Example usage for org.apache.commons.pool2 PooledObjectState INVALID

List of usage examples for org.apache.commons.pool2 PooledObjectState INVALID

Introduction

In this page you can find the example usage for org.apache.commons.pool2 PooledObjectState INVALID.

Prototype

PooledObjectState INVALID

To view the source code for org.apache.commons.pool2 PooledObjectState INVALID.

Click Source Link

Document

Failed maintenance (e.g.

Usage

From source file:JDBCPool.dbcp.demo.sourcecode.GenericObjectPool.java

/**
 * {@inheritDoc}/*from w  w w  .  j a v  a 2s.  com*/
 * <p>
 * Activation of this method decrements the active count and attempts to
 * destroy the instance.
 *
 * @throws Exception             if an exception occurs destroying the
 *                               object
 * @throws IllegalStateException if obj does not belong to this pool
 */
@Override
public void invalidateObject(T obj) throws Exception {
    PooledObject<T> p = allObjects.get(new IdentityWrapper<T>(obj));
    if (p == null) {
        if (isAbandonedConfig()) {
            return;
        } else {
            throw new IllegalStateException("Invalidated object not currently part of this pool");
        }
    }
    synchronized (p) {
        if (p.getState() != PooledObjectState.INVALID) {
            destroy(p);
        }
    }
    ensureIdle(1, false);
}