org.sadun.util.pool
Class ObjectPool.BaseFactory

java.lang.Object
  extended byorg.sadun.util.pool.ObjectPool.BaseFactory
All Implemented Interfaces:
ObjectPool.Factory, java.io.Serializable
Direct Known Subclasses:
EjbFactory, ObjectPool.ObjectFactory
Enclosing class:
ObjectPool

public abstract static class ObjectPool.BaseFactory
extends java.lang.Object
implements ObjectPool.Factory

A base implementation of ExtendedObjectPool.Factory relying on reflection, holding a Class object, an optional parameter array and an optional Setup object.

These objects are made available to subclasses by the members cls, params and ps.

Version:
1.0
Author:
Cristiano Sadun
See Also:
Serialized Form

Field Summary
protected  java.lang.Class cls
          The class of the objects produced by the factory.
protected  java.lang.Class[] paramCls
          The types of the parameters to use for constructing the object.
protected  java.lang.Object[] params
          The parameters to use for constructing the object.
protected  Setup ps
          The setup object to use for post-construction initialization.
 
Constructor Summary
ObjectPool.BaseFactory(java.lang.Class cls, java.lang.Object[] params, Setup ps)
          Create a BaseFactory whose member cls will hold the class of the objects to produce
ObjectPool.BaseFactory(java.lang.String clsName, java.lang.Object[] params, Setup ps)
          Create a BaseFactory whose member cls will hold the class of the objects to produce
 
Method Summary
abstract  java.lang.Object create()
          Subclasses must implement the code which actually creates a new instance of the class to pool.
 void destroy(java.lang.Object obj)
          A null implementation of ObjectPool.Factory.destroy().
 java.lang.Class getProducedClass()
          Return the class object for the type of object this factory creates
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

cls

protected java.lang.Class cls
The class of the objects produced by the factory.


params

protected java.lang.Object[] params
The parameters to use for constructing the object. It is never null, but may have size zero.


ps

protected Setup ps
The setup object to use for post-construction initialization. Can be null.


paramCls

protected java.lang.Class[] paramCls
The types of the parameters to use for constructing the object. It is never null, but may have size zero.

Constructor Detail

ObjectPool.BaseFactory

public ObjectPool.BaseFactory(java.lang.Class cls,
                              java.lang.Object[] params,
                              Setup ps)
Create a BaseFactory whose member cls will hold the class of the objects to produce

Parameters:
cls - the class of the objects to produce
params - the construction parameters, or null
ps - the Setup object to be used for post-construction setup, or null

ObjectPool.BaseFactory

public ObjectPool.BaseFactory(java.lang.String clsName,
                              java.lang.Object[] params,
                              Setup ps)
Create a BaseFactory whose member cls will hold the class of the objects to produce

Parameters:
clsName - the name of the class of the objects to produce
params - the construction parameters, or null
ps - the Setup object to be used for post-construction setup, or null
Method Detail

create

public abstract java.lang.Object create()
Subclasses must implement the code which actually creates a new instance of the class to pool.

Specified by:
create in interface ObjectPool.Factory
Returns:
the newly created object

destroy

public void destroy(java.lang.Object obj)
A null implementation of ObjectPool.Factory.destroy().

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

getProducedClass

public java.lang.Class getProducedClass()
Return the class object for the type of object this factory creates

Specified by:
getProducedClass in interface ObjectPool.Factory
Returns:
the class object for the type of object this factory creates