DATADOC-88 added accessors for Mongo and database name to MongoDbFactory
This commit is contained in:
@@ -3,9 +3,14 @@ package org.springframework.data.document.mongodb;
|
||||
import org.springframework.dao.DataAccessException;
|
||||
|
||||
import com.mongodb.DB;
|
||||
import com.mongodb.Mongo;
|
||||
|
||||
public interface MongoDbFactory {
|
||||
|
||||
DB getDb() throws DataAccessException;
|
||||
|
||||
Mongo getMongo();
|
||||
|
||||
String getDatabaseName();
|
||||
|
||||
}
|
||||
|
||||
@@ -100,6 +100,14 @@ public class MongoDbFactoryBean implements MongoDbFactory, FactoryBean<DB>, Init
|
||||
return MongoDbUtils.getDB(mongo, databaseName, username, password == null ? null : password.toCharArray());
|
||||
}
|
||||
|
||||
public Mongo getMongo() {
|
||||
return this.mongo;
|
||||
}
|
||||
|
||||
public String getDatabaseName() {
|
||||
return this.databaseName;
|
||||
}
|
||||
|
||||
public DB getObject() throws Exception {
|
||||
return getDb();
|
||||
}
|
||||
|
||||
@@ -1122,9 +1122,8 @@ public class MongoTemplate implements MongoOperations, ApplicationEventPublisher
|
||||
}
|
||||
|
||||
private void initializeMappingMongoConverter(MappingMongoConverter converter) {
|
||||
DB db = this.mongoDbFactory.getDb();
|
||||
converter.setMongo(db.getMongo());
|
||||
converter.setDefaultDatabase(db.getName());
|
||||
converter.setMongo(this.mongoDbFactory.getMongo());
|
||||
converter.setDefaultDatabase(this.mongoDbFactory.getDatabaseName());
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user