org.apache.commons.pool
Interface KeyedPoolableObjectFactory

All Known Implementing Classes:
BaseKeyedPoolableObjectFactory

public interface KeyedPoolableObjectFactory

An interface defining life-cycle methods for instances to be served by a KeyedObjectPool.

By contract, when an KeyedObjectPool delegates to a KeyedPoolableObjectFactory,

  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: 1.8 $ $Date: 2004/02/28 12:16:21 $
See Also:
KeyedObjectPool

Method Summary
 void activateObject(Object key, Object obj)
          Reinitialize an instance to be returned by the pool.
 void destroyObject(Object key, Object obj)
          Destroy an instance no longer needed by the pool.
 Object makeObject(Object key)
          Create an instance that can be served by the pool.
 void passivateObject(Object key, Object obj)
          Uninitialize an instance to be returned to the pool.
 boolean validateObject(Object key, Object obj)
          Ensures that the instance is safe to be returned by the pool.
 

Method Detail

makeObject

public Object makeObject(Object key)
                  throws Exception
Create an instance that can be served by the pool.

Parameters:
key - the key used when constructing the object
Returns:
an instance that can be served by the pool.
Exception

destroyObject

public void destroyObject(Object key,
                          Object obj)
                   throws Exception
Destroy an instance no longer needed by the pool.

Parameters:
key - the key used when selecting the instance
obj - the instance to be destroyed
Exception

validateObject

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

Parameters:
key - the key used when selecting the object
obj - the instance to be validated
Returns:
false if this obj is not valid and should be dropped from the pool, true otherwise.

activateObject

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

Parameters:
key - the key used when selecting the object
obj - the instance to be activated
Exception

passivateObject

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

Parameters:
key - the key used when selecting the object
obj - the instance to be passivated
Exception


Copyright © 2001-2004 The Apache Software Foundation. All Rights Reserved.