@CompileStatic class MongoConnectionSourceFactory extends AbstractConnectionSourceFactory<com.mongodb.client.MongoClient, MongoConnectionSourceSettings>
A factory for building com.mongodb.client.MongoClient instances
| Type | Name and description |
|---|---|
com.mongodb.MongoClientSettings$Builder |
clientOptionsBuilderThe client options builder |
java.util.List<MongoClientSettingsBuilderCustomizer> |
clientSettingsCustomizersOptional customizers applied to the MongoClientSettings.Builder of the default connection source before the com.mongodb.client.MongoClient is created. |
org.bson.codecs.configuration.CodecRegistry |
codecRegistryAn optional additional registry |
java.util.List<org.bson.codecs.Codec> |
codecsOptional additional codecs |
| Constructor and description |
|---|
MongoConnectionSourceFactory() |
| Type Params | Return Type | Name and description |
|---|---|---|
<F extends ConnectionSourceSettings> |
MongoConnectionSourceSettings |
buildRuntimeSettings(java.lang.String name, PropertyResolver configuration, F fallbackSettings) |
<F extends ConnectionSourceSettings> |
protected MongoConnectionSourceSettings |
buildSettings(java.lang.String name, PropertyResolver configuration, F fallbackSettings, boolean isDefaultDataSource) |
|
ConnectionSource<com.mongodb.client.MongoClient, MongoConnectionSourceSettings> |
create(java.lang.String name, MongoConnectionSourceSettings settings)Creates the connection and its client, a RestartableMongoClient that connects the first time it is used or its datastore is started, rather than now. |
|
java.io.Serializable |
getConnectionSourcesConfigurationKey() |
The client options builder
Optional customizers applied to the MongoClientSettings.Builder of the
default connection source before the com.mongodb.client.MongoClient is created. This is the
supported hook for settings that have no grails.mongodb.* equivalent — e.g.
registering a driver com.mongodb.event.CommandListener for metrics/tracing.
An optional additional registry
Optional additional codecs
Creates the connection and its client, a RestartableMongoClient that connects the first time it is used or its datastore is started, rather than now. The settings are built and checked here, so a connection string that cannot be parsed is still reported as the datastore is created.
A subclass that builds the client itself should wrap it the same way, so that it opens no socket before the datastore starts and can be stopped for a CRaC checkpoint and started again after the restore. A client that is not one is closed for the checkpoint instead, and a replacement is built for the restore: return a MongoConnectionSource for it, so that whatever reads the client from the connection source gets the replacement.