org.apache.commons.dbcp
public class: AbandonedObjectPool [javadoc |
source]
java.lang.Object
org.apache.commons.pool.BaseObjectPool
org.apache.commons.pool.impl.GenericObjectPool
org.apache.commons.dbcp.AbandonedObjectPool
All Implemented Interfaces:
ObjectPool
Deprecated! This - will be removed in a future version of DBCP.
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.
- author:
Glenn - L. Nielsen
- version:
$ - Revision: 482015 $ $Date: 2006-12-03 19:22:09 -0700 (Sun, 03 Dec 2006) $
| Fields inherited from org.apache.commons.pool.impl.GenericObjectPool: |
|---|
| WHEN_EXHAUSTED_FAIL, WHEN_EXHAUSTED_BLOCK, WHEN_EXHAUSTED_GROW, DEFAULT_MAX_IDLE, DEFAULT_MIN_IDLE, DEFAULT_MAX_ACTIVE, DEFAULT_WHEN_EXHAUSTED_ACTION, DEFAULT_MAX_WAIT, DEFAULT_TEST_ON_BORROW, DEFAULT_TEST_ON_RETURN, DEFAULT_TEST_WHILE_IDLE, DEFAULT_TIME_BETWEEN_EVICTION_RUNS_MILLIS, DEFAULT_NUM_TESTS_PER_EVICTION_RUN, DEFAULT_MIN_EVICTABLE_IDLE_TIME_MILLIS, DEFAULT_SOFT_MIN_EVICTABLE_IDLE_TIME_MILLIS |
| Constructor: |
public AbandonedObjectPool(PoolableObjectFactory factory,
AbandonedConfig config) {
super(factory);
this.config = config;
System.out.println("AbandonedObjectPool is used (" + this + ")");
System.out.println(" LogAbandoned: " + config.getLogAbandoned());
System.out.println(" RemoveAbandoned: " + config.getRemoveAbandoned());
System.out.println(" RemoveAbandonedTimeout: " + config.getRemoveAbandonedTimeout());
}
Create an ObjectPool which tracks db connections. Parameters:
factory - PoolableObjectFactory used to create this
config - configuration for abandoned db connections
|
| Methods from org.apache.commons.pool.impl.GenericObjectPool: |
|---|
|
addObject, borrowObject, clear, close, evict, getMaxActive, getMaxIdle, getMaxWait, getMinEvictableIdleTimeMillis, getMinIdle, getNumActive, getNumIdle, getNumTestsPerEvictionRun, getSoftMinEvictableIdleTimeMillis, getTestOnBorrow, getTestOnReturn, getTestWhileIdle, getTimeBetweenEvictionRunsMillis, getWhenExhaustedAction, invalidateObject, returnObject, setConfig, setFactory, setMaxActive, setMaxIdle, setMaxWait, setMinEvictableIdleTimeMillis, setMinIdle, setNumTestsPerEvictionRun, setSoftMinEvictableIdleTimeMillis, setTestOnBorrow, setTestOnReturn, setTestWhileIdle, setTimeBetweenEvictionRunsMillis, setWhenExhaustedAction |
| Method from org.apache.commons.dbcp.AbandonedObjectPool Detail: |
public Object borrowObject() throws Exception {
if (config != null
&& config.getRemoveAbandoned()
&& (getNumIdle() < 2)
&& (getNumActive() > getMaxActive() - 3) ) {
removeAbandoned();
}
Object obj = super.borrowObject();
if (obj instanceof AbandonedTrace) {
((AbandonedTrace) obj).setStackTrace();
}
if (obj != null && config != null && config.getRemoveAbandoned()) {
synchronized (trace) {
trace.add(obj);
}
}
return obj;
} Deprecated!Get a db connection from the pool.
If removeAbandoned=true, recovers db connections which
have been idle > removeAbandonedTimeout and
getNumActive() > getMaxActive() - 3 and
getNumIdle() < 2 |
public void invalidateObject(Object obj) throws Exception {
if (config != null && config.getRemoveAbandoned()) {
synchronized (trace) {
boolean foundObject = trace.remove(obj);
if (!foundObject) {
return; // This connection has already been invalidated. Stop now.
}
}
}
super.invalidateObject(obj);
} Deprecated!Invalidates an object from the pool. |
public void returnObject(Object obj) throws Exception {
if (config != null && config.getRemoveAbandoned()) {
synchronized (trace) {
boolean foundObject = trace.remove(obj);
if (!foundObject) {
return; // This connection has already been invalidated. Stop now.
}
}
}
super.returnObject(obj);
} Deprecated!Return a db connection to the pool. |