@NotThreadSafe public static final class MongoClientSettings.Builder extends java.lang.Object
MongoClientSettings
so that MongoClientSettings
can be immutable, and to support easier construction
through chaining.Modifier and Type | Method and Description |
---|---|
MongoClientSettings.Builder |
addCommandListener(CommandListener commandListener)
Adds the given command listener.
|
MongoClientSettings.Builder |
applicationName(java.lang.String applicationName)
Sets the logical name of the application using this MongoClient.
|
MongoClientSettings.Builder |
applyConnectionString(ConnectionString connectionString)
Takes the settings from the given
ConnectionString and applies them to the builder |
MongoClientSettings.Builder |
applyToClusterSettings(Block<ClusterSettings.Builder> block)
Applies the
ClusterSettings.Builder block and then sets the clusterSettings. |
MongoClientSettings.Builder |
applyToConnectionPoolSettings(Block<ConnectionPoolSettings.Builder> block)
Applies the
ConnectionPoolSettings.Builder block and then sets the connectionPoolSettings. |
MongoClientSettings.Builder |
applyToServerSettings(Block<ServerSettings.Builder> block)
Applies the
ServerSettings.Builder block and then sets the serverSettings. |
MongoClientSettings.Builder |
applyToSocketSettings(Block<SocketSettings.Builder> block)
Applies the
SocketSettings.Builder block and then sets the socketSettings. |
MongoClientSettings.Builder |
applyToSslSettings(Block<SslSettings.Builder> block)
Applies the
SslSettings.Builder block and then sets the sslSettings. |
MongoClientSettings |
build()
Build an instance of
MongoClientSettings . |
MongoClientSettings.Builder |
codecRegistry(CodecRegistry codecRegistry)
Sets the codec registry
|
MongoClientSettings.Builder |
commandListenerList(java.util.List<CommandListener> commandListeners)
Sets the the command listeners
|
MongoClientSettings.Builder |
compressorList(java.util.List<MongoCompressor> compressorList)
Sets the compressors to use for compressing messages to the server.
|
MongoClientSettings.Builder |
credential(MongoCredential credential)
Sets the credential.
|
MongoClientSettings.Builder |
readConcern(ReadConcern readConcern)
Sets the read concern.
|
MongoClientSettings.Builder |
readPreference(ReadPreference readPreference)
Sets the read preference.
|
MongoClientSettings.Builder |
retryWrites(boolean retryWrites)
Sets whether writes should be retried if they fail due to a network error.
|
MongoClientSettings.Builder |
streamFactoryFactory(StreamFactoryFactory streamFactoryFactory)
Sets the factory to use to create a
StreamFactory . |
MongoClientSettings.Builder |
writeConcern(WriteConcern writeConcern)
Sets the write concern.
|
public MongoClientSettings.Builder applyConnectionString(ConnectionString connectionString)
ConnectionString
and applies them to the builderconnectionString
- the connection string containing details of how to connect to MongoDBpublic MongoClientSettings.Builder applyToClusterSettings(Block<ClusterSettings.Builder> block)
ClusterSettings.Builder
block and then sets the clusterSettings.block
- the block to apply to the ClusterSettings.MongoClientSettings.getClusterSettings()
public MongoClientSettings.Builder applyToSocketSettings(Block<SocketSettings.Builder> block)
SocketSettings.Builder
block and then sets the socketSettings.block
- the block to apply to the SocketSettings.MongoClientSettings.getSocketSettings()
public MongoClientSettings.Builder applyToConnectionPoolSettings(Block<ConnectionPoolSettings.Builder> block)
ConnectionPoolSettings.Builder
block and then sets the connectionPoolSettings.block
- the block to apply to the ConnectionPoolSettings.MongoClientSettings.getConnectionPoolSettings()
public MongoClientSettings.Builder applyToServerSettings(Block<ServerSettings.Builder> block)
ServerSettings.Builder
block and then sets the serverSettings.block
- the block to apply to the ServerSettings.MongoClientSettings.getServerSettings()
public MongoClientSettings.Builder applyToSslSettings(Block<SslSettings.Builder> block)
SslSettings.Builder
block and then sets the sslSettings.block
- the block to apply to the SslSettings.MongoClientSettings.getSslSettings()
public MongoClientSettings.Builder readPreference(ReadPreference readPreference)
readPreference
- read preferenceMongoClientSettings.getReadPreference()
public MongoClientSettings.Builder writeConcern(WriteConcern writeConcern)
writeConcern
- the write concernMongoClientSettings.getWriteConcern()
public MongoClientSettings.Builder retryWrites(boolean retryWrites)
retryWrites
- sets if writes should be retried if they fail due to a network error.MongoClientSettings.getRetryWrites()
public MongoClientSettings.Builder readConcern(ReadConcern readConcern)
readConcern
- the read concernpublic MongoClientSettings.Builder credential(MongoCredential credential)
credential
- the credentialpublic MongoClientSettings.Builder codecRegistry(CodecRegistry codecRegistry)
codecRegistry
- the codec registryMongoClientSettings.getCodecRegistry()
public MongoClientSettings.Builder streamFactoryFactory(StreamFactoryFactory streamFactoryFactory)
StreamFactory
.streamFactoryFactory
- the stream factory factorypublic MongoClientSettings.Builder addCommandListener(CommandListener commandListener)
commandListener
- the command listenerpublic MongoClientSettings.Builder commandListenerList(java.util.List<CommandListener> commandListeners)
commandListeners
- the list of command listenerspublic MongoClientSettings.Builder applicationName(@Nullable java.lang.String applicationName)
applicationName
- the logical name of the application using this MongoClient. It may be null.
The UTF-8 encoding may not exceed 128 bytes.MongoClientSettings.getApplicationName()
public MongoClientSettings.Builder compressorList(java.util.List<MongoCompressor> compressorList)
compressorList
- the list of compressors to requestMongoClientSettings.getCompressorList()
public MongoClientSettings build()
MongoClientSettings
.Copyright © 2010 - 2020 Adobe. All Rights Reserved