com.boylesoftware.cb2.util.pool
Interface PooledObjectFactory

All Known Implementing Classes:
PooledObjectFactoryAdapter

public interface PooledObjectFactory

Factories implementing this interface are used by object pool implementations for instantiating the objects.

Rarely you need to implement this interface directly, usually you extend PooledObjectFactoryAdapter class.

Version:
$Id: PooledObjectFactory.java,v 1.2 2003/07/23 22:18:08 levahim Exp $
Author:
Lev Himmelfarb
See Also:
AdaptiveObjectPool, PooledObjectFactoryAdapter

Method Summary
 java.lang.Object createObject()
          Instantiates an object for a pool.
 void destroyObject(java.lang.Object o)
          Destroyes the object before it is removed from the pool.
 void resetObject(java.lang.Object o)
          Resets an object after it had been used.
 void setPool(AdaptiveObjectPool pool)
          This method is called when the factory instance is used when creating a new pool.
 

Method Detail

createObject

public java.lang.Object createObject()
Instantiates an object for a pool.

Returns:
the new object instance.

resetObject

public void resetObject(java.lang.Object o)
Resets an object after it had been used. The pool calls this method on the factory and passes an object to it each time the object is returned to the pool.

Note, this method is called from a synchronized block, so it should be short.

Parameters:
o - the object being returned to the pool after use.

destroyObject

public void destroyObject(java.lang.Object o)
Destroyes the object before it is removed from the pool. The pool calls this method when it removes an object, usually because of idle timeout.

Note, this method is called from a synchronized block, so it should be short.

Parameters:
o - the object being removed from the pool.

setPool

public void setPool(AdaptiveObjectPool pool)
This method is called when the factory instance is used when creating a new pool. The AdaptiveObjectPool contructor calls the method.

Parameters:
pool - reference to the pool instance, which is going to use this factory.


Copyright © 2002,2003,2004 - Boyle Software, Inc.