@Immutable public final class MongoClientSettings extends java.lang.Object
MongoClient
.Modifier and Type | Class and Description |
---|---|
static class |
MongoClientSettings.Builder
A builder for
MongoClientSettings so that MongoClientSettings can be immutable, and to support easier construction
through chaining. |
Modifier and Type | Method and Description |
---|---|
static MongoClientSettings.Builder |
builder()
Convenience method to create a Builder.
|
static MongoClientSettings.Builder |
builder(MongoClientSettings settings)
Convenience method to create a from an existing
MongoClientSettings . |
java.lang.String |
getApplicationName()
Gets the logical name of the application using this MongoClient.
|
AutoEncryptionSettings |
getAutoEncryptionSettings()
Gets the auto-encryption settings.
|
ClusterSettings |
getClusterSettings()
Gets the cluster settings.
|
CodecRegistry |
getCodecRegistry()
The codec registry to use, or null if not set.
|
java.util.List<CommandListener> |
getCommandListeners()
Gets the list of added
CommandListener . |
java.util.List<MongoCompressor> |
getCompressorList()
Gets the compressors to use for compressing messages to the server.
|
ConnectionPoolSettings |
getConnectionPoolSettings()
Gets the settings for the connection provider in a settings object.
|
MongoCredential |
getCredential()
Gets the credential.
|
static CodecRegistry |
getDefaultCodecRegistry()
Gets the default codec registry.
|
SocketSettings |
getHeartbeatSocketSettings()
Gets the connection settings for the heartbeat thread (the background task that checks the state of the cluster) wrapped in a
settings object.
|
ReadConcern |
getReadConcern()
The read concern to use.
|
ReadPreference |
getReadPreference()
The read preference to use for queries, map-reduce, aggregation, and count.
|
boolean |
getRetryReads()
Returns true if reads should be retried if they fail due to a network error or other retryable error.
|
boolean |
getRetryWrites()
Returns true if writes should be retried if they fail due to a network error or other retryable error.
|
ServerSettings |
getServerSettings()
Gets the server-specific settings wrapped in a settings object.
|
SocketSettings |
getSocketSettings()
Gets the connection-specific settings wrapped in a settings object.
|
SslSettings |
getSslSettings()
Gets the SSL settings.
|
StreamFactoryFactory |
getStreamFactoryFactory()
Gets the factory to use to create a
StreamFactory . |
UuidRepresentation |
getUuidRepresentation()
Gets the UUID representation to use when encoding instances of
UUID and when decoding BSON binary values with
subtype of 3. |
WriteConcern |
getWriteConcern()
The write concern to use.
|
public static CodecRegistry getDefaultCodecRegistry()
public static MongoClientSettings.Builder builder()
public static MongoClientSettings.Builder builder(MongoClientSettings settings)
MongoClientSettings
.settings
- create a builder from existing settingspublic ReadPreference getReadPreference()
Default is ReadPreference.primary()
.
ReadPreference.primary()
@Nullable public MongoCredential getCredential()
public WriteConcern getWriteConcern()
Default is WriteConcern.ACKNOWLEDGED
.
WriteConcern.ACKNOWLEDGED
public boolean getRetryWrites()
Starting with the 3.11.0 release, the default value is true
public boolean getRetryReads()
public ReadConcern getReadConcern()
public CodecRegistry getCodecRegistry()
@Nullable public StreamFactoryFactory getStreamFactoryFactory()
StreamFactory
.public java.util.List<CommandListener> getCommandListeners()
CommandListener
.
The default is an empty list.
@Nullable public java.lang.String getApplicationName()
Default is null.
public java.util.List<MongoCompressor> getCompressorList()
Default is the empty list.
public UuidRepresentation getUuidRepresentation()
UUID
and when decoding BSON binary values with
subtype of 3.
The default is UuidRepresentation.JAVA_LEGACY
, but it will be changing to UuidRepresentation.UNSPECIFIED
in
the next major release. If your application stores UUID values in MongoDB, consider setting this value to the desired
representation in order to avoid a breaking change when upgrading. New applications should prefer
UuidRepresentation.STANDARD
, while existing Java applications should prefer UuidRepresentation.JAVA_LEGACY
.
Applications wishing to interoperate with existing Python or .NET applications should prefer
UuidRepresentation.PYTHON_LEGACY
or UuidRepresentation.C_SHARP_LEGACY
, respectively. Applications that do not
store UUID values in MongoDB don't need to set this value.
@Nullable public AutoEncryptionSettings getAutoEncryptionSettings()
Client side encryption enables an application to specify what fields in a collection must be encrypted, and the driver automatically encrypts commands and decrypts results.
Automatic encryption is an enterprise only feature that only applies to operations on a collection. Automatic encryption is not supported for operations on a database or view and will result in error. To bypass automatic encryption, set bypassAutoEncryption=true in ClientSideEncryptionOptions.
Explicit encryption/decryption and automatic decryption is a community feature, enabled with the new
com.mongodb.client.vault .ClientEncryption
type. A MongoClient configured with bypassAutoEncryption=true will still
automatically decrypt.
Automatic encryption requires the authenticated user to have the listCollections privilege action.
Note: support for client side encryption is in beta. Backwards-breaking changes may be made before the final release.
public ClusterSettings getClusterSettings()
public SslSettings getSslSettings()
public SocketSettings getSocketSettings()
MongoClientSettings
instance.SocketSettings
public SocketSettings getHeartbeatSocketSettings()
SocketSettings
public ConnectionPoolSettings getConnectionPoolSettings()
MongoClientSettings
instance that relate to the
connection provider.ConnectionPoolSettings
public ServerSettings getServerSettings()
MongoClientSettings
instance.ServerSettings
Copyright © 2010 - 2023 Adobe. All Rights Reserved