Package org.datanucleus.store.rdbms
Class ConnectionFactoryImpl
java.lang.Object
org.datanucleus.store.connection.AbstractConnectionFactory
org.datanucleus.store.rdbms.ConnectionFactoryImpl
- All Implemented Interfaces:
org.datanucleus.store.connection.ConnectionFactory
public class ConnectionFactoryImpl
extends org.datanucleus.store.connection.AbstractConnectionFactory
ConnectionFactory for RDBMS datastores.
Each instance is a factory of transactional or non-transactional connections, obtained through a javax.sql.DataSource.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescription(package private) static class
Emulate the two phase protocol for non XA(package private) class
-
Field Summary
FieldsModifier and TypeFieldDescription(package private) DataSource
DataSource from which to get the connections.(package private) ConnectionPool
Optional locally-managed pool of connections from which we get our connections (when using URL), that backs the dataSource.Fields inherited from class org.datanucleus.store.connection.AbstractConnectionFactory
RESOURCE_NAME_NONTX, RESOURCE_NAME_TX, resourceName, resourceType, storeMgr
-
Constructor Summary
ConstructorsConstructorDescriptionConnectionFactoryImpl
(org.datanucleus.store.StoreManager storeMgr, String resourceName) Constructor. -
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
org.datanucleus.store.connection.ManagedConnection
createManagedConnection
(org.datanucleus.ExecutionContext ec, Map options) Method to create a new ManagedConnection.private DataSource
generateDataSource
(org.datanucleus.store.StoreManager storeMgr, Object connDS, String connJNDI, String resourceName, String requiredPoolingType, String connURL) Method to generate the datasource used by this connection factory.protected void
Method to initialise the DataSource used by this ConnectionFactory.Methods inherited from class org.datanucleus.store.connection.AbstractConnectionFactory
getResourceName, getResourceType, toString
-
Field Details
-
dataSource
DataSource dataSourceDataSource from which to get the connections. -
pool
ConnectionPool poolOptional locally-managed pool of connections from which we get our connections (when using URL), that backs the dataSource. This is stored so that we can close the pool upon close.
-
-
Constructor Details
-
ConnectionFactoryImpl
Constructor.- Parameters:
storeMgr
- Store ManagerresourceName
- either tx or nontx
-
-
Method Details
-
close
public void close()- Specified by:
close
in interfaceorg.datanucleus.store.connection.ConnectionFactory
- Overrides:
close
in classorg.datanucleus.store.connection.AbstractConnectionFactory
-
initialiseDataSource
protected void initialiseDataSource()Method to initialise the DataSource used by this ConnectionFactory. Only invoked when the request for the first connection comes in. -
generateDataSource
private DataSource generateDataSource(org.datanucleus.store.StoreManager storeMgr, Object connDS, String connJNDI, String resourceName, String requiredPoolingType, String connURL) Method to generate the datasource used by this connection factory. Searches initially for a provided DataSource then, if not found, for JNDI DataSource, and finally for the DataSource at a connection URL.- Parameters:
storeMgr
- Store ManagerconnDS
- Factory data source objectconnJNDI
- DataSource JNDI name(s)resourceName
- Resource namerequiredPoolingType
- Type of connection poolconnURL
- URL for connections- Returns:
- The DataSource
-
createManagedConnection
public org.datanucleus.store.connection.ManagedConnection createManagedConnection(org.datanucleus.ExecutionContext ec, Map options) Method to create a new ManagedConnection.- Parameters:
ec
- the object that is bound the connection during its lifecycle (if for a PM/EM operation)options
- Options for creating the connection (optional)- Returns:
- The ManagedConnection
-