Package org.apache.commons.dbcp
Class AbandonedObjectPool
- java.lang.Object
-
- org.apache.commons.pool.BaseObjectPool<T>
-
- org.apache.commons.pool.impl.GenericObjectPool
-
- org.apache.commons.dbcp.AbandonedObjectPool
-
- All Implemented Interfaces:
org.apache.commons.pool.ObjectPool
public class AbandonedObjectPool extends org.apache.commons.pool.impl.GenericObjectPoolAn 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.
- Version:
- $Revision: 899987 $ $Date: 2010-01-16 11:51:16 -0500 (Sat, 16 Jan 2010) $
- Author:
- Glenn L. Nielsen
-
-
Field Summary
-
Fields inherited from class org.apache.commons.pool.impl.GenericObjectPool
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 Summary
Constructors Constructor Description AbandonedObjectPool(org.apache.commons.pool.PoolableObjectFactory factory, AbandonedConfig config)Create an ObjectPool which tracks db connections.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.ObjectborrowObject()Get a db connection from the pool.voidinvalidateObject(java.lang.Object obj)Invalidates an object from the pool.voidreturnObject(java.lang.Object obj)Return a db connection to the pool.-
Methods inherited from class org.apache.commons.pool.impl.GenericObjectPool
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
-
-
-
-
Constructor Detail
-
AbandonedObjectPool
public AbandonedObjectPool(org.apache.commons.pool.PoolableObjectFactory factory, AbandonedConfig config)Create an ObjectPool which tracks db connections.- Parameters:
factory- PoolableObjectFactory used to create thisconfig- configuration for abandoned db connections
-
-
Method Detail
-
borrowObject
public java.lang.Object borrowObject() throws java.lang.ExceptionGet a db connection from the pool. If removeAbandoned=true, recovers db connections which have been idle > removeAbandonedTimeout and getNumActive() > getMaxActive() - 3 and getNumIdle() < 2- Specified by:
borrowObjectin interfaceorg.apache.commons.pool.ObjectPool- Overrides:
borrowObjectin classorg.apache.commons.pool.impl.GenericObjectPool- Returns:
- Object jdbc Connection
- Throws:
java.lang.Exception- if an exception occurs retrieving a connection from the pool
-
returnObject
public void returnObject(java.lang.Object obj) throws java.lang.ExceptionReturn a db connection to the pool.- Specified by:
returnObjectin interfaceorg.apache.commons.pool.ObjectPool- Overrides:
returnObjectin classorg.apache.commons.pool.impl.GenericObjectPool- Parameters:
obj- db Connection to return- Throws:
java.lang.Exception- if an exception occurs returning the connection to the pool
-
invalidateObject
public void invalidateObject(java.lang.Object obj) throws java.lang.ExceptionInvalidates an object from the pool.- Specified by:
invalidateObjectin interfaceorg.apache.commons.pool.ObjectPool- Overrides:
invalidateObjectin classorg.apache.commons.pool.impl.GenericObjectPool- Parameters:
obj- object to be returned- Throws:
java.lang.Exception- if an exception occurs invalidating the object
-
-