public class MongoDatabaseUtils extends Object
MongoDatabase
instances via MongoDbFactory
. Used for obtaining
session bound
resources, such as MongoDatabase
and
MongoCollection
suitable for transactional usage.
Note: Intended for internal usage only.Constructor and Description |
---|
MongoDatabaseUtils() |
Modifier and Type | Method and Description |
---|---|
static com.mongodb.client.MongoDatabase |
getDatabase(MongoDbFactory factory)
|
static com.mongodb.client.MongoDatabase |
getDatabase(MongoDbFactory factory,
SessionSynchronization sessionSynchronization)
Obtain the default
database form the given factory . |
static com.mongodb.client.MongoDatabase |
getDatabase(String dbName,
MongoDbFactory factory)
|
static com.mongodb.client.MongoDatabase |
getDatabase(String dbName,
MongoDbFactory factory,
SessionSynchronization sessionSynchronization)
Obtain the
database with given name form the given factory . |
static boolean |
isTransactionActive(MongoDbFactory dbFactory)
Check if the
MongoDbFactory is actually bound to a ClientSession that has an active transaction, or
if a TransactionSynchronization has been registered for the resource and if the
associated ClientSession has an active transaction . |
public static com.mongodb.client.MongoDatabase getDatabase(MongoDbFactory factory)
database
form the given factory
using
native session synchronization
.
Registers a MongoDB specific transaction synchronization
within the current
Thread
if synchronization is active
.factory
- the MongoDbFactory
to get the MongoDatabase
from.MongoDatabase
that is potentially associated with a transactional ClientSession
.public static com.mongodb.client.MongoDatabase getDatabase(MongoDbFactory factory, SessionSynchronization sessionSynchronization)
database
form the given factory
.
Registers a MongoDB specific transaction synchronization
within the current
Thread
if synchronization is active
.factory
- the MongoDbFactory
to get the MongoDatabase
from.sessionSynchronization
- the synchronization to use. Must not be null.MongoDatabase
that is potentially associated with a transactional ClientSession
.public static com.mongodb.client.MongoDatabase getDatabase(@Nullable String dbName, MongoDbFactory factory)
database
with given name form the given factory
using
native session synchronization
.
Registers a MongoDB specific transaction synchronization
within the current
Thread
if synchronization is active
.dbName
- the name of the MongoDatabase
to get.factory
- the MongoDbFactory
to get the MongoDatabase
from.MongoDatabase
that is potentially associated with a transactional ClientSession
.public static com.mongodb.client.MongoDatabase getDatabase(@Nullable String dbName, MongoDbFactory factory, SessionSynchronization sessionSynchronization)
database
with given name form the given factory
.
Registers a MongoDB specific transaction synchronization
within the current
Thread
if synchronization is active
.dbName
- the name of the MongoDatabase
to get.factory
- the MongoDbFactory
to get the MongoDatabase
from.sessionSynchronization
- the synchronization to use. Must not be null.MongoDatabase
that is potentially associated with a transactional ClientSession
.public static boolean isTransactionActive(MongoDbFactory dbFactory)
MongoDbFactory
is actually bound to a ClientSession
that has an active transaction, or
if a TransactionSynchronization
has been registered for the resource
and if the
associated ClientSession
has an active transaction
.dbFactory
- the resource to check transactions for. Must not be null.Copyright © 2011–2021 Pivotal Software, Inc.. All rights reserved.