org.apache.commons.pool

Interface PoolableObjectFactory

public interface PoolableObjectFactory

An interface defining life-cycle methods for instances to be used in an ObjectPool.

By contract, when an ObjectPool delegates to a PoolableObjectFactory,

  1. makeObject is called whenever a new instance is needed.
  2. activateObject is invoked on every instance before it is returned from the pool.
  3. passivateObject is invoked on every instance when it is returned to the pool.
  4. destroyObject is invoked on every instance when it is being "dropped" from the pool (whether due to the response from validateObject, or for reasons specific to the pool implementation.)
  5. validateObject is invoked in an implementation-specific fashion to determine if an instance is still valid to be returned by the pool. It will only be invoked on an "activated" instance.

Version: $Revision: 155430 $ $Date: 2005-02-26 08:13:28 -0500 (Sat, 26 Feb 2005) $

Author: Rodney Waldhoff

See Also:

Method Summary
voidactivateObject(Object obj)
Reinitialize an instance to be returned by the pool.
voiddestroyObject(Object obj)
Destroys an instance no longer needed by the pool.
ObjectmakeObject()
Creates an instance that can be returned by the pool.
voidpassivateObject(Object obj)
Uninitialize an instance to be returned to the pool.
booleanvalidateObject(Object obj)
Ensures that the instance is safe to be returned by the pool.

Method Detail

activateObject

public void activateObject(Object obj)
Reinitialize an instance to be returned by the pool.

Parameters: obj the instance to be activated

destroyObject

public void destroyObject(Object obj)
Destroys an instance no longer needed by the pool.

Parameters: obj the instance to be destroyed

makeObject

public Object makeObject()
Creates an instance that can be returned by the pool.

Returns: an instance that can be returned by the pool.

passivateObject

public void passivateObject(Object obj)
Uninitialize an instance to be returned to the pool.

Parameters: obj the instance to be passivated

validateObject

public boolean validateObject(Object obj)
Ensures that the instance is safe to be returned by the pool. Returns false if this object should be destroyed.

Parameters: obj the instance to be validated

Returns: false if this obj is not valid and should be dropped from the pool, true otherwise.

Copyright © 2001-2003 Apache Software Foundation. Documenation generated April 29 2009.