Spring Data Document

org.springframework.data.mongodb.core
Class SimpleMongoDbFactory

java.lang.Object
  extended by org.springframework.data.mongodb.core.SimpleMongoDbFactory
All Implemented Interfaces:
DisposableBean, MongoDbFactory

public class SimpleMongoDbFactory
extends Object
implements DisposableBean, MongoDbFactory

Factory to create DB instances from a Mongo instance.

Author:
Mark Pollack, Oliver Gierke

Field Summary
protected  org.apache.commons.logging.Log logger
           
 
Constructor Summary
SimpleMongoDbFactory(Mongo mongo, String databaseName)
          Create an instance of SimpleMongoDbFactory given the Mongo instance and database name.
SimpleMongoDbFactory(Mongo mongo, String databaseName, org.springframework.data.authentication.UserCredentials userCredentials)
          Create an instance of SimpleMongoDbFactory given the Mongo instance, database name, and username/password
 
Method Summary
 void destroy()
          Clean up the Mongo instance.
 DB getDb()
          Creates a default DB instance.
 DB getDb(String dbName)
          Creates a DB instance to access the database with the given name.
 void setWriteConcern(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
 

Field Detail

logger

protected final org.apache.commons.logging.Log logger
Constructor Detail

SimpleMongoDbFactory

public SimpleMongoDbFactory(Mongo mongo,
                            String databaseName)
Create an instance of SimpleMongoDbFactory given the Mongo instance and database name.

Parameters:
mongo - Mongo instance, must not be null.
databaseName - database name, not be null.

SimpleMongoDbFactory

public SimpleMongoDbFactory(Mongo mongo,
                            String databaseName,
                            org.springframework.data.authentication.UserCredentials userCredentials)
Create an instance of SimpleMongoDbFactory given the Mongo instance, database name, and username/password

Parameters:
mongo - Mongo instance, must not be null.
databaseName - Database name, must not be null.
userCredentials - username and password must not be null.
Method Detail

setWriteConcern

public void setWriteConcern(WriteConcern writeConcern)
Configures the WriteConcern to be used on the DB instance being created.

Parameters:
writeConcern - the writeConcern to set

getDb

public DB getDb()
         throws DataAccessException
Description copied from interface: MongoDbFactory
Creates a default DB instance.

Specified by:
getDb in interface MongoDbFactory
Returns:
Throws:
DataAccessException

getDb

public DB getDb(String dbName)
         throws DataAccessException
Description copied from interface: MongoDbFactory
Creates a DB instance to access the database with the given name.

Specified by:
getDb in interface MongoDbFactory
Parameters:
dbName - must not be null or empty.
Returns:
Throws:
DataAccessException

destroy

public void destroy()
             throws Exception
Clean up the Mongo instance.

Specified by:
destroy in interface DisposableBean
Throws:
Exception

Spring Data Document

Copyright © 2011. All Rights Reserved.