use of org.springframework.data.mongodb.core.SimpleMongoDbFactory in project oc-explorer by devgateway.
the class MongoTemplateTestConfig method shadowMongoTemplate.
/**
* Creates a shadow template configuration by adding "-shadow" as postfix of database name.
* This is used to replicate the entire database structure in a shadow/temporary database location
*
* @return
* @throws Exception
*/
@Bean(name = "shadowMongoTemplate")
public MongoTemplate shadowMongoTemplate(MongodProcess mongodProcess) throws Exception {
Net net = mongodProcess.getConfig().net();
properties.setHost(net.getServerAddress().getHostName());
properties.setPort(net.getPort());
properties.setDatabase(originalUri + MongoTemplateConfig.SHADOW_POSTFIX);
properties.setUri(null);
MongoTemplate template = new MongoTemplate(new SimpleMongoDbFactory(properties.createMongoClient(this.options, environment), properties.getDatabase()));
((MappingMongoConverter) template.getConverter()).setCustomConversions(customConversions);
return template;
}
use of org.springframework.data.mongodb.core.SimpleMongoDbFactory in project oc-explorer by devgateway.
the class MongoTemplateTestConfig method mongoTemplate.
@Bean(name = "mongoTemplate")
public MongoTemplate mongoTemplate(MongodProcess mongodProcess) throws Exception {
Net net = mongodProcess.getConfig().net();
properties.setHost(net.getServerAddress().getHostName());
properties.setPort(net.getPort());
properties.setDatabase(originalUri);
properties.setUri(null);
MongoTemplate template = new MongoTemplate(new SimpleMongoDbFactory(properties.createMongoClient(this.options, environment), properties.getDatabase()));
((MappingMongoConverter) template.getConverter()).setCustomConversions(customConversions);
return template;
}
use of org.springframework.data.mongodb.core.SimpleMongoDbFactory in project cas by apereo.
the class MongoDbConnectionFactory method mongoDbFactory.
private MongoDbFactory mongoDbFactory(final Mongo mongo, final BaseMongoDbProperties props) {
final String dbName;
final String authDbName;
if (StringUtils.isNotBlank(props.getClientUri())) {
final MongoClientURI uri = buildMongoClientURI(props.getClientUri(), buildMongoDbClientOptions(props));
authDbName = uri.getCredentials().getSource();
dbName = uri.getDatabase();
LOGGER.debug("Using database [{}] from the connection client URI", dbName);
} else {
authDbName = props.getAuthenticationDatabaseName();
dbName = props.getDatabaseName();
LOGGER.debug("Using database [{}] from individual settings", dbName);
}
if (StringUtils.isBlank(dbName)) {
LOGGER.error("Database name cannot be undefined. It must be specified as part of the client URI connection string if used, or " + "as an individual setting for the MongoDb connection");
}
return new SimpleMongoDbFactory(mongo, dbName, null, authDbName);
}
use of org.springframework.data.mongodb.core.SimpleMongoDbFactory in project commons-dao by reportportal.
the class MongodbConfiguration method mongoDbFactory.
@Bean
@Profile("!unittest")
MongoDbFactory mongoDbFactory() throws UnknownHostException {
SimpleMongoDbFactory mongoDbFactory = new SimpleMongoDbFactory(mongo(), mongoProperties.getDatabase());
mongoDbFactory.setWriteConcern(WriteConcern.ACKNOWLEDGED);
return mongoDbFactory;
}
use of org.springframework.data.mongodb.core.SimpleMongoDbFactory in project ocvn by devgateway.
the class MongoTemplateTestConfig method shadowMongoTemplate.
/**
* Creates a shadow template configuration by adding "-shadow" as postfix of database name.
* This is used to replicate the entire database structure in a shadow/temporary database location
*
* @return
* @throws Exception
*/
@Bean(name = "shadowMongoTemplate")
public MongoTemplate shadowMongoTemplate(MongodProcess mongodProcess) throws Exception {
Net net = mongodProcess.getConfig().net();
properties.setHost(net.getServerAddress().getHostName());
properties.setPort(net.getPort());
properties.setDatabase(originalUri + MongoTemplateConfig.SHADOW_POSTFIX);
properties.setUri(null);
MongoTemplate template = new MongoTemplate(new SimpleMongoDbFactory(properties.createMongoClient(this.options, environment), properties.getDatabase()));
((MappingMongoConverter) template.getConverter()).setCustomConversions(customConversions);
return template;
}
Aggregations