public abstract class AbstractPool extends java.lang.Object implements Pool
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.
Modifier and Type | Field and Description |
---|---|
protected CoreLogger |
log
The logger
|
Modifier | Constructor and Description |
---|---|
protected |
AbstractPool(javax.resource.spi.ManagedConnectionFactory mcf,
PoolConfiguration pc,
boolean noTxSeparatePools,
boolean sharable,
java.lang.String mcp)
Create a new base pool.
|
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(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 PoolConfiguration |
getPoolConfiguration()
Get the pool configuration
|
PoolStatistics |
getStatistics()
Get the statistics
|
protected 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
|
protected final CoreLogger log
protected AbstractPool(javax.resource.spi.ManagedConnectionFactory mcf, PoolConfiguration pc, boolean noTxSeparatePools, boolean sharable, java.lang.String mcp)
mcf
- the managed connection factorypc
- the pool configurationnoTxSeparatePools
- noTxSeparatePoolsharable
- Are the connections sharablemcp
- mcppublic void setName(java.lang.String poolName)
poolName
- pool namepublic java.lang.String getName()
public Semaphore getLock()
public boolean isSharable()
public Capacity getCapacity()
public void setCapacity(Capacity c)
c
- The valuepublic boolean isFIFO()
public boolean isInterleaving()
public void setInterleaving(boolean v)
v
- The valuepublic boolean isIdle()
public boolean isFull()
protected abstract java.lang.Object getKey(javax.security.auth.Subject subject, javax.resource.spi.ConnectionRequestInfo cri, boolean separateNoTx) throws javax.resource.ResourceException
subject
- the subjectcri
- the connection request informationseparateNoTx
- separateNoTxjavax.resource.ResourceException
- for any errorprotected ManagedConnectionPool getManagedConnectionPool(java.lang.Object key, javax.security.auth.Subject subject, javax.resource.spi.ConnectionRequestInfo cri) throws javax.resource.ResourceException
key
- the key to the poolsubject
- the subject of the poolcri
- the connection request infojavax.resource.ResourceException
- for any errorprotected TransactionIntegration getTransactionIntegration()
protected javax.transaction.TransactionManager getTransactionManager()
protected javax.transaction.TransactionSynchronizationRegistry getTransactionSynchronizationRegistry()
public void emptyManagedConnectionPool(ManagedConnectionPool pool)
pool
- The poolpublic void flush()
public void flush(boolean kill)
public void flush(FlushMode mode)
public ConnectionListener getConnection(javax.transaction.Transaction trackByTransaction, javax.security.auth.Subject subject, javax.resource.spi.ConnectionRequestInfo cri) throws javax.resource.ResourceException
trackByTransaction
- for transaction stickinesssubject
- the subject for connectioncri
- the connection request informationjavax.resource.ResourceException
- for any errorpublic ConnectionListener findConnectionListener(javax.resource.spi.ManagedConnection mc)
mc
- The managed connectionpublic ConnectionListener findConnectionListener(javax.resource.spi.ManagedConnection mc, java.lang.Object connection)
mc
- The managed connectionconnection
- The connectionpublic javax.resource.spi.ManagedConnectionFactory getManagedConnectionFactory()
public void returnConnection(ConnectionListener cl, boolean kill) throws javax.resource.ResourceException
cl
- the connection event listener wrapping the connectionkill
- whether to destroy the managed connectionjavax.resource.ResourceException
- for any errorpublic boolean hasConnection(javax.security.auth.Subject subject, javax.resource.spi.ConnectionRequestInfo cri)
subject
- the subject for connectioncri
- the connection request informationtrue
if there is an existing connection enlisted, otherwise false
protected ConnectionManager getConnectionManager()
public void setConnectionManager(ConnectionManager cm)
cm
- the connection managerpublic boolean isShutdown()
public void shutdown()
public void prepareShutdown()
public boolean cancelShutdown()
public PoolStatistics getStatistics()
getStatistics
in interface Pool
public PoolStatisticsImpl getInternalStatistics()
public abstract boolean testConnection()
testConnection
in interface Pool
public abstract boolean testConnection(javax.resource.spi.ConnectionRequestInfo cri, javax.security.auth.Subject subject)
testConnection
in interface Pool
cri
- Optional connection request info objectsubject
- Optional subjectprotected boolean internalTestConnection(javax.resource.spi.ConnectionRequestInfo cri, javax.security.auth.Subject subject)
subject
- Optional subjectcri
- Optional CRIpublic java.lang.String[] dumpQueuedThreads()
dumpQueuedThreads
in interface Pool
protected java.util.concurrent.ConcurrentMap<java.lang.Object,ManagedConnectionPool> getManagedConnectionPools()
protected PoolConfiguration getPoolConfiguration()
protected boolean isPrefill()
public abstract CoreLogger getLogger()
Copyright © 2014 IronJacamar (http://www.ironjacamar.org)