Package com.mongodb.client
Class MongoClientFactory
java.lang.Object
com.mongodb.client.MongoClientFactory
- All Implemented Interfaces:
ObjectFactory
A JNDI ObjectFactory for
MongoClient
instances.- Since:
- 3.10
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptiongetObjectInstance
(Object obj, Name name, Context nameCtx, Hashtable<?, ?> environment) This implementation will create instances ofMongoClient
based on a connection string conforming to the format specified inConnectionString
.
-
Constructor Details
-
MongoClientFactory
public MongoClientFactory()
-
-
Method Details
-
getObjectInstance
This implementation will create instances ofMongoClient
based on a connection string conforming to the format specified inConnectionString
.The connection string is specified in one of two ways:
- As the
String
value of a property in theenvironment
parameter with a key of"connectionString"
- As the
String
value of aRefAddr
with type"connectionString"
in anobj
parameter of typeReference
environment
parameter takes precedence over specification in theobj
parameter. Thename
andnameCtx
parameters are ignored.If a non-empty connection string is not specified in either of these two ways, a
MongoException
is thrown.- Specified by:
getObjectInstance
in interfaceObjectFactory
- Returns:
- an instance of
MongoClient
based on the specified connection string
- As the
-