public class SimpleMongoDbFactory extends Object implements DisposableBean, MongoDbFactory
DB instances from a Mongo instance.| Constructor and Description |
|---|
SimpleMongoDbFactory(com.mongodb.MongoClient mongoClient,
String databaseName)
Creates a new
SimpleMongoDbFactory instance from the given MongoClient. |
SimpleMongoDbFactory(com.mongodb.MongoClientURI uri)
Creates a new
SimpleMongoDbFactory instance from the given MongoClientURI. |
SimpleMongoDbFactory(com.mongodb.Mongo mongo,
String databaseName)
Deprecated.
since 1.7. Please use
SimpleMongoDbFactory(MongoClient, String). |
SimpleMongoDbFactory(com.mongodb.Mongo mongo,
String databaseName,
UserCredentials credentials)
Deprecated.
since 1.7. The credentials used should be provided by
MongoClient.getCredentialsList(). |
SimpleMongoDbFactory(com.mongodb.Mongo mongo,
String databaseName,
UserCredentials credentials,
String authenticationDatabaseName)
Deprecated.
since 1.7. The credentials used should be provided by
MongoClient.getCredentialsList(). |
SimpleMongoDbFactory(com.mongodb.MongoURI uri)
Deprecated.
since 1.7. Please use
SimpleMongoDbFactory(MongoClientURI) instead. |
| Modifier and Type | Method and Description |
|---|---|
void |
destroy()
Clean up the Mongo instance if it was created by the factory itself.
|
com.mongodb.DB |
getDb()
Creates a default
DB instance. |
com.mongodb.DB |
getDb(String dbName)
Creates a
DB instance to access the database with the given name. |
PersistenceExceptionTranslator |
getExceptionTranslator()
Exposes a shared
MongoExceptionTranslator. |
void |
setWriteConcern(com.mongodb.WriteConcern writeConcern)
Configures the
WriteConcern to be used on the DB instance being created. |
@Deprecated public SimpleMongoDbFactory(com.mongodb.Mongo mongo, String databaseName)
SimpleMongoDbFactory(MongoClient, String).SimpleMongoDbFactory given the Mongo instance and database name.mongo - Mongo instance, must not be null.databaseName - database name, not be null or empty.@Deprecated public SimpleMongoDbFactory(com.mongodb.Mongo mongo, String databaseName, UserCredentials credentials)
MongoClient.getCredentialsList().mongo - Mongo instance, must not be null.databaseName - Database name, must not be null or empty.credentials - username and password.@Deprecated public SimpleMongoDbFactory(com.mongodb.Mongo mongo, String databaseName, UserCredentials credentials, String authenticationDatabaseName)
MongoClient.getCredentialsList().mongo - Mongo instance, must not be null.databaseName - Database name, must not be null or empty.credentials - username and password.authenticationDatabaseName - the database name to use for authentication@Deprecated public SimpleMongoDbFactory(com.mongodb.MongoURI uri) throws com.mongodb.MongoException, UnknownHostException
SimpleMongoDbFactory(MongoClientURI) instead.SimpleMongoDbFactory instance from the given MongoURI.uri - must not be null.com.mongodb.MongoExceptionUnknownHostExceptionMongoURIpublic SimpleMongoDbFactory(com.mongodb.MongoClientURI uri)
throws UnknownHostException
SimpleMongoDbFactory instance from the given MongoClientURI.uri - must not be null.UnknownHostExceptionpublic SimpleMongoDbFactory(com.mongodb.MongoClient mongoClient,
String databaseName)
SimpleMongoDbFactory instance from the given MongoClient.mongoClient - must not be null.databaseName - must not be null.public void setWriteConcern(com.mongodb.WriteConcern writeConcern)
WriteConcern to be used on the DB instance being created.writeConcern - the writeConcern to setpublic com.mongodb.DB getDb()
throws DataAccessException
MongoDbFactoryDB instance.getDb in interface MongoDbFactoryDataAccessExceptionpublic com.mongodb.DB getDb(String dbName) throws DataAccessException
MongoDbFactoryDB instance to access the database with the given name.getDb in interface MongoDbFactorydbName - must not be null or empty.DataAccessExceptionpublic void destroy()
throws Exception
destroy in interface DisposableBeanExceptionDisposableBean.destroy()public PersistenceExceptionTranslator getExceptionTranslator()
MongoDbFactoryMongoExceptionTranslator.getExceptionTranslator in interface MongoDbFactoryCopyright © 2011–2018 Pivotal Software, Inc.. All rights reserved.