@CompileStatic class MongoConnectionSource extends DefaultConnectionSource<com.mongodb.client.MongoClient, MongoConnectionSourceSettings>
The connection source MongoConnectionSourceFactory creates, whose com.mongodb.client.MongoClient can be replaced.
A closed MongoClient cannot be reopened, so a datastore that closes its clients when it is stopped for
a checkpoint builds new ones when it is started again after the restore. Putting each replacement here, where
the original was, means that anything reading the client from the connection source rather than from the
datastore gets the one in use, and that closing the connection source closes it when it is GORM's to close.
| Constructor and description |
|---|
MongoConnectionSource(java.lang.String name, com.mongodb.client.MongoClient client, MongoConnectionSourceSettings settings)A connection source for a client GORM created, which close() closes. |
MongoConnectionSource(java.lang.String name, com.mongodb.client.MongoClient client, MongoConnectionSourceSettings settings, boolean closeable)A connection source that optionally owns its client, for a factory that hands GORM one the application supplied. |
| Type Params | Return Type | Name and description |
|---|---|---|
|
void |
close() |
|
com.mongodb.client.MongoClient |
getSource() |
|
void |
replaceSource(com.mongodb.client.MongoClient replacement)Replaces the client, typically with one built from the same settings after the previous one was closed. |
A connection source for a client GORM created, which close() closes.
name - the name of the connection sourceclient - the clientsettings - the settings A connection source that optionally owns its client, for a factory that hands GORM one the application
supplied. The client is still replaceable, so a datastore that reads it from here after a restore gets
the one in use, but closeable = false leaves closing it to whoever created it.
name - the name of the connection sourceclient - the clientsettings - the settingscloseable - whether close() should close the clientReplaces the client, typically with one built from the same settings after the previous one was closed. The client being replaced is not closed here.
replacement - the client to hand out from now on