org.sadun.util.pool2
Class ObjectPool.PooledObjectFactory

java.lang.Object
  extended byorg.sadun.util.pool2.ObjectPool.PooledObjectFactory
All Implemented Interfaces:
ObjectPool.Factory, java.io.Serializable
Enclosing class:
ObjectPool

protected static class ObjectPool.PooledObjectFactory
extends java.lang.Object
implements ObjectPool.Factory

A object factory which produces BasePooledObject wrappers for other classes.

In detail, this class uses an existing object factory to produce objects of class C, obtains an appropriate PooledC subclass of BasePooledObject and then wraps the objects in instances of PooledC.

See Also:
Serialized Form

Constructor Summary
protected ObjectPool.PooledObjectFactory(ObjectPool pool, ObjectPool.Factory factory)
          Create a factory which is used by the given ObjectPool and employs the given org.sadun.util.pool.ObjectPool.Factory
 
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.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ObjectPool.PooledObjectFactory

protected ObjectPool.PooledObjectFactory(ObjectPool pool,
                                         ObjectPool.Factory factory)
                                  throws ObjectPool.ObjectPoolException
Create a factory which is used by the given ObjectPool and employs the given org.sadun.util.pool.ObjectPool.Factory

Parameters:
pool - the ObjectPool using this factory to create pooled objects
factory - the org.sadun.util.pool.ObjectPool.Factory to produce the original instances
Method Detail

create

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

Specified by:
create in interface ObjectPool.Factory
Returns:
the newly created object
Throws:
ObjectPool.ObjectPoolException
See Also:
ObjectPool.Factory.create()

getProducedClass

public java.lang.Class getProducedClass()
Description copied from interface: ObjectPool.Factory
This method is invoked when validating the created class.

Specified by:
getProducedClass in interface ObjectPool.Factory
Returns:
the class object for the type of object this factory will create
See Also:
ObjectPool.Factory.getProducedClass()

destroy

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

Specified by:
destroy in interface ObjectPool.Factory
Parameters:
obj - the object to destroy
Throws:
ObjectPool.ObjectPoolException