public class MongoClientImpl extends Object implements MongoClient
Constructor and Description |
---|
MongoClientImpl(Client client)
Create a new MongoClient.
|
MongoClientImpl(MongoClientConfiguration config)
Create a new MongoClient.
|
Modifier and Type | Method and Description |
---|---|
MongoClient |
asSerializedClient()
Returns a MongoClient instance that shares connections with this
MongoClient instance but serializes all of its requests on a single
connection.
|
void |
close() |
Client |
getClient()
Returns the client value.
|
MongoClientConfiguration |
getConfig()
Returns the configuration being used by the logical MongoDB connection.
|
MongoDatabase |
getDatabase(String name)
Returns the MongoDatabase with the specified name.
|
List<String> |
listDatabaseNames()
Returns a list of database names.
|
List<String> |
listDatabases()
Deprecated.
|
MongoIterator<Document> |
restart(DocumentAssignable cursorDocument)
Restarts an iterator that was previously saved.
|
MongoCursorControl |
restart(LambdaCallback<Document> results,
DocumentAssignable cursorDocument)
Restarts a document stream from a cursor that was previously saved.
|
MongoCursorControl |
restart(StreamCallback<Document> results,
DocumentAssignable cursorDocument)
Restarts a document stream from a cursor that was previously saved.
|
public MongoClientImpl(Client client)
client
- The client interface for interacting with the database.public MongoClientImpl(MongoClientConfiguration config)
config
- The configuration for interacting with MongoDB.public MongoClient asSerializedClient()
While the returned MongoClient 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.
asSerializedClient
in interface MongoClient
public void close()
Overridden to close the underlying client.
close
in interface Closeable
close
in interface AutoCloseable
public Client getClient()
public MongoClientConfiguration getConfig()
Overridden to return the clients configuration.
getConfig
in interface MongoClient
public MongoDatabase getDatabase(String name)
Overridden to create a MongoDatabase
instance with the given
name.
getDatabase
in interface MongoClient
name
- The name of the existing database.MongoDatabase
.MongoClient.getDatabase(String)
public List<String> listDatabaseNames()
Overridden to issue a listDatabases command against the 'admin' database.
listDatabaseNames
in interface MongoClient
MongoClient.listDatabaseNames()
@Deprecated public List<String> listDatabases()
listDatabases
in interface MongoClient
public MongoIterator<Document> restart(DocumentAssignable cursorDocument) throws IllegalArgumentException
restart
in interface MongoClient
cursorDocument
- The document containing the state of the cursor.IllegalArgumentException
- If the document does not contain a valid cursor state.public MongoCursorControl restart(LambdaCallback<Document> results, DocumentAssignable cursorDocument) throws IllegalArgumentException
The sequence of callbacks will be terminated by either calling the
results.accept(...)
method with null
for both parameters or by calling the
method with an error for the first parameter.
Overridden to call restart(StreamCallback, DocumentAssignable)
with an adapter for the LambdaCallback
.
restart
in interface MongoClient
results
- Callback that will be notified of the results of the cursor.cursorDocument
- The document containing the state of the cursor.MongoCursorControl
to control the cursor streaming
documents to the caller. This includes the ability to stop the
cursor and persist its state.IllegalArgumentException
- If the document does not contain a valid cursor state.public MongoCursorControl restart(StreamCallback<Document> results, DocumentAssignable cursorDocument) throws IllegalArgumentException
restart
in interface MongoClient
results
- Callback that will be notified of the results of the cursor.cursorDocument
- The document containing the state of the cursor.MongoCursorControl
to control the cursor streaming
documents to the caller. This includes the ability to stop the
cursor and persist its state.IllegalArgumentException
- If the document does not contain a valid cursor state.Copyright © 2011–2014 Allanbank Consulting, Inc.. All rights reserved.