org.jboss.jca.core.connectionmanager.pool
Class AbstractPool

java.lang.Object
  extended by 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 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.

Version:
$Rev: 111532 $
Author:
Gurkan Erdogdu

Field Summary
protected  CoreLogger log
          The logger
 
Constructor Summary
protected AbstractPool(javax.resource.spi.ManagedConnectionFactory mcf, org.jboss.jca.core.api.connectionmanager.pool.PoolConfiguration pc, boolean noTxSeparatePools)
          Create a new base pool.
 
Method Summary
 void emptyManagedConnectionPool(ManagedConnectionPool pool)
          Remove the matching managed connection pool if the pool is empty
 void flush()
          
 void flush(boolean kill)
          
 ConnectionListener getConnection(Transaction trackByTransaction, Subject subject, javax.resource.spi.ConnectionRequestInfo cri)
          Get a connection
protected  ConnectionListenerFactory getConnectionListenerFactory()
          Get the connection listener factory
protected abstract  Object getKey(Subject subject, javax.resource.spi.ConnectionRequestInfo cri, boolean separateNoTx)
          Retrieve the key for this request.
abstract  CoreLogger getLogger()
          Get the logger
 javax.resource.spi.ManagedConnectionFactory getManagedConnectionFactory()
          Retrieve the managed connection factory for this pool.
protected  ManagedConnectionPool getManagedConnectionPool(Object key, Subject subject, javax.resource.spi.ConnectionRequestInfo cri)
          Determine the correct pool for this request, creates a new one when necessary.
 String getName()
          Gets pool name.
 org.jboss.jca.core.api.connectionmanager.pool.PoolStatistics getStatistics()
          
protected  org.jboss.jca.core.spi.transaction.TransactionIntegration getTransactionIntegration()
          Get any transaction integration associated with the pool.
protected  TransactionManager getTransactionManager()
          Get any transaction manager associated with the pool.
protected  TransactionSynchronizationRegistry getTransactionSynchronizationRegistry()
          Get any transaction synchronization registry associated with the pool.
protected  boolean internalTestConnection(Subject subject)
          Test if a connection can be obtained
 void returnConnection(ConnectionListener cl, boolean kill)
          Return a connection
 void setConnectionListenerFactory(ConnectionListenerFactory clf)
          Set the connection listener factory.
 void setName(String poolName)
          Sets pool name.
 void shutdown()
          Shutdown the pool
abstract  boolean testConnection()
          
 
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)
Create a new base pool.

Parameters:
mcf - the managed connection factory
pc - the pool configuration
noTxSeparatePools - noTxSeparatePool
Method Detail

setName

public void setName(String poolName)
Sets pool name.

Parameters:
poolName - pool name

getName

public String getName()
Gets pool name.

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

getKey

protected abstract Object getKey(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(Object key,
                                                         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 TransactionManager getTransactionManager()
Get any transaction manager associated with the pool.

Returns:
the transaction manager

getTransactionSynchronizationRegistry

protected 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()

Specified by:
flush in interface org.jboss.jca.core.api.connectionmanager.pool.Pool

flush

public void flush(boolean kill)

Specified by:
flush in interface org.jboss.jca.core.api.connectionmanager.pool.Pool

getConnection

public ConnectionListener getConnection(Transaction trackByTransaction,
                                        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

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

getConnectionListenerFactory

protected ConnectionListenerFactory getConnectionListenerFactory()
Get the connection listener factory

Returns:
The value

setConnectionListenerFactory

public void setConnectionListenerFactory(ConnectionListenerFactory clf)
Set the connection listener factory.

Parameters:
clf - the connection event listener factory

shutdown

public void shutdown()
Shutdown the pool


getStatistics

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

Specified by:
getStatistics in interface org.jboss.jca.core.api.connectionmanager.pool.Pool

testConnection

public abstract boolean testConnection()

Specified by:
testConnection in interface org.jboss.jca.core.api.connectionmanager.pool.Pool

internalTestConnection

protected boolean internalTestConnection(Subject subject)
Test if a connection can be obtained

Parameters:
subject - Optional subject
Returns:
True if possible; otherwise false

getLogger

public abstract CoreLogger getLogger()
Get the logger

Returns:
The value


Copyright © 2008 Red Hat Middleware LLC (http://www.jboss.com/)