|
Spring Data MongoDB | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.springframework.data.mongodb.core.SimpleMongoDbFactory
public class SimpleMongoDbFactory
Factory to create DB
instances from a Mongo
instance.
Constructor Summary | |
---|---|
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.MongoURI uri)
Creates a new SimpleMongoDbFactory instance from the given MongoURI . |
Method Summary | |
---|---|
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. |
void |
setWriteConcern(com.mongodb.WriteConcern writeConcern)
Configures the WriteConcern to be used on the DB instance being created. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
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.MongoURI uri) throws com.mongodb.MongoException, UnknownHostException
SimpleMongoDbFactory
instance from the given MongoURI
.
uri
- must not be null.
com.mongodb.MongoException
UnknownHostException
MongoURI
Method Detail |
---|
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
MongoDbFactory
DB
instance.
getDb
in interface MongoDbFactory
DataAccessException
public com.mongodb.DB getDb(String dbName) throws DataAccessException
MongoDbFactory
DB
instance to access the database with the given name.
getDb
in interface MongoDbFactory
dbName
- must not be null or empty.
DataAccessException
public void destroy() throws Exception
destroy
in interface DisposableBean
Exception
DisposableBean.destroy()
|
Spring Data MongoDB | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |