Renamed DBCallback to DbCallback.
This commit is contained in:
@@ -20,8 +20,7 @@ import org.springframework.dao.DataAccessException;
|
|||||||
import com.mongodb.DB;
|
import com.mongodb.DB;
|
||||||
import com.mongodb.MongoException;
|
import com.mongodb.MongoException;
|
||||||
|
|
||||||
public interface DBCallback<T> {
|
public interface DbCallback<T> {
|
||||||
|
|
||||||
T doInDB(DB db) throws MongoException, DataAccessException;
|
T doInDB(DB db) throws MongoException, DataAccessException;
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -62,7 +62,7 @@ public interface MongoOperations {
|
|||||||
void executeCommand(DBObject command);
|
void executeCommand(DBObject command);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Executes a {@link DBCallback} translating any exceptions as necessary.
|
* Executes a {@link DbCallback} translating any exceptions as necessary.
|
||||||
*
|
*
|
||||||
* Allows for returning a result object, that is a domain object or a collection of domain objects.
|
* Allows for returning a result object, that is a domain object or a collection of domain objects.
|
||||||
*
|
*
|
||||||
@@ -71,7 +71,7 @@ public interface MongoOperations {
|
|||||||
*
|
*
|
||||||
* @return a result object returned by the action or <tt>null</tt>
|
* @return a result object returned by the action or <tt>null</tt>
|
||||||
*/
|
*/
|
||||||
<T> T execute(DBCallback<T> action);
|
<T> T execute(DbCallback<T> action);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Executes the given {@link CollectionCallback} on the default collection.
|
* Executes the given {@link CollectionCallback} on the default collection.
|
||||||
@@ -98,7 +98,7 @@ public interface MongoOperations {
|
|||||||
<T> T execute(CollectionCallback<T> action, String collectionName);
|
<T> T execute(CollectionCallback<T> action, String collectionName);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Executes the given {@link DBCallback} within the same connection to the database so as to ensure
|
* Executes the given {@link DbCallback} within the same connection to the database so as to ensure
|
||||||
* consistency in a write heavy environment where you may read the data that you wrote. See the
|
* consistency in a write heavy environment where you may read the data that you wrote. See the
|
||||||
* comments on {@see <a href=http://www.mongodb.org/display/DOCS/Java+Driver+Concurrency>Java Driver Concurrency</a>}
|
* comments on {@see <a href=http://www.mongodb.org/display/DOCS/Java+Driver+Concurrency>Java Driver Concurrency</a>}
|
||||||
*
|
*
|
||||||
@@ -108,7 +108,7 @@ public interface MongoOperations {
|
|||||||
* @param action callback that specified the MongoDB actions to perform on the DB instance
|
* @param action callback that specified the MongoDB actions to perform on the DB instance
|
||||||
* @return a result object returned by the action or <tt>null</tt>
|
* @return a result object returned by the action or <tt>null</tt>
|
||||||
*/
|
*/
|
||||||
<T> T executeInSession(DBCallback<T> action);
|
<T> T executeInSession(DbCallback<T> action);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create an uncapped collection with the provided name.
|
* Create an uncapped collection with the provided name.
|
||||||
|
|||||||
@@ -138,7 +138,7 @@ public class MongoTemplate implements InitializingBean, MongoOperations {
|
|||||||
*/
|
*/
|
||||||
public DBCollection getDefaultCollection() {
|
public DBCollection getDefaultCollection() {
|
||||||
|
|
||||||
return execute(new DBCallback<DBCollection>() {
|
return execute(new DbCallback<DBCollection>() {
|
||||||
public DBCollection doInDB(DB db) throws MongoException, DataAccessException {
|
public DBCollection doInDB(DB db) throws MongoException, DataAccessException {
|
||||||
return db.getCollection(getDefaultCollectionName());
|
return db.getCollection(getDefaultCollectionName());
|
||||||
}
|
}
|
||||||
@@ -157,7 +157,7 @@ public class MongoTemplate implements InitializingBean, MongoOperations {
|
|||||||
*/
|
*/
|
||||||
public void executeCommand(final DBObject command) {
|
public void executeCommand(final DBObject command) {
|
||||||
|
|
||||||
CommandResult result = execute(new DBCallback<CommandResult>() {
|
CommandResult result = execute(new DbCallback<CommandResult>() {
|
||||||
public CommandResult doInDB(DB db) throws MongoException, DataAccessException {
|
public CommandResult doInDB(DB db) throws MongoException, DataAccessException {
|
||||||
return db.command(command);
|
return db.command(command);
|
||||||
}
|
}
|
||||||
@@ -246,9 +246,9 @@ public class MongoTemplate implements InitializingBean, MongoOperations {
|
|||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.springframework.data.document.mongodb.MongoOperations#executeInSession(org.springframework.data.document.mongodb.DBCallback)
|
* @see org.springframework.data.document.mongodb.MongoOperations#executeInSession(org.springframework.data.document.mongodb.DBCallback)
|
||||||
*/
|
*/
|
||||||
public <T> T executeInSession(final DBCallback<T> action) {
|
public <T> T executeInSession(final DbCallback<T> action) {
|
||||||
|
|
||||||
return execute(new DBCallback<T>() {
|
return execute(new DbCallback<T>() {
|
||||||
public T doInDB(DB db) throws MongoException, DataAccessException {
|
public T doInDB(DB db) throws MongoException, DataAccessException {
|
||||||
try {
|
try {
|
||||||
db.requestStart();
|
db.requestStart();
|
||||||
@@ -264,7 +264,7 @@ public class MongoTemplate implements InitializingBean, MongoOperations {
|
|||||||
* @see org.springframework.data.document.mongodb.MongoOperations#createCollection(java.lang.String)
|
* @see org.springframework.data.document.mongodb.MongoOperations#createCollection(java.lang.String)
|
||||||
*/
|
*/
|
||||||
public DBCollection createCollection(final String collectionName) {
|
public DBCollection createCollection(final String collectionName) {
|
||||||
return execute(new DBCallback<DBCollection>() {
|
return execute(new DbCallback<DBCollection>() {
|
||||||
public DBCollection doInDB(DB db) throws MongoException, DataAccessException {
|
public DBCollection doInDB(DB db) throws MongoException, DataAccessException {
|
||||||
return db.createCollection(collectionName, new BasicDBObject());
|
return db.createCollection(collectionName, new BasicDBObject());
|
||||||
}
|
}
|
||||||
@@ -275,7 +275,7 @@ public class MongoTemplate implements InitializingBean, MongoOperations {
|
|||||||
* @see org.springframework.data.document.mongodb.MongoOperations#createCollection(java.lang.String, org.springframework.data.document.mongodb.CollectionOptions)
|
* @see org.springframework.data.document.mongodb.MongoOperations#createCollection(java.lang.String, org.springframework.data.document.mongodb.CollectionOptions)
|
||||||
*/
|
*/
|
||||||
public void createCollection(final String collectionName, final CollectionOptions collectionOptions) {
|
public void createCollection(final String collectionName, final CollectionOptions collectionOptions) {
|
||||||
execute(new DBCallback<Void>() {
|
execute(new DbCallback<Void>() {
|
||||||
public Void doInDB(DB db) throws MongoException, DataAccessException {
|
public Void doInDB(DB db) throws MongoException, DataAccessException {
|
||||||
db.createCollection(collectionName, convertToDbObject(collectionOptions));
|
db.createCollection(collectionName, convertToDbObject(collectionOptions));
|
||||||
return null;
|
return null;
|
||||||
@@ -287,7 +287,7 @@ public class MongoTemplate implements InitializingBean, MongoOperations {
|
|||||||
* @see org.springframework.data.document.mongodb.MongoOperations#getCollection(java.lang.String)
|
* @see org.springframework.data.document.mongodb.MongoOperations#getCollection(java.lang.String)
|
||||||
*/
|
*/
|
||||||
public DBCollection getCollection(final String collectionName) {
|
public DBCollection getCollection(final String collectionName) {
|
||||||
return execute(new DBCallback<DBCollection>() {
|
return execute(new DbCallback<DBCollection>() {
|
||||||
public DBCollection doInDB(DB db) throws MongoException, DataAccessException {
|
public DBCollection doInDB(DB db) throws MongoException, DataAccessException {
|
||||||
return db.getCollection(collectionName);
|
return db.getCollection(collectionName);
|
||||||
}
|
}
|
||||||
@@ -299,7 +299,7 @@ public class MongoTemplate implements InitializingBean, MongoOperations {
|
|||||||
* @see org.springframework.data.document.mongodb.MongoOperations#collectionExists(java.lang.String)
|
* @see org.springframework.data.document.mongodb.MongoOperations#collectionExists(java.lang.String)
|
||||||
*/
|
*/
|
||||||
public boolean collectionExists(final String collectionName) {
|
public boolean collectionExists(final String collectionName) {
|
||||||
return execute(new DBCallback<Boolean>() {
|
return execute(new DbCallback<Boolean>() {
|
||||||
public Boolean doInDB(DB db) throws MongoException, DataAccessException {
|
public Boolean doInDB(DB db) throws MongoException, DataAccessException {
|
||||||
return db.collectionExists(collectionName);
|
return db.collectionExists(collectionName);
|
||||||
}
|
}
|
||||||
@@ -544,7 +544,7 @@ public class MongoTemplate implements InitializingBean, MongoOperations {
|
|||||||
* @see org.springframework.data.document.mongodb.MongoOperations#getCollectionNames()
|
* @see org.springframework.data.document.mongodb.MongoOperations#getCollectionNames()
|
||||||
*/
|
*/
|
||||||
public Set<String> getCollectionNames() {
|
public Set<String> getCollectionNames() {
|
||||||
return execute(new DBCallback<Set<String>>() {
|
return execute(new DbCallback<Set<String>>() {
|
||||||
public Set<String> doInDB(DB db) throws MongoException, DataAccessException {
|
public Set<String> doInDB(DB db) throws MongoException, DataAccessException {
|
||||||
return db.getCollectionNames();
|
return db.getCollectionNames();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user