Package com.mongodb.async.client
Class MongoClientSettings.Builder
- java.lang.Object
-
- com.mongodb.async.client.MongoClientSettings.Builder
-
- Enclosing class:
- MongoClientSettings
@NotThreadSafe public static final class MongoClientSettings.Builder extends Object
A builder forMongoClientSettings
so thatMongoClientSettings
can be immutable, and to support easier construction through chaining.
-
-
Method Summary
-
-
-
Method Detail
-
applyConnectionString
public MongoClientSettings.Builder applyConnectionString(ConnectionString connectionString)
Takes the settings from the givenConnectionString
and applies them to the builder- Parameters:
connectionString
- the connection string containing details of how to connect to MongoDB- Returns:
- this
- Since:
- 3.7
-
applyToClusterSettings
public MongoClientSettings.Builder applyToClusterSettings(Block<ClusterSettings.Builder> block)
Applies theClusterSettings.Builder
block and then sets the clusterSettings.- Parameters:
block
- the block to apply to the ClusterSettings.- Returns:
- this
- Since:
- 3.7
- See Also:
MongoClientSettings.getClusterSettings()
-
applyToSocketSettings
public MongoClientSettings.Builder applyToSocketSettings(Block<SocketSettings.Builder> block)
Applies theSocketSettings.Builder
block and then sets the socketSettings.- Parameters:
block
- the block to apply to the SocketSettings.- Returns:
- this
- Since:
- 3.7
- See Also:
MongoClientSettings.getSocketSettings()
-
applyToConnectionPoolSettings
public MongoClientSettings.Builder applyToConnectionPoolSettings(Block<ConnectionPoolSettings.Builder> block)
Applies theConnectionPoolSettings.Builder
block and then sets the connectionPoolSettings.- Parameters:
block
- the block to apply to the ConnectionPoolSettings.- Returns:
- this
- Since:
- 3.7
- See Also:
MongoClientSettings.getConnectionPoolSettings()
-
applyToServerSettings
public MongoClientSettings.Builder applyToServerSettings(Block<ServerSettings.Builder> block)
Applies theServerSettings.Builder
block and then sets the serverSettings.- Parameters:
block
- the block to apply to the ServerSettings.- Returns:
- this
- Since:
- 3.7
- See Also:
MongoClientSettings.getServerSettings()
-
applyToSslSettings
public MongoClientSettings.Builder applyToSslSettings(Block<SslSettings.Builder> block)
Applies theSslSettings.Builder
block and then sets the sslSettings.- Parameters:
block
- the block to apply to the SslSettings.- Returns:
- this
- Since:
- 3.7
- See Also:
MongoClientSettings.getSslSettings()
-
clusterSettings
@Deprecated public MongoClientSettings.Builder clusterSettings(ClusterSettings clusterSettings)
Deprecated. PreferapplyToClusterSettings(Block)
Sets the cluster settings.- Parameters:
clusterSettings
- the cluster settings- Returns:
- this
- See Also:
MongoClientSettings.getClusterSettings()
-
socketSettings
@Deprecated public MongoClientSettings.Builder socketSettings(SocketSettings socketSettings)
Deprecated. PreferapplyToSocketSettings(Block)
Sets the socket settings.- Parameters:
socketSettings
- the socket settings- Returns:
- this
- See Also:
MongoClientSettings.getSocketSettings()
-
heartbeatSocketSettings
@Deprecated public MongoClientSettings.Builder heartbeatSocketSettings(SocketSettings heartbeatSocketSettings)
Deprecated. configuring heartbeatSocketSettings will be removed in the future.Sets the heartbeat socket settings.- Parameters:
heartbeatSocketSettings
- the socket settings- Returns:
- this
- See Also:
MongoClientSettings.getHeartbeatSocketSettings()
-
connectionPoolSettings
@Deprecated public MongoClientSettings.Builder connectionPoolSettings(ConnectionPoolSettings connectionPoolSettings)
Deprecated. PreferapplyToConnectionPoolSettings(Block)
Sets the connection pool settings.- Parameters:
connectionPoolSettings
- the connection settings- Returns:
- this
- See Also:
()
-
serverSettings
@Deprecated public MongoClientSettings.Builder serverSettings(ServerSettings serverSettings)
Deprecated. PreferapplyToServerSettings(Block)
Sets the server settings.- Parameters:
serverSettings
- the server settings- Returns:
- this
- See Also:
()
-
sslSettings
@Deprecated public MongoClientSettings.Builder sslSettings(SslSettings sslSettings)
Deprecated. PreferapplyToSslSettings(Block)
Sets the socket settings.- Parameters:
sslSettings
- the SSL settings- Returns:
- this
- See Also:
()
-
readPreference
public MongoClientSettings.Builder readPreference(ReadPreference readPreference)
Sets the read preference.- Parameters:
readPreference
- read preference- Returns:
- this
- See Also:
MongoClientSettings.getReadPreference()
-
writeConcern
public MongoClientSettings.Builder writeConcern(WriteConcern writeConcern)
Sets the write concern.- Parameters:
writeConcern
- the write concern- Returns:
- this
- See Also:
MongoClientSettings.getWriteConcern()
-
retryWrites
public MongoClientSettings.Builder retryWrites(boolean retryWrites)
Sets whether writes should be retried if they fail due to a network error.- Parameters:
retryWrites
- sets if writes should be retried if they fail due to a network error.- Returns:
- this
- Since:
- 3.6
- See Also:
MongoClientSettings.getRetryWrites()
- Since server release
- 3.6
-
readConcern
public MongoClientSettings.Builder readConcern(ReadConcern readConcern)
Sets the read concern.- Parameters:
readConcern
- the read concern- Returns:
- this
- Since:
- 3.2
- MongoDB documentation
- Read Concern
- Since server release
- 3.2
-
credentialList
@Deprecated public MongoClientSettings.Builder credentialList(List<MongoCredential> credentialList)
Deprecated. Prefercredential(MongoCredential)
Sets the credential list.- Parameters:
credentialList
- the credential list- Returns:
- this
- See Also:
MongoClientSettings.getCredentialList()
-
credential
public MongoClientSettings.Builder credential(MongoCredential credential)
Sets the credential.- Parameters:
credential
- the credential- Returns:
- this
- Since:
- 3.6
- See Also:
MongoClientSettings.getCredential()
-
codecRegistry
public MongoClientSettings.Builder codecRegistry(CodecRegistry codecRegistry)
Sets the codec registry- Parameters:
codecRegistry
- the codec registry- Returns:
- this
- Since:
- 3.0
- See Also:
MongoClientSettings.getCodecRegistry()
-
streamFactoryFactory
public MongoClientSettings.Builder streamFactoryFactory(StreamFactoryFactory streamFactoryFactory)
Sets the factory to use to create aStreamFactory
.- Parameters:
streamFactoryFactory
- the stream factory factory- Returns:
- this
- Since:
- 3.1
-
addCommandListener
public MongoClientSettings.Builder addCommandListener(CommandListener commandListener)
Adds the given command listener.- Parameters:
commandListener
- the command listener- Returns:
- this
- Since:
- 3.3
-
applicationName
public MongoClientSettings.Builder applicationName(String applicationName)
Sets the logical name of the application using this MongoClient. The application name may be used by the client to identify the application to the server, for use in server logs, slow query logs, and profile collection.- Parameters:
applicationName
- the logical name of the application using this MongoClient. It may be null. The UTF-8 encoding may not exceed 128 bytes.- Returns:
- this
- Since:
- 3.4
- See Also:
MongoClientSettings.getApplicationName()
- Since server release
- 3.4
-
compressorList
public MongoClientSettings.Builder compressorList(List<MongoCompressor> compressorList)
Sets the compressors to use for compressing messages to the server. The driver will use the first compressor in the list that the server is configured to support.
-
build
public MongoClientSettings build()
Build an instance ofMongoClientSettings
.- Returns:
- the settings from this builder
-
-