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.AbstractConnectionFactory
Implementation 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 class
ConnectionFactoryImpl.ManagedConnectionImpl
-
Field Summary
Fields Modifier and Type Field Description static String
MONGODB_AUTHENTICATION_DATABASE
static String
MONGODB_CONNECT_TIMEOUT
static String
MONGODB_CONNECTIONS_PER_HOST
static String
MONGODB_HEARTBEAT_CONNECT_TIMEOUT
static String
MONGODB_HEARTBEAT_FREQUENCY
static String
MONGODB_HEARTBEAT_SOCKET_TIMEOUT
static String
MONGODB_MAX_CONNECTION_IDLE_TIME
static String
MONGODB_MAX_CONNECTION_LIFE_TIME
static String
MONGODB_MAX_WAIT_TIME
static String
MONGODB_MIN_CONNECTIONS_PER_HOST
static String
MONGODB_MIN_HEARTBEAT_FREQUENCY
static String
MONGODB_REPLICA_SET_NAME
static String
MONGODB_SERVER_SELECTION_TIMEOUT
static String
MONGODB_SOCKET_TIMEOUT
static String
MONGODB_SSL_ENABLED
static String
MONGODB_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 void
close()
org.datanucleus.store.connection.ManagedConnection
createManagedConnection(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:
close
in interfaceorg.datanucleus.store.connection.ConnectionFactory
- Overrides:
close
in 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
-
-