public class SimpleMongoDbFactory extends Object implements DisposableBean, MongoDbFactory
DB instances from a Mongo instance.| Constructor and Description |
|---|
SimpleMongoDbFactory(com.mongodb.Mongo mongo,
String databaseName)
Create an instance of
SimpleMongoDbFactory given the Mongo instance and database name. |
SimpleMongoDbFactory(com.mongodb.Mongo mongo,
String databaseName,
UserCredentials credentials)
Create an instance of SimpleMongoDbFactory given the Mongo instance, database name, and username/password
|
SimpleMongoDbFactory(com.mongodb.Mongo mongo,
String databaseName,
UserCredentials credentials,
String authenticationDatabaseName)
Create an instance of SimpleMongoDbFactory given the Mongo instance, database name, and username/password
|
SimpleMongoDbFactory(com.mongodb.MongoURI uri)
Creates a new
SimpleMongoDbFactory instance from the given MongoURI. |
| 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. |
public SimpleMongoDbFactory(com.mongodb.Mongo mongo,
String databaseName)
SimpleMongoDbFactory given the Mongo instance and database name.mongo - Mongo instance, must not be null.databaseName - database name, not be null or empty.public SimpleMongoDbFactory(com.mongodb.Mongo mongo,
String databaseName,
UserCredentials credentials)
mongo - Mongo instance, must not be null.databaseName - Database name, must not be null or empty.credentials - username and password.public SimpleMongoDbFactory(com.mongodb.Mongo mongo,
String databaseName,
UserCredentials credentials,
String authenticationDatabaseName)
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 authenticationpublic SimpleMongoDbFactory(com.mongodb.MongoURI uri)
throws com.mongodb.MongoException,
UnknownHostException
SimpleMongoDbFactory instance from the given MongoURI.uri - must not be null.com.mongodb.MongoExceptionUnknownHostExceptionMongoURIpublic 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-2014–2014 Pivotal Software, Inc.. All rights reserved.