Java 类com.mongodb.async.client.MongoClient 实例源码
项目:IKB4Stream
文件:DatabaseWriter.java
/**
* DataWriter constructor
*
* @throws IllegalStateException if database configuration is not set
*/
private DatabaseWriter() {
try {
final MongoClient mongoClient = MongoClients.create(PROPERTIES_MANAGER.getProperty("database.host"));
final MongoDatabase mongoDatabase = mongoClient.getDatabase(PROPERTIES_MANAGER.getProperty("database.datasource"));
this.mongoCollection = mongoDatabase.getCollection(PROPERTIES_MANAGER.getProperty("database.collection"));
} catch (IllegalArgumentException e) {
LOGGER.error(e.getMessage());
throw new IllegalStateException(e.getMessage());
}
LOGGER.info("DatabaseWriter has been instantiate");
}
项目:georocket
文件:MongoDBStore.java
/**
* Get or create the MongoDB client
* @return the MongoDB client
*/
private MongoClient getMongoClient() {
if (mongoClient == null) {
mongoClient = MongoClients.create(connectionString);
}
return mongoClient;
}
项目:toolbox
文件:OplogListener.java
public void setMongoClient(MongoClient mongoClient) {
this.mongoClient = mongoClient;
}
项目:kevoree-library
文件:MongoChanFetcher.java
public MongoChanFetcher(Set<Port> localInputs, MongoClient mongoClient, String database, String collection) {
this.localInputs = localInputs;
this.mongoClient = mongoClient;
this.collection = collection;
this.database = database;
}
项目:mongowg
文件:OpLogUtils.java
/**
* Returns the {@code MongoCollection} which contains the oplog.
*
* @param client The {@link MongoClient}
* @return The {@code MongoCollection} which contains the oplog
*/
public static MongoCollection<BsonDocument> getCollection(MongoClient client) {
return client.getDatabase(OPLOG_DATABASE).getCollection(OPLOG_COLLECTION, BsonDocument.class);
}