Package com.mongodb.client
Interface MongoClient
-
- All Superinterfaces:
java.lang.AutoCloseable
,java.io.Closeable
@Immutable @Deprecated(since="2021-05-27") public interface MongoClient extends java.io.Closeable
Deprecated.Usage of this API is not supported in AEM as a Cloud Service.A client-side representation of a MongoDB cluster. Instances can represent either a standalone MongoDB instance, a replica set, or a sharded cluster. Instance of this class are responsible for maintaining an up-to-date state of the cluster, and possibly cache resources related to this, including background threads for monitoring, and connection pools.Instances of this class serve as factories for
MongoDatabase
instances.Instances of this class can be created via the
MongoClients
factory.- Since:
- 3.7
- See Also:
MongoClients
-
-
Method Summary
All Methods Instance Methods Abstract Methods Deprecated Methods Modifier and Type Method Description void
close()
Deprecated.Close the client, which will close all underlying cached resources, including, for example, sockets and background monitoring threads.ClusterDescription
getClusterDescription()
Deprecated.Gets the current cluster description.MongoDatabase
getDatabase(java.lang.String databaseName)
Deprecated.Gets aMongoDatabase
instance for the given database name.MongoIterable<java.lang.String>
listDatabaseNames()
Deprecated.Get a list of the database namesMongoIterable<java.lang.String>
listDatabaseNames(ClientSession clientSession)
Deprecated.Get a list of the database namesListDatabasesIterable<Document>
listDatabases()
Deprecated.Gets the list of databasesListDatabasesIterable<Document>
listDatabases(ClientSession clientSession)
Deprecated.Gets the list of databases<TResult> ListDatabasesIterable<TResult>
listDatabases(ClientSession clientSession, java.lang.Class<TResult> resultClass)
Deprecated.Gets the list of databases<TResult> ListDatabasesIterable<TResult>
listDatabases(java.lang.Class<TResult> resultClass)
Deprecated.Gets the list of databasesClientSession
startSession()
Deprecated.Creates a client session with default options.ClientSession
startSession(ClientSessionOptions options)
Deprecated.Creates a client session.ChangeStreamIterable<Document>
watch()
Deprecated.Creates a change stream for this client.ChangeStreamIterable<Document>
watch(ClientSession clientSession)
Deprecated.Creates a change stream for this client.<TResult> ChangeStreamIterable<TResult>
watch(ClientSession clientSession, java.lang.Class<TResult> resultClass)
Deprecated.Creates a change stream for this client.ChangeStreamIterable<Document>
watch(ClientSession clientSession, java.util.List<? extends Bson> pipeline)
Deprecated.Creates a change stream for this client.<TResult> ChangeStreamIterable<TResult>
watch(ClientSession clientSession, java.util.List<? extends Bson> pipeline, java.lang.Class<TResult> resultClass)
Deprecated.Creates a change stream for this client.<TResult> ChangeStreamIterable<TResult>
watch(java.lang.Class<TResult> resultClass)
Deprecated.Creates a change stream for this client.ChangeStreamIterable<Document>
watch(java.util.List<? extends Bson> pipeline)
Deprecated.Creates a change stream for this client.<TResult> ChangeStreamIterable<TResult>
watch(java.util.List<? extends Bson> pipeline, java.lang.Class<TResult> resultClass)
Deprecated.Creates a change stream for this client.
-
-
-
Method Detail
-
getDatabase
MongoDatabase getDatabase(java.lang.String databaseName)
Deprecated.Gets aMongoDatabase
instance for the given database name.- Parameters:
databaseName
- the name of the database to retrieve- Returns:
- a
MongoDatabase
representing the specified database - Throws:
java.lang.IllegalArgumentException
- if databaseName is invalid- See Also:
MongoNamespace.checkDatabaseNameValidity(String)
-
startSession
ClientSession startSession()
Deprecated.Creates a client session with default options.Note: A ClientSession instance can not be used concurrently in multiple operations.
- Returns:
- the client session
-
startSession
ClientSession startSession(ClientSessionOptions options)
Deprecated.Creates a client session.Note: A ClientSession instance can not be used concurrently in multiple operations.
- Parameters:
options
- the options for the client session- Returns:
- the client session
-
close
void close()
Deprecated.Close the client, which will close all underlying cached resources, including, for example, sockets and background monitoring threads.- Specified by:
close
in interfacejava.lang.AutoCloseable
- Specified by:
close
in interfacejava.io.Closeable
-
listDatabaseNames
MongoIterable<java.lang.String> listDatabaseNames()
Deprecated.Get a list of the database names- Returns:
- an iterable containing all the names of all the databases
-
listDatabaseNames
MongoIterable<java.lang.String> listDatabaseNames(ClientSession clientSession)
Deprecated.Get a list of the database names- Parameters:
clientSession
- the client session with which to associate this operation- Returns:
- an iterable containing all the names of all the databases
-
listDatabases
ListDatabasesIterable<Document> listDatabases()
Deprecated.Gets the list of databases- Returns:
- the list databases iterable interface
-
listDatabases
ListDatabasesIterable<Document> listDatabases(ClientSession clientSession)
Deprecated.Gets the list of databases- Parameters:
clientSession
- the client session with which to associate this operation- Returns:
- the list databases iterable interface
-
listDatabases
<TResult> ListDatabasesIterable<TResult> listDatabases(java.lang.Class<TResult> resultClass)
Deprecated.Gets the list of databases- Type Parameters:
TResult
- the type of the class to use instead ofDocument
.- Parameters:
resultClass
- the class to cast the database documents to- Returns:
- the list databases iterable interface
-
listDatabases
<TResult> ListDatabasesIterable<TResult> listDatabases(ClientSession clientSession, java.lang.Class<TResult> resultClass)
Deprecated.Gets the list of databases- Type Parameters:
TResult
- the type of the class to use instead ofDocument
.- Parameters:
clientSession
- the client session with which to associate this operationresultClass
- the class to cast the database documents to- Returns:
- the list databases iterable interface
-
watch
ChangeStreamIterable<Document> watch()
Deprecated.Creates a change stream for this client.- Returns:
- the change stream iterable
- Since:
- 3.8
-
watch
<TResult> ChangeStreamIterable<TResult> watch(java.lang.Class<TResult> resultClass)
Deprecated.Creates a change stream for this client.- Type Parameters:
TResult
- the target document type of the iterable.- Parameters:
resultClass
- the class to decode each document into- Returns:
- the change stream iterable
- Since:
- 3.8
-
watch
ChangeStreamIterable<Document> watch(java.util.List<? extends Bson> pipeline)
Deprecated.Creates a change stream for this client.- Parameters:
pipeline
- the aggregation pipeline to apply to the change stream.- Returns:
- the change stream iterable
- Since:
- 3.8
-
watch
<TResult> ChangeStreamIterable<TResult> watch(java.util.List<? extends Bson> pipeline, java.lang.Class<TResult> resultClass)
Deprecated.Creates a change stream for this client.- Type Parameters:
TResult
- the target document type of the iterable.- Parameters:
pipeline
- the aggregation pipeline to apply to the change streamresultClass
- the class to decode each document into- Returns:
- the change stream iterable
- Since:
- 3.8
-
watch
ChangeStreamIterable<Document> watch(ClientSession clientSession)
Deprecated.Creates a change stream for this client.- Parameters:
clientSession
- the client session with which to associate this operation- Returns:
- the change stream iterable
- Since:
- 3.8
-
watch
<TResult> ChangeStreamIterable<TResult> watch(ClientSession clientSession, java.lang.Class<TResult> resultClass)
Deprecated.Creates a change stream for this client.- Type Parameters:
TResult
- the target document type of the iterable.- Parameters:
clientSession
- the client session with which to associate this operationresultClass
- the class to decode each document into- Returns:
- the change stream iterable
- Since:
- 3.8
-
watch
ChangeStreamIterable<Document> watch(ClientSession clientSession, java.util.List<? extends Bson> pipeline)
Deprecated.Creates a change stream for this client.- Parameters:
clientSession
- the client session with which to associate this operationpipeline
- the aggregation pipeline to apply to the change stream.- Returns:
- the change stream iterable
- Since:
- 3.8
-
watch
<TResult> ChangeStreamIterable<TResult> watch(ClientSession clientSession, java.util.List<? extends Bson> pipeline, java.lang.Class<TResult> resultClass)
Deprecated.Creates a change stream for this client.- Type Parameters:
TResult
- the target document type of the iterable.- Parameters:
clientSession
- the client session with which to associate this operationpipeline
- the aggregation pipeline to apply to the change streamresultClass
- the class to decode each document into- Returns:
- the change stream iterable
- Since:
- 3.8
-
getClusterDescription
ClusterDescription getClusterDescription()
Deprecated.Gets the current cluster description.This method will not block, meaning that it may return a
ClusterDescription
whoseclusterType
is unknown and whoseServerDescription
s are all in the connecting state. If the application requires notifications after the driver has connected to a member of the cluster, it should register aClusterListener
via theClusterSettings
inMongoClientSettings
.- Returns:
- the current cluster description
- Since:
- 3.11
- See Also:
ClusterSettings.Builder.addClusterListener(ClusterListener)
,MongoClientSettings.Builder.applyToClusterSettings(com.mongodb.Block)
-
-