public class SimpleMongoClientDbFactory extends MongoDbFactorySupport<com.mongodb.client.MongoClient> implements DisposableBean
MongoDatabase
instances from a MongoClient
instance.Constructor and Description |
---|
SimpleMongoClientDbFactory(com.mongodb.ConnectionString connectionString)
Creates a new
SimpleMongoClientDbFactory instance from the given MongoClient . |
SimpleMongoClientDbFactory(com.mongodb.client.MongoClient mongoClient,
String databaseName)
Creates a new
SimpleMongoClientDbFactory instance from the given MongoClient . |
SimpleMongoClientDbFactory(String connectionString)
Creates a new
SimpleMongoClientDbFactory instance for the given connectionString . |
Modifier and Type | Method and Description |
---|---|
protected void |
closeClient()
Close the client instance.
|
protected com.mongodb.client.MongoDatabase |
doGetMongoDatabase(String dbName)
Get the actual
MongoDatabase from the client. |
com.mongodb.DB |
getLegacyDb()
Get the legacy database entry point.
|
com.mongodb.client.ClientSession |
getSession(com.mongodb.ClientSessionOptions options)
Obtain a
ClientSession for given ClientSessionOptions. |
destroy, getDb, getDb, getDefaultDatabaseName, getExceptionTranslator, getMongoClient, setWriteConcern, withSession
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
destroy
getCodecRegistry, isTransactionActive, withSession
getCodecFor, hasCodecFor
public SimpleMongoClientDbFactory(String connectionString)
SimpleMongoClientDbFactory
instance for the given connectionString
.connectionString
- connection coordinates for a database connection. Must contain a database name and must not
be null or empty.public SimpleMongoClientDbFactory(com.mongodb.ConnectionString connectionString)
SimpleMongoClientDbFactory
instance from the given MongoClient
.connectionString
- connection coordinates for a database connection. Must contain also a database name and not
be null.public SimpleMongoClientDbFactory(com.mongodb.client.MongoClient mongoClient, String databaseName)
SimpleMongoClientDbFactory
instance from the given MongoClient
.mongoClient
- must not be null.databaseName
- must not be null or empty.public com.mongodb.DB getLegacyDb()
MongoDbFactory
MongoDbFactory.getDb()
instead.getLegacyDb
in interface MongoDbFactory
public com.mongodb.client.ClientSession getSession(com.mongodb.ClientSessionOptions options)
MongoDbFactory
ClientSession
for given ClientSessionOptions.getSession
in interface MongoDbFactory
getSession
in interface MongoSessionProvider
options
- must not be null.protected void closeClient()
MongoDbFactorySupport
closeClient
in class MongoDbFactorySupport<com.mongodb.client.MongoClient>
protected com.mongodb.client.MongoDatabase doGetMongoDatabase(String dbName)
MongoDbFactorySupport
MongoDatabase
from the client.doGetMongoDatabase
in class MongoDbFactorySupport<com.mongodb.client.MongoClient>
dbName
- must not be null or empty.Copyright © 2011–2020 Pivotal Software, Inc.. All rights reserved.