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 Classes
    Modifier and Type
    Class
    Description
    (package private) static class 
    Emulate the two phase protocol for non XA
    (package private) class 
     
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    (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

    Constructors
    Constructor
    Description
    ConnectionFactoryImpl(org.datanucleus.store.StoreManager storeMgr, String resourceName)
    Constructor.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
     
    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

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Field Details

    • dataSource

      DataSource dataSource
      DataSource from which to get the connections.
    • pool

      Optional 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

      public ConnectionFactoryImpl(org.datanucleus.store.StoreManager storeMgr, String resourceName)
      Constructor.
      Parameters:
      storeMgr - Store Manager
      resourceName - either tx or nontx
  • Method Details

    • close

      public void close()
      Specified by:
      close in interface org.datanucleus.store.connection.ConnectionFactory
      Overrides:
      close in class org.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 Manager
      connDS - Factory data source object
      connJNDI - DataSource JNDI name(s)
      resourceName - Resource name
      requiredPoolingType - Type of connection pool
      connURL - 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