org.jboss.jca.core.connectionmanager.pool

## Class AbstractPool

- java.lang.Object
- - org.jboss.jca.core.connectionmanager.pool.AbstractPool

- All Implemented Interfaces:
    org.jboss.jca.core.api.connectionmanager.pool.Pool
  Direct Known Subclasses:
    AbstractPrefillPool, PoolByCri, PoolBySubjectAndCri, ReauthPool

      public abstract class AbstractPool
      extends java.lang.Object
      implements Pool

  Abstract pool implementation.

  It can contains sub-pools according to the semantic of the pool. Concrete implementatins override `getKey(Subject, ConnectionRequestInfo, boolean)` method to create map key object.

  Author:
    Gurkan Erdogdu, Jesper Pedersen

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected CoreLogger` | `log` The logger

  - ### Constructor Summary

    Constructors
    Modifier | Constructor and Description
    --- | ---
    `protected` | `AbstractPool(javax.resource.spi.ManagedConnectionFactory mcf, org.jboss.jca.core.api.connectionmanager.pool.PoolConfiguration pc, boolean noTxSeparatePools, boolean sharable, java.lang.String mcp)` Create a new base pool.

  - ### Method Summary

    All Methods Instance Methods Abstract Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `boolean` | `cancelShutdown()` Cancel shutdown
    `java.lang.String[]` | `dumpQueuedThreads()` Dump the queued threads
    `void` | `emptyManagedConnectionPool(ManagedConnectionPool pool)` Remove the matching managed connection pool if the pool is empty
    `ConnectionListener` | `findConnectionListener(javax.resource.spi.ManagedConnection mc)` Find a connection listener
    `ConnectionListener` | `findConnectionListener(javax.resource.spi.ManagedConnection mc, java.lang.Object connection)` Find a connection listener
    `void` | `flush()` Flush idle connections from the pool
    `void` | `flush(boolean kill)` Flush the pool
    `void` | `flush(org.jboss.jca.core.api.connectionmanager.pool.FlushMode mode)` Flush the pool
    `Capacity` | `getCapacity()` Get the capacity policy
    `ConnectionListener` | `getConnection(javax.transaction.Transaction trackByTransaction, javax.security.auth.Subject subject, javax.resource.spi.ConnectionRequestInfo cri)` Get a connection
    `protected ConnectionManager` | `getConnectionManager()` Get the connection manager
    `PoolStatisticsImpl` | `getInternalStatistics()` Get internal statistics
    `protected abstract java.lang.Object` | `getKey(javax.security.auth.Subject subject, javax.resource.spi.ConnectionRequestInfo cri, boolean separateNoTx)` Retrieve the key for this request.
    `Semaphore` | `getLock()` Get the lock
    `abstract CoreLogger` | `getLogger()` Get the logger
    `javax.resource.spi.ManagedConnectionFactory` | `getManagedConnectionFactory()` Retrieve the managed connection factory for this pool.
    `protected ManagedConnectionPool` | `getManagedConnectionPool(java.lang.Object key, javax.security.auth.Subject subject, javax.resource.spi.ConnectionRequestInfo cri)` Determine the correct pool for this request, creates a new one when necessary.
    `protected java.util.concurrent.ConcurrentMap<java.lang.Object,ManagedConnectionPool>` | `getManagedConnectionPools()` Get the managed connection pools.
    `java.lang.String` | `getName()` Gets pool name.
    `protected org.jboss.jca.core.api.connectionmanager.pool.PoolConfiguration` | `getPoolConfiguration()` Get the pool configuration
    `org.jboss.jca.core.api.connectionmanager.pool.PoolStatistics` | `getStatistics()` Get the statistics
    `protected org.jboss.jca.core.spi.transaction.TransactionIntegration` | `getTransactionIntegration()` Get any transaction integration associated with the pool.
    `protected javax.transaction.TransactionManager` | `getTransactionManager()` Get any transaction manager associated with the pool.
    `protected javax.transaction.TransactionSynchronizationRegistry` | `getTransactionSynchronizationRegistry()` Get any transaction synchronization registry associated with the pool.
    `boolean` | `hasConnection(javax.security.auth.Subject subject, javax.resource.spi.ConnectionRequestInfo cri)` Has an existing connection
    `protected boolean` | `internalTestConnection(javax.resource.spi.ConnectionRequestInfo cri, javax.security.auth.Subject subject)` Test if a connection can be obtained
    `boolean` | `isFIFO()` Is the pool a FIFO or FILO pool
    `boolean` | `isFull()` Is the pool full
    `boolean` | `isIdle()` Is the pool idle
    `boolean` | `isInterleaving()` Get the interleaving flag
    `protected boolean` | `isPrefill()` Is prefill
    `boolean` | `isSharable()` Is sharable
    `boolean` | `isShutdown()` Is shutdown
    `void` | `prepareShutdown()` Prepare Shutdown
    `void` | `returnConnection(ConnectionListener cl, boolean kill)` Return a connection
    `void` | `setCapacity(Capacity c)` Set the capacity policy
    `void` | `setConnectionManager(ConnectionManager cm)` Set the connection manager
    `void` | `setInterleaving(boolean v)` Set the interleaving flag
    `void` | `setName(java.lang.String poolName)` Sets pool name.
    `void` | `shutdown()` Shutdown the pool
    `abstract boolean` | `testConnection()` Test if a connection can be obtained
    `abstract boolean` | `testConnection(javax.resource.spi.ConnectionRequestInfo cri, javax.security.auth.Subject subject)` Test if a connection can be obtained

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### log

          protected final CoreLogger log

      The logger

  - ### Constructor Detail

    - #### AbstractPool

          protected AbstractPool(javax.resource.spi.ManagedConnectionFactory mcf,
                                 org.jboss.jca.core.api.connectionmanager.pool.PoolConfiguration pc,
                                 boolean noTxSeparatePools,
                                 boolean sharable,
                                 java.lang.String mcp)

      Create a new base pool.
      Parameters:
        `mcf` - the managed connection factory
        `pc` - the pool configuration
        `noTxSeparatePools` - noTxSeparatePool
        `sharable` - Are the connections sharable
        `mcp` - mcp

  - ### Method Detail

    - #### setName

          public void setName(java.lang.String poolName)

      Sets pool name.
      Parameters:
        `poolName` - pool name

    - #### getName

          public java.lang.String getName()

      Gets pool name.
      Specified by:
        `getName` in interface `org.jboss.jca.core.api.connectionmanager.pool.Pool`
      Returns:
        pool name

    - #### getLock

          public Semaphore getLock()

      Get the lock
      Returns:
        The value

    - #### isSharable

          public boolean isSharable()

      Is sharable
      Returns:
        The value

    - #### getCapacity

          public Capacity getCapacity()

      Get the capacity policy
      Returns:
        The value

    - #### setCapacity

          public void setCapacity(Capacity c)

      Set the capacity policy
      Parameters:
        `c` - The value

    - #### isFIFO

          public boolean isFIFO()

      Is the pool a FIFO or FILO pool
      Returns:
        True if FIFO

    - #### isInterleaving

          public boolean isInterleaving()

      Get the interleaving flag
      Returns:
        The value

    - #### setInterleaving

          public void setInterleaving(boolean v)

      Set the interleaving flag
      Parameters:
        `v` - The value

    - #### isIdle

          public boolean isIdle()

      Is the pool idle
      Returns:
        True if idle, otherwise false

    - #### isFull

          public boolean isFull()

      Is the pool full
      Returns:
        True if full, otherwise false

    - #### getKey

          protected abstract java.lang.Object getKey(javax.security.auth.Subject subject,
                                                     javax.resource.spi.ConnectionRequestInfo cri,
                                                     boolean separateNoTx)
                                              throws javax.resource.ResourceException

      Retrieve the key for this request.
      Parameters:
        `subject` - the subject
        `cri` - the connection request information
        `separateNoTx` - separateNoTx
      Returns:
        the key
      Throws:
        `javax.resource.ResourceException` - for any error

    - #### getManagedConnectionPool

          protected ManagedConnectionPool getManagedConnectionPool(java.lang.Object key,
                                                                   javax.security.auth.Subject subject,
                                                                   javax.resource.spi.ConnectionRequestInfo cri)
                                                            throws javax.resource.ResourceException

      Determine the correct pool for this request, creates a new one when necessary.
      Parameters:
        `key` - the key to the pool
        `subject` - the subject of the pool
        `cri` - the connection request info
      Returns:
        the subpool context
      Throws:
        `javax.resource.ResourceException` - for any error

    - #### getTransactionIntegration

          protected org.jboss.jca.core.spi.transaction.TransactionIntegration getTransactionIntegration()

      Get any transaction integration associated with the pool.
      Returns:
        the transaction integration

    - #### getTransactionManager

          protected javax.transaction.TransactionManager getTransactionManager()

      Get any transaction manager associated with the pool.
      Returns:
        the transaction manager

    - #### getTransactionSynchronizationRegistry

          protected javax.transaction.TransactionSynchronizationRegistry getTransactionSynchronizationRegistry()

      Get any transaction synchronization registry associated with the pool.
      Returns:
        The value

    - #### emptyManagedConnectionPool

          public void emptyManagedConnectionPool(ManagedConnectionPool pool)

      Remove the matching managed connection pool if the pool is empty
      Parameters:
        `pool` - The pool

    - #### flush

          public void flush()

      Flush idle connections from the pool
      Specified by:
        `flush` in interface `org.jboss.jca.core.api.connectionmanager.pool.Pool`

    - #### flush

          public void flush(boolean kill)

      Flush the pool
      Specified by:
        `flush` in interface `org.jboss.jca.core.api.connectionmanager.pool.Pool`
      Parameters:
        `kill` - Kill all connections

    - #### flush

          public void flush(org.jboss.jca.core.api.connectionmanager.pool.FlushMode mode)

      Flush the pool
      Specified by:
        `flush` in interface `org.jboss.jca.core.api.connectionmanager.pool.Pool`
      Parameters:
        `mode` - The flush mode

    - #### getConnection

          public ConnectionListener getConnection(javax.transaction.Transaction trackByTransaction,
                                                  javax.security.auth.Subject subject,
                                                  javax.resource.spi.ConnectionRequestInfo cri)
                                           throws javax.resource.ResourceException

      Get a connection
      Parameters:
        `trackByTransaction` - for transaction stickiness
        `subject` - the subject for connection
        `cri` - the connection request information
      Returns:
        a connection event listener wrapping the connection
      Throws:
        `javax.resource.ResourceException` - for any error

    - #### findConnectionListener

          public ConnectionListener findConnectionListener(javax.resource.spi.ManagedConnection mc)

      Find a connection listener
      Parameters:
        `mc` - The managed connection
      Returns:
        The connection listener

    - #### findConnectionListener

          public ConnectionListener findConnectionListener(javax.resource.spi.ManagedConnection mc,
                                                           java.lang.Object connection)

      Find a connection listener
      Parameters:
        `mc` - The managed connection
        `connection` - The connection
      Returns:
        The connection listener

    - #### getManagedConnectionFactory

          public javax.resource.spi.ManagedConnectionFactory getManagedConnectionFactory()

      Retrieve the managed connection factory for this pool.
      Returns:
        the managed connection factory

    - #### returnConnection

          public void returnConnection(ConnectionListener cl,
                                       boolean kill)
                                throws javax.resource.ResourceException

      Return a connection
      Parameters:
        `cl` - the connection event listener wrapping the connection
        `kill` - whether to destroy the managed connection
      Throws:
        `javax.resource.ResourceException` - for any error

    - #### hasConnection

          public boolean hasConnection(javax.security.auth.Subject subject,
                                       javax.resource.spi.ConnectionRequestInfo cri)

      Has an existing connection
      Parameters:
        `subject` - the subject for connection
        `cri` - the connection request information
      Returns:
        `true` if there is an existing connection enlisted, otherwise `false`

    - #### getConnectionManager

          protected ConnectionManager getConnectionManager()

      Get the connection manager
      Returns:
        The value

    - #### setConnectionManager

          public void setConnectionManager(ConnectionManager cm)

      Set the connection manager
      Parameters:
        `cm` - the connection manager

    - #### isShutdown

          public boolean isShutdown()

      Is shutdown
      Returns:
        The value

    - #### shutdown

          public void shutdown()

      Shutdown the pool

    - #### prepareShutdown

          public void prepareShutdown()

      Prepare Shutdown

    - #### cancelShutdown

          public boolean cancelShutdown()

      Cancel shutdown
      Returns:
        True if the shutdown was canceled; false otherwise

    - #### getStatistics

          public org.jboss.jca.core.api.connectionmanager.pool.PoolStatistics getStatistics()

      Get the statistics
      Specified by:
        `getStatistics` in interface `org.jboss.jca.core.api.connectionmanager.pool.Pool`
      Returns:
        The value

    - #### getInternalStatistics

          public PoolStatisticsImpl getInternalStatistics()

      Get internal statistics
      Returns:
        The value

    - #### testConnection

          public abstract boolean testConnection()

      Test if a connection can be obtained
      Specified by:
        `testConnection` in interface `org.jboss.jca.core.api.connectionmanager.pool.Pool`
      Returns:
        True if it was possible to get a connection; otherwise false

    - #### testConnection

          public abstract boolean testConnection(javax.resource.spi.ConnectionRequestInfo cri,
                                                 javax.security.auth.Subject subject)

      Test if a connection can be obtained
      Specified by:
        `testConnection` in interface `org.jboss.jca.core.api.connectionmanager.pool.Pool`
      Parameters:
        `cri` - Optional connection request info object
        `subject` - Optional subject
      Returns:
        True if it was possible to get a connection; otherwise false

    - #### internalTestConnection

          protected boolean internalTestConnection(javax.resource.spi.ConnectionRequestInfo cri,
                                                   javax.security.auth.Subject subject)

      Test if a connection can be obtained
      Parameters:
        `subject` - Optional subject
        `cri` - Optional CRI
      Returns:
        True if possible; otherwise false

    - #### dumpQueuedThreads

          public java.lang.String[] dumpQueuedThreads()

      Dump the queued threads
      Specified by:
        `dumpQueuedThreads` in interface `org.jboss.jca.core.api.connectionmanager.pool.Pool`
      Returns:
        The strack traces of the queued thread, or empty if none

    - #### getManagedConnectionPools

          protected java.util.concurrent.ConcurrentMap<java.lang.Object,ManagedConnectionPool> getManagedConnectionPools()

      Get the managed connection pools.
      Returns:
        The managed connection pools

    - #### getPoolConfiguration

          protected org.jboss.jca.core.api.connectionmanager.pool.PoolConfiguration getPoolConfiguration()

      Get the pool configuration
      Returns:
        The value

    - #### isPrefill

          protected boolean isPrefill()

      Is prefill
      Returns:
        The value

    - #### getLogger

          public abstract CoreLogger getLogger()

      Get the logger
      Returns:
        The value

Copyright © 2014 IronJacamar (http://www.ironjacamar.org)