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
-
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 thedatabase
with 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 defaultdatabase
form the givenfactory
.static reactor.core.publisher.Mono<Boolean>
isTransactionActive
(ReactiveMongoDatabaseFactory databaseFactory) Check if theReactiveMongoDatabaseFactory
is actually bound to aClientSession
that has an active transaction, or if aTransactionSynchronization
has been registered for theresource
and if the associatedClientSession
has anactive transaction
.
-
Constructor Details
-
ReactiveMongoDatabaseUtils
public ReactiveMongoDatabaseUtils()
-
-
Method Details
-
isTransactionActive
public static reactor.core.publisher.Mono<Boolean> isTransactionActive(ReactiveMongoDatabaseFactory databaseFactory) Check if theReactiveMongoDatabaseFactory
is actually bound to aClientSession
that has an active transaction, or if aTransactionSynchronization
has been registered for theresource
and if the associatedClientSession
has anactive transaction
.- Parameters:
databaseFactory
- the resource to check transactions for. Must not be null.- Returns:
- a
Mono
emitting 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 defaultdatabase
form the givenfactory
usingnative session synchronization
.
Registers aMongoDB specific transaction synchronization
within the subscriberContext
ifsynchronization is active
.- Parameters:
factory
- theReactiveMongoDatabaseFactory
to get theMongoDatabase
from.- Returns:
- the
MongoDatabase
that 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 defaultdatabase
form the givenfactory
.
Registers aMongoDB specific transaction synchronization
within the subscriberContext
ifsynchronization is active
.- Parameters:
factory
- theReactiveMongoDatabaseFactory
to get theMongoDatabase
from.sessionSynchronization
- the synchronization to use. Must not be null.- Returns:
- the
MongoDatabase
that is potentially associated with a transactionalClientSession
.
-
getDatabase
public static reactor.core.publisher.Mono<com.mongodb.reactivestreams.client.MongoDatabase> getDatabase(String dbName, ReactiveMongoDatabaseFactory factory) Obtain thedatabase
with given name form the givenfactory
usingnative session synchronization
.
Registers aMongoDB specific transaction synchronization
within the subscriberContext
ifsynchronization is active
.- Parameters:
dbName
- the name of theMongoDatabase
to get.factory
- theReactiveMongoDatabaseFactory
to get theMongoDatabase
from.- Returns:
- the
MongoDatabase
that 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 thedatabase
with given name form the givenfactory
.
Registers aMongoDB specific transaction synchronization
within the subscriberContext
ifsynchronization is active
.- Parameters:
dbName
- the name of theMongoDatabase
to get.factory
- theReactiveMongoDatabaseFactory
to get theMongoDatabase
from.sessionSynchronization
- the synchronization to use. Must not be null.- Returns:
- the
MongoDatabase
that is potentially associated with a transactionalClientSession
.
-