@Bean public SimpleMongoDbFactory mongoDbFactory() throws Exception { UserCredentials userCredentials = new UserCredentials(user, password); SimpleMongoDbFactory mongoDbFactory = new SimpleMongoDbFactory(new MongoClient(host, port), dbName, userCredentials); mongoDbFactory.setWriteConcern(WriteConcern.ACKNOWLEDGED); return mongoDbFactory; }
@Bean @Profile("!unittest") MongoDbFactory mongoDbFactory() throws UnknownHostException { SimpleMongoDbFactory mongoDbFactory = new SimpleMongoDbFactory(mongo(), mongoProperties.getDatabase()); mongoDbFactory.setWriteConcern(WriteConcern.ACKNOWLEDGED); return mongoDbFactory; }
public SimpleMongoDbFactory configure(SimpleMongoDbFactory mongoDbFactory, MongoDbFactoryConfig config) { if (config != null && config.getWriteConcern() != null) { WriteConcern writeConcern = WriteConcern.valueOf(config.getWriteConcern()); if (writeConcern != null) { mongoDbFactory.setWriteConcern(writeConcern); } } return mongoDbFactory; } }
public SimpleMongoDbFactory configure(SimpleMongoDbFactory mongoDbFactory, MongoDbFactoryConfig config) { if (config != null && config.getWriteConcern() != null) { WriteConcern writeConcern = WriteConcern.valueOf(config.getWriteConcern()); if (writeConcern != null) { mongoDbFactory.setWriteConcern(writeConcern); } } return mongoDbFactory; } }
public SimpleMongoDbFactory configure(SimpleMongoDbFactory mongoDbFactory, MongoDbFactoryConfig config) { if (config != null && config.getWriteConcern() != null) { WriteConcern writeConcern = WriteConcern.valueOf(config.getWriteConcern()); if (writeConcern != null) { mongoDbFactory.setWriteConcern(writeConcern); } } return mongoDbFactory; } }
public SimpleMongoDbFactory configure(SimpleMongoDbFactory mongoDbFactory, MongoDbFactoryConfig config) { if (config != null && config.getWriteConcern() != null) { WriteConcern writeConcern = WriteConcern.valueOf(config.getWriteConcern()); if (writeConcern != null) { mongoDbFactory.setWriteConcern(writeConcern); } } return mongoDbFactory; }
public MongoDbFactory createService(MongoServiceInfo serviceInfo) { try { SimpleMongoDbFactory mongoDbFactory; if (serviceInfo.getUri() != null) { mongoDbFactory = new SimpleMongoDbFactory(new MongoURI(serviceInfo.getUri())); } else { UserCredentials credentials = new UserCredentials(serviceInfo.getUserName(), serviceInfo.getPassword()); ServerAddress serverAddress = new ServerAddress(serviceInfo.getHost(), serviceInfo.getPort()); MongoOptions mongoOptionsToUse = getMongoOptions(); Mongo mongo; if (mongoOptionsToUse != null) { mongo = new Mongo(serverAddress, mongoOptionsToUse); } else { mongo = new Mongo(serverAddress); } mongoDbFactory = new SimpleMongoDbFactory(mongo, serviceInfo.getDatabase(), credentials); } if (cloudMongoConfiguration != null && cloudMongoConfiguration.getWriteConcern() != null) { WriteConcern writeConcern = WriteConcern.valueOf(cloudMongoConfiguration.getWriteConcern()); if (writeConcern != null) { mongoDbFactory.setWriteConcern(writeConcern); } } return mongoDbFactory; } catch (UnknownHostException e) { throw new CloudServiceException(e); } catch (MongoException e) { throw new CloudServiceException(e); } }