Class 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.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      (package private) javax.sql.DataSource dataSource
      DataSource from which to get the connections.
      (package private) ConnectionPool pool
      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, java.lang.String resourceName)
      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, java.util.Map options)
      Method to create a new ManagedConnection.
      private javax.sql.DataSource generateDataSource​(org.datanucleus.store.StoreManager storeMgr, java.lang.Object connDS, java.lang.String connJNDI, java.lang.String resourceName, java.lang.String requiredPoolingType, java.lang.String connURL)
      Method to generate the datasource used by this connection factory.
      protected void initialiseDataSource()
      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 Detail

      • dataSource

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

        ConnectionPool 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 Detail

      • ConnectionFactoryImpl

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

      • 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 javax.sql.DataSource generateDataSource​(org.datanucleus.store.StoreManager storeMgr,
                                                        java.lang.Object connDS,
                                                        java.lang.String connJNDI,
                                                        java.lang.String resourceName,
                                                        java.lang.String requiredPoolingType,
                                                        java.lang.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,
                                                                                          java.util.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