Package org.springframework.data.mongodb
Interface ReactiveMongoDatabaseFactory
- All Superinterfaces:
CodecRegistryProvider
- All Known Implementing Classes:
SimpleReactiveMongoDatabaseFactory
Interface for factories creating reactive
MongoDatabase
instances.- Since:
- 2.0
- Author:
- Mark Paluch, Christoph Strobl, Mathieu Ouellet
-
Method Summary
Modifier and TypeMethodDescriptioncreate
(com.mongodb.ConnectionString connectionString) Creates a newSimpleReactiveMongoDatabaseFactory
instance from the givenMongoClient
.static ReactiveMongoDatabaseFactory
Creates a newMongoDatabaseFactory
instance from the givenMongoClient
.Creates a newSimpleReactiveMongoDatabaseFactory
instance for the givenconnectionString
.org.bson.codecs.configuration.CodecRegistry
Get the underlyingCodecRegistry
used by the reactive MongoDB Java driver.Exposes a sharedMongoExceptionTranslator
.Mono<com.mongodb.reactivestreams.client.MongoDatabase>
Creates a defaultMongoDatabase
instance.Mono<com.mongodb.reactivestreams.client.MongoDatabase>
getMongoDatabase
(String dbName) Obtain aMongoDatabase
instance to access the database with the given name.Mono<com.mongodb.reactivestreams.client.ClientSession>
getSession
(com.mongodb.ClientSessionOptions options) default boolean
Returns if the givenReactiveMongoDatabaseFactory
is bound to aClientSession
that has anactive transaction
.withSession
(com.mongodb.reactivestreams.client.ClientSession session) Obtain aClientSession
bound instance ofReactiveMongoDatabaseFactory
returningMongoDatabase
instances that are aware and bound to the given session.Methods inherited from interface org.springframework.data.mongodb.CodecRegistryProvider
getCodecFor, hasCodecFor
-
Method Details
-
create
Creates a newSimpleReactiveMongoDatabaseFactory
instance for the givenconnectionString
. Using this factory method will create a newMongoClient
instance that will be closed when callingSimpleReactiveMongoDatabaseFactory.destroy()
.- Parameters:
connectionString
- connection coordinates for a database connection. Must contain a database name and must not be null or empty.- Since:
- 4.5.2
- See Also:
-
create
Creates a newSimpleReactiveMongoDatabaseFactory
instance from the givenMongoClient
. Using this factory will create a newMongoClient
instance that will be closed when callingSimpleReactiveMongoDatabaseFactory.destroy()
.- Parameters:
connectionString
- connection coordinates for a database connection. Must contain also a database name and not be null.- Since:
- 4.5.2
-
create
static ReactiveMongoDatabaseFactory create(com.mongodb.reactivestreams.client.MongoClient mongoClient, String databaseName) Creates a newMongoDatabaseFactory
instance from the givenMongoClient
. We assume a managed client instance that will be disposed by you (or the application container) once the client is no longer required for use.- Parameters:
mongoClient
- must not be null.databaseName
- must not be null or empty.- Since:
- 4.5.2
-
getMongoDatabase
Mono<com.mongodb.reactivestreams.client.MongoDatabase> getMongoDatabase() throws DataAccessExceptionCreates a defaultMongoDatabase
instance.- Returns:
- never null.
- Throws:
DataAccessException
-
getMongoDatabase
Mono<com.mongodb.reactivestreams.client.MongoDatabase> getMongoDatabase(String dbName) throws DataAccessException Obtain aMongoDatabase
instance to access the database with the given name.- Parameters:
dbName
- must not be null or empty.- Returns:
- never null.
- Throws:
DataAccessException
-
getExceptionTranslator
PersistenceExceptionTranslator getExceptionTranslator()Exposes a sharedMongoExceptionTranslator
.- Returns:
- will never be null.
-
getCodecRegistry
org.bson.codecs.configuration.CodecRegistry getCodecRegistry()Get the underlyingCodecRegistry
used by the reactive MongoDB Java driver.- Specified by:
getCodecRegistry
in interfaceCodecRegistryProvider
- Returns:
- never null.
-
getSession
Mono<com.mongodb.reactivestreams.client.ClientSession> getSession(com.mongodb.ClientSessionOptions options) - Parameters:
options
- must not be null.- Returns:
- never null.
- Since:
- 2.1
-
withSession
Obtain aClientSession
bound instance ofReactiveMongoDatabaseFactory
returningMongoDatabase
instances that are aware and bound to the given session.- Parameters:
session
- must not be null.- Returns:
- never null.
- Since:
- 2.1
-
isTransactionActive
default boolean isTransactionActive()Returns if the givenReactiveMongoDatabaseFactory
is bound to aClientSession
that has anactive transaction
.- Returns:
- true if there's an active transaction, false otherwise.
- Since:
- 2.2
-