Class SimpleReactiveMongoDatabaseFactory
java.lang.Object
org.springframework.data.mongodb.core.SimpleReactiveMongoDatabaseFactory
- All Implemented Interfaces:
DisposableBean
,CodecRegistryProvider
,ReactiveMongoDatabaseFactory
public class SimpleReactiveMongoDatabaseFactory
extends Object
implements DisposableBean, ReactiveMongoDatabaseFactory
Factory to create
MongoDatabase
instances from a MongoClient
instance.- Since:
- 2.0
- Author:
- Mark Paluch, Christoph Strobl, Mathieu Ouellet
-
Constructor Summary
ConstructorDescriptionSimpleReactiveMongoDatabaseFactory
(com.mongodb.ConnectionString connectionString) Creates a newSimpleReactiveMongoDatabaseFactory
instance from the givenConnectionString
.SimpleReactiveMongoDatabaseFactory
(com.mongodb.reactivestreams.client.MongoClient mongoClient, String databaseName) Creates a newSimpleReactiveMongoDatabaseFactory
instance from the givenMongoClient
. -
Method Summary
Modifier and TypeMethodDescriptionvoid
destroy()
Clean up the Mongo instance if it was created by the factory itself.org.bson.codecs.configuration.CodecRegistry
Get the underlyingCodecRegistry
used by the reactive MongoDB Java driver.Exposes a sharedMongoExceptionTranslator
.reactor.core.publisher.Mono<com.mongodb.reactivestreams.client.MongoDatabase>
Creates a defaultMongoDatabase
instance.reactor.core.publisher.Mono<com.mongodb.reactivestreams.client.MongoDatabase>
getMongoDatabase
(String dbName) Obtain aMongoDatabase
instance to access the database with the given name.reactor.core.publisher.Mono<com.mongodb.reactivestreams.client.ClientSession>
getSession
(com.mongodb.ClientSessionOptions options) Obtain aMono
emitting aClientSession
for givenoptions
.void
setWriteConcern
(com.mongodb.WriteConcern writeConcern) Configures theWriteConcern
to be used on theMongoDatabase
instance being created.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 class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.springframework.data.mongodb.CodecRegistryProvider
getCodecFor, hasCodecFor
Methods inherited from interface org.springframework.data.mongodb.ReactiveMongoDatabaseFactory
isTransactionActive
-
Constructor Details
-
SimpleReactiveMongoDatabaseFactory
public SimpleReactiveMongoDatabaseFactory(com.mongodb.ConnectionString connectionString) Creates a newSimpleReactiveMongoDatabaseFactory
instance from the givenConnectionString
.- Parameters:
connectionString
- must not be null.
-
SimpleReactiveMongoDatabaseFactory
public SimpleReactiveMongoDatabaseFactory(com.mongodb.reactivestreams.client.MongoClient mongoClient, String databaseName) Creates a newSimpleReactiveMongoDatabaseFactory
instance from the givenMongoClient
.- Parameters:
mongoClient
- must not be null.databaseName
- must not be null.- Since:
- 1.7
-
-
Method Details
-
setWriteConcern
public void setWriteConcern(com.mongodb.WriteConcern writeConcern) Configures theWriteConcern
to be used on theMongoDatabase
instance being created.- Parameters:
writeConcern
- the writeConcern to set
-
getMongoDatabase
public reactor.core.publisher.Mono<com.mongodb.reactivestreams.client.MongoDatabase> getMongoDatabase() throws DataAccessExceptionDescription copied from interface:ReactiveMongoDatabaseFactory
Creates a defaultMongoDatabase
instance.- Specified by:
getMongoDatabase
in interfaceReactiveMongoDatabaseFactory
- Returns:
- never null.
- Throws:
DataAccessException
-
getMongoDatabase
public reactor.core.publisher.Mono<com.mongodb.reactivestreams.client.MongoDatabase> getMongoDatabase(String dbName) throws DataAccessException Description copied from interface:ReactiveMongoDatabaseFactory
Obtain aMongoDatabase
instance to access the database with the given name.- Specified by:
getMongoDatabase
in interfaceReactiveMongoDatabaseFactory
- Parameters:
dbName
- must not be null or empty.- Returns:
- never null.
- Throws:
DataAccessException
-
destroy
Clean up the Mongo instance if it was created by the factory itself.- Specified by:
destroy
in interfaceDisposableBean
- Throws:
Exception
- See Also:
-
getExceptionTranslator
Description copied from interface:ReactiveMongoDatabaseFactory
Exposes a sharedMongoExceptionTranslator
.- Specified by:
getExceptionTranslator
in interfaceReactiveMongoDatabaseFactory
- Returns:
- will never be null.
-
getCodecRegistry
public org.bson.codecs.configuration.CodecRegistry getCodecRegistry()Description copied from interface:ReactiveMongoDatabaseFactory
Get the underlyingCodecRegistry
used by the reactive MongoDB Java driver.- Specified by:
getCodecRegistry
in interfaceCodecRegistryProvider
- Specified by:
getCodecRegistry
in interfaceReactiveMongoDatabaseFactory
- Returns:
- never null.
-
getSession
public reactor.core.publisher.Mono<com.mongodb.reactivestreams.client.ClientSession> getSession(com.mongodb.ClientSessionOptions options) Description copied from interface:ReactiveMongoDatabaseFactory
Obtain aMono
emitting aClientSession
for givenoptions
.- Specified by:
getSession
in interfaceReactiveMongoDatabaseFactory
- Parameters:
options
- must not be null.- Returns:
- never null.
-
withSession
public ReactiveMongoDatabaseFactory withSession(com.mongodb.reactivestreams.client.ClientSession session) Description copied from interface:ReactiveMongoDatabaseFactory
Obtain aClientSession
bound instance ofReactiveMongoDatabaseFactory
returningMongoDatabase
instances that are aware and bound to the given session.- Specified by:
withSession
in interfaceReactiveMongoDatabaseFactory
- Parameters:
session
- must not be null.- Returns:
- never null.
-