org.sadun.util.pool
Interface ObjectPool.Factory

All Superinterfaces:
java.io.Serializable
All Known Implementing Classes:
ObjectPool.BaseFactory, ObjectPool.PooledObjectFactory
Enclosing interface:
ObjectPool

public static interface ObjectPool.Factory
extends java.io.Serializable

If an object to be pooled can't be constructed directly by invoking a constructor, a Factory can be provided to do the construction job.


Method Summary
 java.lang.Object create()
          This method is invoked by the pool when a pooled instance has to be created.
 void destroy(java.lang.Object obj)
          This method is invoked by the pool when a pooled instance has to be destroyed.
 java.lang.Class getProducedClass()
          This method is invoked when validating the created class.
 

Method Detail

create

public java.lang.Object create()
                        throws ObjectPool.ObjectPoolException
This method is invoked by the pool when a pooled instance has to be created.

Returns:
the newly created object
Throws:
ObjectPoolException - if there is a problem creating the object
ObjectPool.ObjectPoolException

destroy

public void destroy(java.lang.Object obj)
             throws ObjectPool.ObjectPoolException
This method is invoked by the pool when a pooled instance has to be destroyed.

Parameters:
obj - the object to destroy
Throws:
ObjectPoolException - if there is a problem destroying the object
ObjectPool.ObjectPoolException

getProducedClass

public java.lang.Class getProducedClass()
This method is invoked when validating the created class.

Returns:
the class object for the type of object this factory will create