public class CachedConnectionStrategy extends AbstractConnectionStrategy
| Modifier and Type | Class and Description |
|---|---|
protected class |
CachedConnectionStrategy.CachedConnectionStrategyThreadLocal<T>
This is moved here to aid testing by exposing a dumbGet() method.
|
| Modifier and Type | Field and Description |
|---|---|
protected Map<ConnectionHandle,Reference<Thread>> |
threadFinalizableRefs
Keep track of connections tied to thread.
|
protected CachedConnectionStrategy.CachedConnectionStrategyThreadLocal<AbstractMap.SimpleEntry<ConnectionHandle,Boolean>> |
tlConnections
Connections are stored here.
|
pool, terminationLock| Constructor and Description |
|---|
CachedConnectionStrategy(BoneCP pool,
ConnectionStrategy fallbackStrategy) |
| Modifier and Type | Method and Description |
|---|---|
void |
cleanupConnection(ConnectionHandle oldHandle,
ConnectionHandle newHandle)
Give a chance to do some cleanups before closing off the connection.
|
protected Connection |
getConnectionInternal()
Actual call that returns a connection
|
ConnectionHandle |
pollConnection()
Obtains a connection using the configured strategy without blocking.
|
protected void |
stealExistingAllocations()
Tries to close off all the unused assigned connections back to the pool.
|
void |
terminateAllConnections()
Destroys all connections using this strategy.
|
protected void |
threadWatch(ConnectionHandle c)
Keep track of this handle tied to which thread so that if the thread is terminated
we can reclaim our connection handle.
|
getConnection, postConnection, preConnectionprotected final Map<ConnectionHandle,Reference<Thread>> threadFinalizableRefs
protected CachedConnectionStrategy.CachedConnectionStrategyThreadLocal<AbstractMap.SimpleEntry<ConnectionHandle,Boolean>> tlConnections
public CachedConnectionStrategy(BoneCP pool, ConnectionStrategy fallbackStrategy)
defaultConnectionStrategy - boneCP - protected void stealExistingAllocations()
protected void threadWatch(ConnectionHandle c)
c - connection handle to track.protected Connection getConnectionInternal() throws SQLException
AbstractConnectionStrategygetConnectionInternal in class AbstractConnectionStrategySQLExceptionpublic ConnectionHandle pollConnection()
ConnectionStrategypollConnection in interface ConnectionStrategypollConnection in class AbstractConnectionStrategypublic void terminateAllConnections()
ConnectionStrategypublic void cleanupConnection(ConnectionHandle oldHandle, ConnectionHandle newHandle)
ConnectionStrategycleanupConnection in interface ConnectionStrategycleanupConnection in class AbstractConnectionStrategyCopyright © 2009-2013 JolBox. All Rights Reserved.