public class AbandonedObjectPool
extends org.apache.commons.pool.impl.GenericObjectPool
An implementation of a Jakarta-Commons ObjectPool which tracks JDBC connections and can recover abandoned db connections. If logAbandoned=true, a stack trace will be printed for any abandoned db connections recovered.
Modifier and Type | Field and Description |
---|---|
private AbandonedConfig |
config
DBCP AbandonedConfig
|
private java.util.List |
trace
A list of connections in use
|
DEFAULT_LIFO, DEFAULT_MAX_ACTIVE, DEFAULT_MAX_IDLE, DEFAULT_MAX_WAIT, DEFAULT_MIN_EVICTABLE_IDLE_TIME_MILLIS, DEFAULT_MIN_IDLE, DEFAULT_NUM_TESTS_PER_EVICTION_RUN, DEFAULT_SOFT_MIN_EVICTABLE_IDLE_TIME_MILLIS, DEFAULT_TEST_ON_BORROW, DEFAULT_TEST_ON_RETURN, DEFAULT_TEST_WHILE_IDLE, DEFAULT_TIME_BETWEEN_EVICTION_RUNS_MILLIS, DEFAULT_WHEN_EXHAUSTED_ACTION, WHEN_EXHAUSTED_BLOCK, WHEN_EXHAUSTED_FAIL, WHEN_EXHAUSTED_GROW
Constructor and Description |
---|
AbandonedObjectPool(org.apache.commons.pool.PoolableObjectFactory factory,
AbandonedConfig config)
Create an ObjectPool which tracks db connections.
|
Modifier and Type | Method and Description |
---|---|
java.lang.Object |
borrowObject()
Get a db connection from the pool.
|
void |
invalidateObject(java.lang.Object obj)
Invalidates an object from the pool.
|
private void |
removeAbandoned()
Recover abandoned db connections which have been idle
greater than the removeAbandonedTimeout.
|
void |
returnObject(java.lang.Object obj)
Return a db connection to the pool.
|
addObject, clear, close, evict, getLifo, getMaxActive, getMaxIdle, getMaxWait, getMinEvictableIdleTimeMillis, getMinIdle, getNumActive, getNumIdle, getNumTestsPerEvictionRun, getSoftMinEvictableIdleTimeMillis, getTestOnBorrow, getTestOnReturn, getTestWhileIdle, getTimeBetweenEvictionRunsMillis, getWhenExhaustedAction, setConfig, setFactory, setLifo, setMaxActive, setMaxIdle, setMaxWait, setMinEvictableIdleTimeMillis, setMinIdle, setNumTestsPerEvictionRun, setSoftMinEvictableIdleTimeMillis, setTestOnBorrow, setTestOnReturn, setTestWhileIdle, setTimeBetweenEvictionRunsMillis, setWhenExhaustedAction, startEvictor
private final AbandonedConfig config
private final java.util.List trace
public AbandonedObjectPool(org.apache.commons.pool.PoolableObjectFactory factory, AbandonedConfig config)
factory
- PoolableObjectFactory used to create thisconfig
- configuration for abandoned db connectionspublic java.lang.Object borrowObject() throws java.lang.Exception
borrowObject
in interface org.apache.commons.pool.ObjectPool
borrowObject
in class org.apache.commons.pool.impl.GenericObjectPool
java.lang.Exception
- if an exception occurs retrieving a
connection from the poolpublic void returnObject(java.lang.Object obj) throws java.lang.Exception
returnObject
in interface org.apache.commons.pool.ObjectPool
returnObject
in class org.apache.commons.pool.impl.GenericObjectPool
obj
- db Connection to returnjava.lang.Exception
- if an exception occurs returning the connection
to the poolpublic void invalidateObject(java.lang.Object obj) throws java.lang.Exception
invalidateObject
in interface org.apache.commons.pool.ObjectPool
invalidateObject
in class org.apache.commons.pool.impl.GenericObjectPool
obj
- object to be returnedjava.lang.Exception
- if an exception occurs invalidating the objectprivate void removeAbandoned()