public class MongoImpl extends Object implements Mongo
Constructor and Description |
---|
MongoImpl(Client client)
Create a new MongoClient.
|
MongoImpl(MongoDbConfiguration config)
Create a new MongoClient.
|
Modifier and Type | Method and Description |
---|---|
Mongo |
asSerializedMongo()
Returns a Mongo instance that shares connections with this Mongo instance
but serializes all of its requests on a single connection.
|
void |
close() |
Client |
getClient()
Returns the client value.
|
MongoDbConfiguration |
getConfig()
Returns the configuration being used by the logical MongoDB connection.
|
MongoDatabase |
getDatabase(String name)
Returns the MongoDatabase with the specified name.
|
List<String> |
listDatabases()
Returns a future for the list of database names.
|
public MongoImpl(Client client)
client
- The client interface for interacting with the database.public MongoImpl(MongoDbConfiguration config)
config
- The configuration for interacting with MongoDB.public Mongo asSerializedMongo()
While the returned Mongo instance is thread safe it is intended to be used by a single logical thread to ensure requests issued to the MongoDB server are guaranteed to be processed in the same order they are requested.
Creation of the serial instance is lightweight with minimal object allocation and no server interaction.
Overridden to create a new Mongo instance around a SerialClientImpl.
asSerializedMongo
in interface Mongo
public void close()
Overridden to close the underlying client.
close
in interface Closeable
close
in interface AutoCloseable
public Client getClient()
public MongoDbConfiguration getConfig()
Overridden to return the clients configuration.
public MongoDatabase getDatabase(String name)
Overridden to create the named database.
getDatabase
in interface Mongo
name
- The name of the existing database.MongoDatabase
.Mongo.getDatabase(java.lang.String)
public List<String> listDatabases()
Overridden to issue a listDatabases command against the 'admin' database.
listDatabases
in interface Mongo
Mongo.listDatabases()
Copyright © 2011-2012 Allanbank Consulting, Inc.. All Rights Reserved.