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 TypeMethodDescriptionorg.bson.codecs.configuration.CodecRegistryGet the underlyingCodecRegistryused by the reactive MongoDB Java driver.Exposes a sharedMongoExceptionTranslator.reactor.core.publisher.Mono<com.mongodb.reactivestreams.client.MongoDatabase>Creates a defaultMongoDatabaseinstance.reactor.core.publisher.Mono<com.mongodb.reactivestreams.client.MongoDatabase>getMongoDatabase(String dbName) Obtain aMongoDatabaseinstance to access the database with the given name.reactor.core.publisher.Mono<com.mongodb.reactivestreams.client.ClientSession>getSession(com.mongodb.ClientSessionOptions options) Obtain aMonoemitting aClientSessionfor givenoptions.default booleanReturns if the givenReactiveMongoDatabaseFactoryis bound to aClientSessionthat has anactive transaction.withSession(com.mongodb.reactivestreams.client.ClientSession session) Obtain aClientSessionbound instance ofReactiveMongoDatabaseFactoryreturningMongoDatabaseinstances that are aware and bound to the given session.Methods inherited from interface org.springframework.data.mongodb.CodecRegistryProvider
getCodecFor, hasCodecFor
-
Method Details
-
getMongoDatabase
reactor.core.publisher.Mono<com.mongodb.reactivestreams.client.MongoDatabase> getMongoDatabase() throws DataAccessExceptionCreates a defaultMongoDatabaseinstance.- Returns:
- never null.
- Throws:
DataAccessException
-
getMongoDatabase
reactor.core.publisher.Mono<com.mongodb.reactivestreams.client.MongoDatabase> getMongoDatabase(String dbName) throws DataAccessException Obtain aMongoDatabaseinstance 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 underlyingCodecRegistryused by the reactive MongoDB Java driver.- Specified by:
getCodecRegistryin interfaceCodecRegistryProvider- Returns:
- never null.
-
getSession
reactor.core.publisher.Mono<com.mongodb.reactivestreams.client.ClientSession> getSession(com.mongodb.ClientSessionOptions options) Obtain aMonoemitting aClientSessionfor givenoptions.- Parameters:
options- must not be null.- Returns:
- never null.
- Since:
- 2.1
-
withSession
Obtain aClientSessionbound instance ofReactiveMongoDatabaseFactoryreturningMongoDatabaseinstances 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 givenReactiveMongoDatabaseFactoryis bound to aClientSessionthat has anactive transaction.- Returns:
- true if there's an active transaction, false otherwise.
- Since:
- 2.2
-