Interface MongoClientFactory
-
- All Known Implementing Classes:
DefaultMongoClientFactory
@ThreadSafe public interface MongoClientFactory
A factory for creating MongoClientsA factory should produce
MongoClients
with the same configuration each timecreate()
is called.The creation of a
MongoClient
is expensive (creating the connection pool and authenticating connections), soMongoClients
are automatically cached, using theMongoClientFactory
as the key.Implementations of the factory can make use of the automatic caching by ensuring the
MongoClientFactory.equals()
returns true if theMongoClientFactory
instances configured with the same relevantMongoConfig
values and if the implementation createsMongoClients
with the same configuration each timecreate()
is called. Note: Only theMongoConfig
values used to create theMongoClient
need be compared in theMongoClientFactory.equals()
method.Note: Implementations must have either a no-args public constructor or a public constructor that takes a single parameter; a
MongoConfig
instance.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description com.mongodb.client.MongoClient
create()
-