public static synchronized MongoClient getMongoClient() { if (mongoClient == null) { mongoClient = MongoClients.create(getConnectionString()); Runtime.getRuntime().addShutdownHook(new ShutdownHook()); } return mongoClient; }
@Override public MongoClient mongoClient() { return MongoClients.create(String.format("mongodb://%s:%d", mongoProperties.getHost(), mongoProperties.getPort())); }
@Override public MongoClient mongoClient() { return MongoClients.create(); }
@Override public MongoClient reactiveMongoClient() { return MongoClients.create(mongoUri); }
public MongoClient mongoClient() { return MongoClients.create(String.format("mongodb://localhost:%d", mongoProperties.getPort())); }
@Override @Bean @DependsOn("embeddedMongoServer") public MongoClient mongoClient() { return MongoClients.create(String.format("mongodb://localhost:%d", mongoProperties.getPort())); }
@Override public MongoClient reactiveMongoClient() { return MongoClients.create("mongodb://localhost/"+getDatabaseName()); }
@Override public MongoClient mongoClient() { return MongoClients.create(url); }
@Override public MongoClient mongoClient() { // this assumes your MongoDB is running on the default port, i.e. 27017 return MongoClients.create(); }
@Override public MongoClient reactiveMongoClient() { return MongoClients.create(url); }
public MongoClientWrapper(String host, MongoClient client) { this.host = host; this.client = client; }
public MongoClient getClient() { return client; }
@Bean MongoClient mongoClient() { return MongoClients.create(); }
@Bean MongoDatabase mongoDatabase(MongoClient mongoClient) { return mongoClient.getDatabase(database); }
@Bean ReactiveMongoDbFactory reactiveMongoDbFactory(MongoClient mongoClient) { return new ReactiveMongoDbFactory(mongoClient, database); }
/** * Builds a template that will be used to query the Mongo database. * @param mongoClient the mongo client * @return the bean */ @Bean public ReactiveMongoTemplate reactiveMongoTemplate(final MongoClient mongoClient) { return new ReactiveMongoTemplate(mongoClient, "nightclazz"); }
/** * Builds a low level template that will be used to create tailable cursors MongoDB. * * @param mongoClient the mongo client * @return the new bean */ @Bean public ReactiveMongoTemplate reactiveMongoTemplate(final MongoClient mongoClient) { return new ReactiveMongoTemplate(mongoClient, "nightclazz"); }
/** * The internal MongoClientImpl constructor. * * <p>This should not be considered a part of the public API.</p> * @param wrapped the underlying MongoClient */ public MongoClientImpl(final com.mongodb.async.client.MongoClient wrapped) { this.wrapped = notNull("wrapped", wrapped); }