Package org.springframework.data.mongodb
Class ReactiveMongoDatabaseUtils
java.lang.Object
org.springframework.data.mongodb.ReactiveMongoDatabaseUtils
Helper class for managing reactive
Note: Intended for internal usage only.
MongoDatabase instances via ReactiveMongoDatabaseFactory. Used for
obtaining session bound resources, such as MongoDatabase and MongoCollection
suitable for transactional usage.
Note: Intended for internal usage only.
- Since:
- 2.2
- Author:
- Mark Paluch, Christoph Strobl, Mathieu Ouellet
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic reactor.core.publisher.Mono<com.mongodb.reactivestreams.client.MongoDatabase>getDatabase(String dbName, ReactiveMongoDatabaseFactory factory) static reactor.core.publisher.Mono<com.mongodb.reactivestreams.client.MongoDatabase>getDatabase(String dbName, ReactiveMongoDatabaseFactory factory, SessionSynchronization sessionSynchronization) Obtain thedatabasewith given name form the givenfactory.static reactor.core.publisher.Mono<com.mongodb.reactivestreams.client.MongoDatabase>getDatabase(ReactiveMongoDatabaseFactory factory) static reactor.core.publisher.Mono<com.mongodb.reactivestreams.client.MongoDatabase>getDatabase(ReactiveMongoDatabaseFactory factory, SessionSynchronization sessionSynchronization) Obtain the defaultdatabaseform the givenfactory.static reactor.core.publisher.Mono<Boolean>isTransactionActive(ReactiveMongoDatabaseFactory databaseFactory) Check if theReactiveMongoDatabaseFactoryis actually bound to aClientSessionthat has an active transaction, or if aTransactionSynchronizationhas been registered for theresourceand if the associatedClientSessionhas anactive transaction.
-
Constructor Details
-
ReactiveMongoDatabaseUtils
public ReactiveMongoDatabaseUtils()
-
-
Method Details
-
isTransactionActive
public static reactor.core.publisher.Mono<Boolean> isTransactionActive(ReactiveMongoDatabaseFactory databaseFactory) Check if theReactiveMongoDatabaseFactoryis actually bound to aClientSessionthat has an active transaction, or if aTransactionSynchronizationhas been registered for theresourceand if the associatedClientSessionhas anactive transaction.- Parameters:
databaseFactory- the resource to check transactions for. Must not be null.- Returns:
- a
Monoemitting true if the factory has an ongoing transaction.
-
getDatabase
public static reactor.core.publisher.Mono<com.mongodb.reactivestreams.client.MongoDatabase> getDatabase(ReactiveMongoDatabaseFactory factory) Obtain the defaultdatabaseform the givenfactoryusingnative session synchronization.
Registers aMongoDB specific transaction synchronizationwithin the subscriberContextifsynchronization is active.- Parameters:
factory- theReactiveMongoDatabaseFactoryto get theMongoDatabasefrom.- Returns:
- the
MongoDatabasethat is potentially associated with a transactionalClientSession.
-
getDatabase
public static reactor.core.publisher.Mono<com.mongodb.reactivestreams.client.MongoDatabase> getDatabase(ReactiveMongoDatabaseFactory factory, SessionSynchronization sessionSynchronization) Obtain the defaultdatabaseform the givenfactory.
Registers aMongoDB specific transaction synchronizationwithin the subscriberContextifsynchronization is active.- Parameters:
factory- theReactiveMongoDatabaseFactoryto get theMongoDatabasefrom.sessionSynchronization- the synchronization to use. Must not be null.- Returns:
- the
MongoDatabasethat is potentially associated with a transactionalClientSession.
-
getDatabase
public static reactor.core.publisher.Mono<com.mongodb.reactivestreams.client.MongoDatabase> getDatabase(String dbName, ReactiveMongoDatabaseFactory factory) Obtain thedatabasewith given name form the givenfactoryusingnative session synchronization.
Registers aMongoDB specific transaction synchronizationwithin the subscriberContextifsynchronization is active.- Parameters:
dbName- the name of theMongoDatabaseto get.factory- theReactiveMongoDatabaseFactoryto get theMongoDatabasefrom.- Returns:
- the
MongoDatabasethat is potentially associated with a transactionalClientSession.
-
getDatabase
public static reactor.core.publisher.Mono<com.mongodb.reactivestreams.client.MongoDatabase> getDatabase(String dbName, ReactiveMongoDatabaseFactory factory, SessionSynchronization sessionSynchronization) Obtain thedatabasewith given name form the givenfactory.
Registers aMongoDB specific transaction synchronizationwithin the subscriberContextifsynchronization is active.- Parameters:
dbName- the name of theMongoDatabaseto get.factory- theReactiveMongoDatabaseFactoryto get theMongoDatabasefrom.sessionSynchronization- the synchronization to use. Must not be null.- Returns:
- the
MongoDatabasethat is potentially associated with a transactionalClientSession.
-