Example usage for org.apache.commons.pool2 PooledObject invalidate

List of usage examples for org.apache.commons.pool2 PooledObject invalidate

Introduction

In this page you can find the example usage for org.apache.commons.pool2 PooledObject invalidate.

Prototype

void invalidate();

Source Link

Document

Sets the state to PooledObjectState#INVALID INVALID

Usage

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

/**
 * Destroys a wrapped pooled object.//from  w w w .  j ava2s.  co m
 *
 * @param toDestory The wrapped pooled object to destroy
 *
 * @throws Exception If the factory fails to destroy the pooled object
 *                   cleanly
 */
private void destroy(PooledObject<T> toDestory) throws Exception {
    toDestory.invalidate();
    idleObjects.remove(toDestory);
    allObjects.remove(new IdentityWrapper<T>(toDestory.getObject()));
    try {
        factory.destroyObject(toDestory);
    } finally {
        destroyedCount.incrementAndGet();
        createCount.decrementAndGet();
    }
}