Package org.datanucleus.store.mongodb
Class ConnectionFactoryImpl
- java.lang.Object
-
- org.datanucleus.store.connection.AbstractConnectionFactory
-
- org.datanucleus.store.mongodb.ConnectionFactoryImpl
-
- All Implemented Interfaces:
org.datanucleus.store.connection.ConnectionFactory
public class ConnectionFactoryImpl extends org.datanucleus.store.connection.AbstractConnectionFactoryImplementation of a ConnectionFactory for MongoDB. Accepts a URL of the formmongodb://[username:password@]host1[:port1][,host2[:port2],...[,hostN[:portN]]][/[database.collection][?options]]
Defaults to a DB name of "DataNucleus" if nothing specified. Defaults to a DB name for authentication of "admin" if nothing specified and username supplied. Has a DB object per PM/EM. TODO Allow the option of having DB per PMF/EMF.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description classConnectionFactoryImpl.ManagedConnectionImpl
-
Field Summary
Fields Modifier and Type Field Description static StringMONGODB_AUTHENTICATION_DATABASEstatic StringMONGODB_CONNECT_TIMEOUTstatic StringMONGODB_CONNECTIONS_PER_HOSTstatic StringMONGODB_HEARTBEAT_CONNECT_TIMEOUTstatic StringMONGODB_HEARTBEAT_FREQUENCYstatic StringMONGODB_HEARTBEAT_SOCKET_TIMEOUTstatic StringMONGODB_MAX_CONNECTION_IDLE_TIMEstatic StringMONGODB_MAX_CONNECTION_LIFE_TIMEstatic StringMONGODB_MAX_WAIT_TIMEstatic StringMONGODB_MIN_CONNECTIONS_PER_HOSTstatic StringMONGODB_MIN_HEARTBEAT_FREQUENCYstatic StringMONGODB_REPLICA_SET_NAMEstatic StringMONGODB_SERVER_SELECTION_TIMEOUTstatic StringMONGODB_SOCKET_TIMEOUTstatic StringMONGODB_SSL_ENABLEDstatic StringMONGODB_SSL_INVALID_HOSTNAME_ALLOWED
-
Constructor Summary
Constructors Constructor Description ConnectionFactoryImpl(org.datanucleus.store.StoreManager storeMgr, String resourceType)Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()org.datanucleus.store.connection.ManagedConnectioncreateManagedConnection(org.datanucleus.ExecutionContext ec, Map options)Obtain a connection from the Factory.
-
-
-
Field Detail
-
MONGODB_AUTHENTICATION_DATABASE
public static final String MONGODB_AUTHENTICATION_DATABASE
- See Also:
- Constant Field Values
-
MONGODB_CONNECT_TIMEOUT
public static final String MONGODB_CONNECT_TIMEOUT
- See Also:
- Constant Field Values
-
MONGODB_HEARTBEAT_CONNECT_TIMEOUT
public static final String MONGODB_HEARTBEAT_CONNECT_TIMEOUT
- See Also:
- Constant Field Values
-
MONGODB_HEARTBEAT_FREQUENCY
public static final String MONGODB_HEARTBEAT_FREQUENCY
- See Also:
- Constant Field Values
-
MONGODB_HEARTBEAT_SOCKET_TIMEOUT
public static final String MONGODB_HEARTBEAT_SOCKET_TIMEOUT
- See Also:
- Constant Field Values
-
MONGODB_MAX_CONNECTION_IDLE_TIME
public static final String MONGODB_MAX_CONNECTION_IDLE_TIME
- See Also:
- Constant Field Values
-
MONGODB_MAX_CONNECTION_LIFE_TIME
public static final String MONGODB_MAX_CONNECTION_LIFE_TIME
- See Also:
- Constant Field Values
-
MONGODB_MAX_WAIT_TIME
public static final String MONGODB_MAX_WAIT_TIME
- See Also:
- Constant Field Values
-
MONGODB_MIN_HEARTBEAT_FREQUENCY
public static final String MONGODB_MIN_HEARTBEAT_FREQUENCY
- See Also:
- Constant Field Values
-
MONGODB_MIN_CONNECTIONS_PER_HOST
public static final String MONGODB_MIN_CONNECTIONS_PER_HOST
- See Also:
- Constant Field Values
-
MONGODB_SERVER_SELECTION_TIMEOUT
public static final String MONGODB_SERVER_SELECTION_TIMEOUT
- See Also:
- Constant Field Values
-
MONGODB_SOCKET_TIMEOUT
public static final String MONGODB_SOCKET_TIMEOUT
- See Also:
- Constant Field Values
-
MONGODB_SSL_ENABLED
public static final String MONGODB_SSL_ENABLED
- See Also:
- Constant Field Values
-
MONGODB_SSL_INVALID_HOSTNAME_ALLOWED
public static final String MONGODB_SSL_INVALID_HOSTNAME_ALLOWED
- See Also:
- Constant Field Values
-
MONGODB_CONNECTIONS_PER_HOST
public static final String MONGODB_CONNECTIONS_PER_HOST
- See Also:
- Constant Field Values
-
MONGODB_REPLICA_SET_NAME
public static final String MONGODB_REPLICA_SET_NAME
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
ConnectionFactoryImpl
public ConnectionFactoryImpl(org.datanucleus.store.StoreManager storeMgr, String resourceType)Constructor.- Parameters:
storeMgr- Store ManagerresourceType- Type of resource (tx, nontx)
-
-
Method Detail
-
close
public void close()
- Specified by:
closein interfaceorg.datanucleus.store.connection.ConnectionFactory- Overrides:
closein classorg.datanucleus.store.connection.AbstractConnectionFactory
-
createManagedConnection
public org.datanucleus.store.connection.ManagedConnection createManagedConnection(org.datanucleus.ExecutionContext ec, Map options)Obtain a connection from the Factory. The connection will be enlisted within the transaction associated to the ExecutionContext. Note that MongoDB doesn't have a "transaction" as such, so commit/rollback don't apply.- Parameters:
ec- the pool that is bound the connection during its lifecycle (or null)options- Options for creating the connection- Returns:
- the
ManagedConnection
-
-