use of com.mongodb.MongoClient in project sling by apache.
the class MongoDBNoSqlResourceProviderFactory method activate.
@Activate
private void activate(ComponentContext componentContext, Map<String, Object> config) {
String connectionString = PropertiesUtil.toString(config.get(CONNECTION_STRING_PROPERTY), CONNECTION_STRING_DEFAULT);
String database = PropertiesUtil.toString(config.get(DATABASE_PROPERTY), DATABASE_DEFAULT);
String collection = PropertiesUtil.toString(config.get(COLLECTION_PROPERTY), COLLECTION_DEFAULT);
mongoClient = new MongoClient(connectionString);
NoSqlAdapter mongodbAdapter = new MongoDBNoSqlAdapter(mongoClient, database, collection);
// enable call logging and metrics for {@link MongoDBNoSqlAdapter}
noSqlAdapter = new MetricsNoSqlAdapterWrapper(mongodbAdapter, LoggerFactory.getLogger(MongoDBNoSqlAdapter.class));
}
use of com.mongodb.MongoClient in project GeoGig by boundlessgeo.
the class MongoGraphDatabaseTest method createDatabase.
@Override
protected MongoGraphDatabase createDatabase(Platform platform) throws Exception {
final IniMongoProperties properties = new IniMongoProperties();
final String uri = properties.get("mongodb.uri", String.class).or("mongodb://localhost:27017/");
final String database = properties.get("mongodb.database", String.class).or("geogig");
MongoClient client = new MongoClient(new MongoClientURI(uri));
DB db = client.getDB(database);
db.dropDatabase();
MongoConnectionManager manager = new MongoConnectionManager();
ConfigDatabase config = new TestConfigDatabase(platform);
MongoGraphDatabase mongoGraphDatabase = new MongoGraphDatabase(manager, config);
return mongoGraphDatabase;
}
use of com.mongodb.MongoClient in project java-design-patterns by iluwatar.
the class MongoTicketRepository method connect.
/**
* Connect to database with given parameters
*/
public void connect(String dbName, String ticketsCollectionName, String countersCollectionName) {
if (mongoClient != null) {
mongoClient.close();
}
mongoClient = new MongoClient(System.getProperty("mongo-host"), Integer.parseInt(System.getProperty("mongo-port")));
database = mongoClient.getDatabase(dbName);
ticketsCollection = database.getCollection(ticketsCollectionName);
countersCollection = database.getCollection(countersCollectionName);
if (countersCollection.count() <= 0) {
initCounters();
}
}
use of com.mongodb.MongoClient in project java-design-patterns by iluwatar.
the class MongoEventLog method connect.
/**
* Connect to database with given parameters
*/
public void connect(String dbName, String eventsCollectionName) {
if (mongoClient != null) {
mongoClient.close();
}
mongoClient = new MongoClient(System.getProperty("mongo-host"), Integer.parseInt(System.getProperty("mongo-port")));
database = mongoClient.getDatabase(dbName);
eventsCollection = database.getCollection(eventsCollectionName);
}
use of com.mongodb.MongoClient in project java-design-patterns by iluwatar.
the class MongoBankTest method init.
@BeforeEach
public void init() {
MongoConnectionPropertiesLoader.load();
MongoClient mongoClient = new MongoClient(System.getProperty("mongo-host"), Integer.parseInt(System.getProperty("mongo-port")));
mongoClient.dropDatabase(TEST_DB);
mongoClient.close();
mongoBank = new MongoBank(TEST_DB, TEST_ACCOUNTS_COLLECTION);
}
Aggregations