Package org.kiwiproject.mongo
Class MongoClientWrapper
- java.lang.Object
-
- org.kiwiproject.mongo.MongoClientWrapper
-
- All Implemented Interfaces:
Closeable,AutoCloseable
@Beta public class MongoClientWrapper extends Object implements Closeable
A wrapper around aMongoClientthat also providesMongoDatabaseandDBinstances for a specific database, which is specified in the constructor.
-
-
Constructor Summary
Constructors Constructor Description MongoClientWrapper(String mongoUri, String databaseName)Create a new instance with the given Mongo connection URI.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()Closes the wrapperMongoClient.com.mongodb.DBgetDB()Return the (deprecated)DBinstance for clients that have not yet migrated toMongoDatabase.
-
-
-
Constructor Detail
-
MongoClientWrapper
public MongoClientWrapper(String mongoUri, String databaseName)
Create a new instance with the given Mongo connection URI. UsesdatabaseNameto get bothMongoDatabaseandDBinstances, which are available from this instance via their getter methods.- Parameters:
mongoUri- the Mongo connection URIdatabaseName- the database associated with this instance
-
-
Method Detail
-
getDB
public com.mongodb.DB getDB()
Return the (deprecated)DBinstance for clients that have not yet migrated toMongoDatabase.- Returns:
- the DB instance associated with this instance (as specified in the constructor)
-
close
public void close()
Closes the wrapperMongoClient.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable
-
-