Spring Data Document

org.springframework.data.mongodb.core
Class MongoDbUtils

java.lang.Object
  extended by org.springframework.data.mongodb.core.MongoDbUtils

public abstract class MongoDbUtils
extends Object

Helper class featuring helper methods for internal MongoDb classes.

Mainly intended for internal use within the framework.

Since:
1.0
Author:
Thomas Risberg, Graeme Rocher, Oliver Gierke

Method Summary
static void closeDB(DB db)
          Perform actual closing of the Mongo DB object, catching and logging any cleanup exceptions thrown.
static DB doGetDB(Mongo mongo, String databaseName, String username, char[] password, boolean allowCreate)
           
static DB getDB(Mongo mongo, String databaseName)
          Obtains a DB connection for the given Mongo instance and database name
static DB getDB(Mongo mongo, String databaseName, String username, char[] password)
          Obtains a DB connection for the given Mongo instance and database name
static boolean isDBTransactional(DB db, Mongo mongo)
          Return whether the given DB instance is transactional, that is, bound to the current thread by Spring's transaction facilities.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getDB

public static DB getDB(Mongo mongo,
                       String databaseName)
Obtains a DB connection for the given Mongo instance and database name

Parameters:
mongo - The Mongo instance
databaseName - The database name
Returns:
The DB connection

getDB

public static DB getDB(Mongo mongo,
                       String databaseName,
                       String username,
                       char[] password)
Obtains a DB connection for the given Mongo instance and database name

Parameters:
mongo - The Mongo instance
databaseName - The database name
username - The username to authenticate with
password - The password to authenticate with
Returns:
The DB connection

doGetDB

public static DB doGetDB(Mongo mongo,
                         String databaseName,
                         String username,
                         char[] password,
                         boolean allowCreate)

isDBTransactional

public static boolean isDBTransactional(DB db,
                                        Mongo mongo)
Return whether the given DB instance is transactional, that is, bound to the current thread by Spring's transaction facilities.

Parameters:
db - the DB to check
mongo - the Mongo instance that the DB was created with (may be null)
Returns:
whether the DB is transactional

closeDB

public static void closeDB(DB db)
Perform actual closing of the Mongo DB object, catching and logging any cleanup exceptions thrown.

Parameters:
db - the DB to close (may be null)

Spring Data Document

Copyright © 2011. All Rights Reserved.