Class MongoClientOptions.Builder
- java.lang.Object
-
- com.mongodb.MongoClientOptions.Builder
-
- Enclosing class:
- MongoClientOptions
@NotThreadSafe @Deprecated(since="2021-05-27") public static class MongoClientOptions.Builder extends java.lang.Object
Deprecated.Usage of this API is not supported in AEM as a Cloud Service.A builder for MongoClientOptions so that MongoClientOptions can be immutable, and to support easier construction through chaining.- Since:
- 2.10.0
-
-
Constructor Summary
Constructors Constructor Description Builder()
Deprecated.Creates a Builder for MongoClientOptions, getting the appropriate system properties for initialization.Builder(MongoClientOptions options)
Deprecated.Creates a Builder from an existing MongoClientOptions.
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description MongoClientOptions.Builder
addClusterListener(ClusterListener clusterListener)
Deprecated.Adds the given cluster listener.MongoClientOptions.Builder
addCommandListener(CommandListener commandListener)
Deprecated.Adds the given command listener.MongoClientOptions.Builder
addConnectionPoolListener(ConnectionPoolListener connectionPoolListener)
Deprecated.Adds the given connection pool listener.MongoClientOptions.Builder
addServerListener(ServerListener serverListener)
Deprecated.Adds the given server listener.MongoClientOptions.Builder
addServerMonitorListener(ServerMonitorListener serverMonitorListener)
Deprecated.Adds the given server monitor listener.MongoClientOptions.Builder
alwaysUseMBeans(boolean alwaysUseMBeans)
Deprecated.there is no replacement for this propertyMongoClientOptions.Builder
applicationName(java.lang.String applicationName)
Deprecated.Sets the logical name of the application using this MongoClient.MongoClientOptions.Builder
autoEncryptionSettings(AutoEncryptionSettings autoEncryptionSettings)
Deprecated.Set options for auto-encryption.MongoClientOptions
build()
Deprecated.Build an instance of MongoClientOptions.MongoClientOptions.Builder
codecRegistry(CodecRegistry codecRegistry)
Deprecated.Sets the codec registryMongoClientOptions.Builder
compressorList(java.util.List<MongoCompressor> compressorList)
Deprecated.Sets the compressors to use for compressing messages to the server.MongoClientOptions.Builder
connectionsPerHost(int connectionsPerHost)
Deprecated.Sets the maximum number of connections per host.MongoClientOptions.Builder
connectTimeout(int connectTimeout)
Deprecated.Sets the connection timeout.MongoClientOptions.Builder
cursorFinalizerEnabled(boolean cursorFinalizerEnabled)
Deprecated.Sets whether cursor finalizers are enabled.MongoClientOptions.Builder
dbDecoderFactory(DBDecoderFactory dbDecoderFactory)
Deprecated.Sets the decoder factory.MongoClientOptions.Builder
dbEncoderFactory(DBEncoderFactory dbEncoderFactory)
Deprecated.Sets the encoder factory.MongoClientOptions.Builder
description(java.lang.String description)
Deprecated.PreferapplicationName(String)
MongoClientOptions.Builder
heartbeatConnectTimeout(int connectTimeout)
Deprecated.Sets the connect timeout for connections used for the cluster heartbeat.MongoClientOptions.Builder
heartbeatFrequency(int heartbeatFrequency)
Deprecated.Sets the heartbeat frequency.MongoClientOptions.Builder
heartbeatSocketTimeout(int socketTimeout)
Deprecated.Sets the socket timeout for connections used for the cluster heartbeat.MongoClientOptions.Builder
legacyDefaults()
Deprecated.there is no replacement for this methodMongoClientOptions.Builder
localThreshold(int localThreshold)
Deprecated.Sets the local threshold.MongoClientOptions.Builder
maxConnectionIdleTime(int maxConnectionIdleTime)
Deprecated.Sets the maximum idle time for a pooled connection.MongoClientOptions.Builder
maxConnectionLifeTime(int maxConnectionLifeTime)
Deprecated.Sets the maximum life time for a pooled connection.MongoClientOptions.Builder
maxWaitTime(int maxWaitTime)
Deprecated.Sets the maximum time that a thread will block waiting for a connection.MongoClientOptions.Builder
minConnectionsPerHost(int minConnectionsPerHost)
Deprecated.Sets the minimum number of connections per host.MongoClientOptions.Builder
minHeartbeatFrequency(int minHeartbeatFrequency)
Deprecated.Sets the minimum heartbeat frequency.MongoClientOptions.Builder
readConcern(ReadConcern readConcern)
Deprecated.Sets the read concern.MongoClientOptions.Builder
readPreference(ReadPreference readPreference)
Deprecated.Sets the read preference.MongoClientOptions.Builder
requiredReplicaSetName(java.lang.String requiredReplicaSetName)
Deprecated.Sets the required replica set name for the cluster.MongoClientOptions.Builder
retryReads(boolean retryReads)
Deprecated.Sets whether reads should be retried if they fail due to a network error.MongoClientOptions.Builder
retryWrites(boolean retryWrites)
Deprecated.Sets whether writes should be retried if they fail due to a network error.MongoClientOptions.Builder
serverSelectionTimeout(int serverSelectionTimeout)
Deprecated.Sets the server selection timeout in milliseconds, which defines how long the driver will wait for server selection to succeed before throwing an exception.MongoClientOptions.Builder
serverSelector(ServerSelector serverSelector)
Deprecated.Sets a server selector that augments the normal server selection rules applied by the driver when determining which server to send an operation to.MongoClientOptions.Builder
socketFactory(javax.net.SocketFactory socketFactory)
Deprecated.PrefersslEnabled(boolean)
andsslContext(SSLContext)
MongoClientOptions.Builder
socketKeepAlive(boolean socketKeepAlive)
Deprecated.configuring keep-alive has been deprecated.MongoClientOptions.Builder
socketTimeout(int socketTimeout)
Deprecated.Sets the socket timeout.MongoClientOptions.Builder
sslContext(javax.net.ssl.SSLContext sslContext)
Deprecated.Sets the SSLContext to be used with SSL is enabled.MongoClientOptions.Builder
sslEnabled(boolean sslEnabled)
Deprecated.Sets whether to use SSL.MongoClientOptions.Builder
sslInvalidHostNameAllowed(boolean sslInvalidHostNameAllowed)
Deprecated.Define whether invalid host names should be allowed.MongoClientOptions.Builder
threadsAllowedToBlockForConnectionMultiplier(int threadsAllowedToBlockForConnectionMultiplier)
Deprecated.in the next major release, wait queue size limitations will be removedMongoClientOptions.Builder
uuidRepresentation(UuidRepresentation uuidRepresentation)
Deprecated.Sets the UUID representation to use when encoding instances ofUUID
and when decoding BSON binary values with subtype of 3.MongoClientOptions.Builder
writeConcern(WriteConcern writeConcern)
Deprecated.Sets the write concern.
-
-
-
Constructor Detail
-
Builder
public Builder()
Deprecated.Creates a Builder for MongoClientOptions, getting the appropriate system properties for initialization.
-
Builder
public Builder(MongoClientOptions options)
Deprecated.Creates a Builder from an existing MongoClientOptions.- Parameters:
options
- create a builder from existing options
-
-
Method Detail
-
description
@Deprecated public MongoClientOptions.Builder description(java.lang.String description)
Deprecated.PreferapplicationName(String)
Sets the description.- Parameters:
description
- the description of this MongoClient- Returns:
this
- See Also:
MongoClientOptions.getDescription()
-
applicationName
public MongoClientOptions.Builder applicationName(java.lang.String applicationName)
Deprecated.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:
MongoClientOptions.getApplicationName()
-
compressorList
public MongoClientOptions.Builder compressorList(java.util.List<MongoCompressor> compressorList)
Deprecated.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.- Parameters:
compressorList
- the list of compressors to request- Returns:
this
- Since:
- 3.6
- See Also:
MongoClientOptions.getCompressorList()
-
minConnectionsPerHost
public MongoClientOptions.Builder minConnectionsPerHost(int minConnectionsPerHost)
Deprecated.Sets the minimum number of connections per host.- Parameters:
minConnectionsPerHost
- minimum number of connections- Returns:
this
- Throws:
java.lang.IllegalArgumentException
- ifminConnectionsPerHost < 0
- Since:
- 2.12
- See Also:
MongoClientOptions.getMinConnectionsPerHost()
-
connectionsPerHost
public MongoClientOptions.Builder connectionsPerHost(int connectionsPerHost)
Deprecated.Sets the maximum number of connections per host.- Parameters:
connectionsPerHost
- maximum number of connections- Returns:
this
- Throws:
java.lang.IllegalArgumentException
- ifconnectionsPerHost < 1
- See Also:
MongoClientOptions.getConnectionsPerHost()
-
threadsAllowedToBlockForConnectionMultiplier
@Deprecated public MongoClientOptions.Builder threadsAllowedToBlockForConnectionMultiplier(int threadsAllowedToBlockForConnectionMultiplier)
Deprecated.in the next major release, wait queue size limitations will be removedSets the multiplier for number of threads allowed to block waiting for a connection.- Parameters:
threadsAllowedToBlockForConnectionMultiplier
- the multiplier- Returns:
this
- Throws:
java.lang.IllegalArgumentException
- ifthreadsAllowedToBlockForConnectionMultiplier < 1
- See Also:
MongoClientOptions.getThreadsAllowedToBlockForConnectionMultiplier()
-
serverSelectionTimeout
public MongoClientOptions.Builder serverSelectionTimeout(int serverSelectionTimeout)
Deprecated.Sets the server selection timeout in milliseconds, which defines how long the driver will wait for server selection to succeed before throwing an exception.
A value of 0 means that it will timeout immediately if no server is available. A negative value means to wait indefinitely.
- Parameters:
serverSelectionTimeout
- the server selection timeout, in milliseconds- Returns:
this
- See Also:
MongoClientOptions.getServerSelectionTimeout()
-
maxWaitTime
public MongoClientOptions.Builder maxWaitTime(int maxWaitTime)
Deprecated.Sets the maximum time that a thread will block waiting for a connection.- Parameters:
maxWaitTime
- the maximum wait time, in milliseconds- Returns:
this
- See Also:
MongoClientOptions.getMaxWaitTime()
-
maxConnectionIdleTime
public MongoClientOptions.Builder maxConnectionIdleTime(int maxConnectionIdleTime)
Deprecated.Sets the maximum idle time for a pooled connection.- Parameters:
maxConnectionIdleTime
- the maximum idle time, in milliseconds, which must be >= 0. A zero value indicates no limit to the life time.- Returns:
this
- Throws:
java.lang.IllegalArgumentException
- ifmaxConnectionIdleTime < 0
- Since:
- 2.12
- See Also:
MongoClientOptions.getMaxConnectionIdleTime()
-
maxConnectionLifeTime
public MongoClientOptions.Builder maxConnectionLifeTime(int maxConnectionLifeTime)
Deprecated.Sets the maximum life time for a pooled connection.- Parameters:
maxConnectionLifeTime
- the maximum life time, in milliseconds, which must be >= 0. A zero value indicates no limit to the life time.- Returns:
this
- Throws:
java.lang.IllegalArgumentException
- ifmaxConnectionLifeTime < 0
- Since:
- 2.12
- See Also:
MongoClientOptions.getMaxConnectionIdleTime()
-
connectTimeout
public MongoClientOptions.Builder connectTimeout(int connectTimeout)
Deprecated.Sets the connection timeout.- Parameters:
connectTimeout
- the connection timeout, in milliseconds, which must be > 0- Returns:
this
- Throws:
java.lang.IllegalArgumentException
- ifconnectTimeout <= 0
- See Also:
MongoClientOptions.getConnectTimeout()
-
socketTimeout
public MongoClientOptions.Builder socketTimeout(int socketTimeout)
Deprecated.Sets the socket timeout.- Parameters:
socketTimeout
- the socket timeout, in milliseconds- Returns:
this
- See Also:
MongoClientOptions.getSocketTimeout()
-
socketKeepAlive
@Deprecated public MongoClientOptions.Builder socketKeepAlive(boolean socketKeepAlive)
Deprecated.configuring keep-alive has been deprecated. It now defaults to true and disabling it is not recommended.Sets whether socket keep-alive is enabled.- Parameters:
socketKeepAlive
- keep-alive- Returns:
this
- See Also:
- Does TCP keep-alive time affect MongoDB Deployments?
-
sslEnabled
public MongoClientOptions.Builder sslEnabled(boolean sslEnabled)
Deprecated.Sets whether to use SSL.If the socketFactory is unset, setting this to true will also set the socketFactory to
SSLSocketFactory.getDefault()
and setting it to false will set the socketFactory toSocketFactory.getDefault()
If the socket factory is set and sslEnabled is also set, the socket factory must create instances of
SSLSocket
. Otherwise, MongoClient will refuse to connect.- Parameters:
sslEnabled
- set to true if using SSL- Returns:
this
- Since:
- 3.0
- See Also:
MongoClientOptions.isSslEnabled()
,MongoClientOptions.getSocketFactory()
-
sslInvalidHostNameAllowed
public MongoClientOptions.Builder sslInvalidHostNameAllowed(boolean sslInvalidHostNameAllowed)
Deprecated.Define whether invalid host names should be allowed. Defaults to false. Take care before setting this to true, as it makes the application susceptible to man-in-the-middle attacks.- Parameters:
sslInvalidHostNameAllowed
- whether invalid host names are allowed in SSL certificates.- Returns:
- this
-
sslContext
public MongoClientOptions.Builder sslContext(javax.net.ssl.SSLContext sslContext)
Deprecated.Sets the SSLContext to be used with SSL is enabled. This property is ignored when either sslEnabled is false or socketFactory is non-null.- Parameters:
sslContext
- the SSLContext to be used for SSL connections- Returns:
this
- Since:
- 3.5
-
readPreference
public MongoClientOptions.Builder readPreference(ReadPreference readPreference)
Deprecated.Sets the read preference.- Parameters:
readPreference
- read preference- Returns:
this
- See Also:
MongoClientOptions.getReadPreference()
-
writeConcern
public MongoClientOptions.Builder writeConcern(WriteConcern writeConcern)
Deprecated.Sets the write concern.- Parameters:
writeConcern
- the write concern- Returns:
this
- See Also:
MongoClientOptions.getWriteConcern()
-
retryWrites
public MongoClientOptions.Builder retryWrites(boolean retryWrites)
Deprecated.Sets whether writes should be retried if they fail due to a network error.Starting with the 3.11.0 release, the default value is true
- Parameters:
retryWrites
- sets if writes should be retried if they fail due to a network error.- Returns:
this
- Since:
- 3.6
- See Also:
MongoClientOptions.getRetryWrites()
-
retryReads
public MongoClientOptions.Builder retryReads(boolean retryReads)
Deprecated.Sets whether reads should be retried if they fail due to a network error.- Parameters:
retryReads
- sets if reads should be retried if they fail due to a network error.- Returns:
this
- Since:
- 3.11
- See Also:
MongoClientOptions.getRetryReads()
-
readConcern
public MongoClientOptions.Builder readConcern(ReadConcern readConcern)
Deprecated.Sets the read concern.- Parameters:
readConcern
- the read concern.- Returns:
- this
- Since:
- 3.2
- See Also:
MongoClientOptions.getReadConcern()
-
codecRegistry
public MongoClientOptions.Builder codecRegistry(CodecRegistry codecRegistry)
Deprecated.Sets the codec registryNote that instances of
DB
andDBCollection
do not use the registry, so it's not necessary to include a codec for DBObject in the registry.- Parameters:
codecRegistry
- the codec registry- Returns:
this
- Since:
- 3.0
- See Also:
MongoClientOptions.getCodecRegistry()
-
uuidRepresentation
public MongoClientOptions.Builder uuidRepresentation(UuidRepresentation uuidRepresentation)
Deprecated.Sets the UUID representation to use when encoding instances ofUUID
and when decoding BSON binary values with subtype of 3.See
MongoClientOptions.getUuidRepresentation()
for recommendations on settings this value- Parameters:
uuidRepresentation
- the UUID representation, which may not be null- Returns:
- this
- Since:
- 3.12
-
serverSelector
public MongoClientOptions.Builder serverSelector(ServerSelector serverSelector)
Deprecated.Sets a server selector that augments the normal server selection rules applied by the driver when determining which server to send an operation to. SeeMongoClientOptions.getServerSelector()
for further details.- Parameters:
serverSelector
- the server selector- Returns:
- this
- Since:
- 3.6
- See Also:
MongoClientOptions.getServerSelector()
-
addCommandListener
public MongoClientOptions.Builder addCommandListener(CommandListener commandListener)
Deprecated.Adds the given command listener.- Parameters:
commandListener
- the non-null command listener- Returns:
- this
- Since:
- 3.1
-
addConnectionPoolListener
public MongoClientOptions.Builder addConnectionPoolListener(ConnectionPoolListener connectionPoolListener)
Deprecated.Adds the given connection pool listener.- Parameters:
connectionPoolListener
- the non-null connection pool listener- Returns:
- this
- Since:
- 3.5
-
addClusterListener
public MongoClientOptions.Builder addClusterListener(ClusterListener clusterListener)
Deprecated.Adds the given cluster listener.- Parameters:
clusterListener
- the non-null cluster listener- Returns:
- this
- Since:
- 3.3
-
addServerListener
public MongoClientOptions.Builder addServerListener(ServerListener serverListener)
Deprecated.Adds the given server listener.- Parameters:
serverListener
- the non-null server listener- Returns:
- this
- Since:
- 3.3
-
addServerMonitorListener
public MongoClientOptions.Builder addServerMonitorListener(ServerMonitorListener serverMonitorListener)
Deprecated.Adds the given server monitor listener.- Parameters:
serverMonitorListener
- the non-null server monitor listener- Returns:
- this
- Since:
- 3.3
-
socketFactory
@Deprecated public MongoClientOptions.Builder socketFactory(javax.net.SocketFactory socketFactory)
Deprecated.PrefersslEnabled(boolean)
andsslContext(SSLContext)
Sets the socket factory.- Parameters:
socketFactory
- the socket factory- Returns:
this
- See Also:
MongoClientOptions.getSocketFactory()
-
cursorFinalizerEnabled
public MongoClientOptions.Builder cursorFinalizerEnabled(boolean cursorFinalizerEnabled)
Deprecated.Sets whether cursor finalizers are enabled.- Parameters:
cursorFinalizerEnabled
- whether cursor finalizers are enabled.- Returns:
this
- See Also:
MongoClientOptions.isCursorFinalizerEnabled()
-
alwaysUseMBeans
@Deprecated public MongoClientOptions.Builder alwaysUseMBeans(boolean alwaysUseMBeans)
Deprecated.there is no replacement for this propertySets whether JMX beans registered by the driver should always be MBeans, regardless of whether the VM is Java 6 or greater. If false, the driver will use MXBeans if the VM is Java 6 or greater, and use MBeans if the VM is Java 5.- Parameters:
alwaysUseMBeans
- true if driver should always use MBeans, regardless of VM version- Returns:
- this
- See Also:
MongoClientOptions.isAlwaysUseMBeans()
-
dbDecoderFactory
public MongoClientOptions.Builder dbDecoderFactory(DBDecoderFactory dbDecoderFactory)
Deprecated.Sets the decoder factory.- Parameters:
dbDecoderFactory
- the decoder factory- Returns:
this
- See Also:
MongoClientOptions.getDbDecoderFactory()
-
dbEncoderFactory
public MongoClientOptions.Builder dbEncoderFactory(DBEncoderFactory dbEncoderFactory)
Deprecated.Sets the encoder factory.- Parameters:
dbEncoderFactory
- the encoder factory- Returns:
this
- See Also:
MongoClientOptions.getDbEncoderFactory()
-
heartbeatFrequency
public MongoClientOptions.Builder heartbeatFrequency(int heartbeatFrequency)
Deprecated.Sets the heartbeat frequency. This is the frequency that the driver will attempt to determine the current state of each server in the cluster. The default value is 10,000 milliseconds- Parameters:
heartbeatFrequency
- the heartbeat frequency for the cluster, in milliseconds, which must be > 0- Returns:
this
- Throws:
java.lang.IllegalArgumentException
- if heartbeatFrequency is not > 0- Since:
- 2.12
- See Also:
MongoClientOptions.getHeartbeatFrequency()
-
minHeartbeatFrequency
public MongoClientOptions.Builder minHeartbeatFrequency(int minHeartbeatFrequency)
Deprecated.Sets the minimum heartbeat frequency. In the event that the driver has to frequently re-check a server's availability, it will wait at least this long since the previous check to avoid wasted effort. The default value is 500 milliseconds.- Parameters:
minHeartbeatFrequency
- the minimum heartbeat frequency, in milliseconds, which must be > 0- Returns:
this
- Throws:
java.lang.IllegalArgumentException
- ifminHeartbeatFrequency <= 0
- Since:
- 2.13
- See Also:
MongoClientOptions.getMinHeartbeatFrequency()
-
heartbeatConnectTimeout
public MongoClientOptions.Builder heartbeatConnectTimeout(int connectTimeout)
Deprecated.Sets the connect timeout for connections used for the cluster heartbeat.- Parameters:
connectTimeout
- the connection timeout, in milliseconds- Returns:
this
- Since:
- 2.12
- See Also:
MongoClientOptions.getHeartbeatConnectTimeout()
-
heartbeatSocketTimeout
public MongoClientOptions.Builder heartbeatSocketTimeout(int socketTimeout)
Deprecated.Sets the socket timeout for connections used for the cluster heartbeat.- Parameters:
socketTimeout
- the socket timeout, in milliseconds- Returns:
this
- Since:
- 2.12
- See Also:
MongoClientOptions.getHeartbeatSocketTimeout()
-
localThreshold
public MongoClientOptions.Builder localThreshold(int localThreshold)
Deprecated.Sets the local threshold.- Parameters:
localThreshold
- the acceptable latency difference, in milliseconds, which must be >= 0- Returns:
this
- Throws:
java.lang.IllegalArgumentException
- iflocalThreshold < 0
- Since:
- 2.13.0
- See Also:
MongoClientOptions.getLocalThreshold()
-
requiredReplicaSetName
public MongoClientOptions.Builder requiredReplicaSetName(java.lang.String requiredReplicaSetName)
Deprecated.Sets the required replica set name for the cluster.- Parameters:
requiredReplicaSetName
- the required replica set name for the replica set.- Returns:
- this
- Since:
- 2.12
- See Also:
MongoClientOptions.getRequiredReplicaSetName()
-
autoEncryptionSettings
public MongoClientOptions.Builder autoEncryptionSettings(AutoEncryptionSettings autoEncryptionSettings)
Deprecated.Set options for auto-encryption.- Parameters:
autoEncryptionSettings
- auto encryption settings- Returns:
- this
- Since:
- 3.11
-
legacyDefaults
@Deprecated public MongoClientOptions.Builder legacyDefaults()
Deprecated.there is no replacement for this methodSets defaults to be what they are inMongoOptions
.- Returns:
this
- See Also:
MongoOptions
-
build
public MongoClientOptions build()
Deprecated.Build an instance of MongoClientOptions.- Returns:
- the options from this builder
-
-