org.sadun.util.pool
Class ObjectPool.ObjectFactory

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

public static class ObjectPool.ObjectFactory
extends ObjectPool.BaseFactory

An ExtendedObjectPool.Factory implementation which uses reflection to create instances of a certain class.

After creation, objects can be optionally setup by an user-provided class implementing the Setup interface.

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

Field Summary
 
Fields inherited from class org.sadun.util.pool.ObjectPool.BaseFactory
cls, paramCls, params, ps
 
Constructor Summary
ObjectPool.ObjectFactory(java.lang.Class cls, java.lang.Object[] params, Setup ps)
          Create a factory which will construct object of the given class, with the given parameters, using the given Setup object.
ObjectPool.ObjectFactory(java.lang.String clsName, java.lang.Object[] params, Setup ps)
          Create a factory which will construct object of the given class, with the given parameters, using the given Setup object.
 
Method Summary
 java.lang.Object create()
          Create an instance of the class defined at construction, using the (optional) parameters and the (optional) Setup object defined at construction for construction and post-construction initialization.
 void destroy(java.lang.Object obj)
          This implementation does not do anything.
 
Methods inherited from class org.sadun.util.pool.ObjectPool.BaseFactory
getProducedClass
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ObjectPool.ObjectFactory

public ObjectPool.ObjectFactory(java.lang.Class cls,
                                java.lang.Object[] params,
                                Setup ps)
Create a factory which will construct object of the given class, with the given parameters, using the given Setup object.

The construction parameter types are deduced from the types of the passed parameter objects, and a compatible constructor is searched for.

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

ObjectPool.ObjectFactory

public ObjectPool.ObjectFactory(java.lang.String clsName,
                                java.lang.Object[] params,
                                Setup ps)
Create a factory which will construct object of the given class, with the given parameters, using the given Setup object.

The construction parameter types are deduced from the types of the passed parameter objects, and a compatible constructor is searched for.

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

create

public java.lang.Object create()
Create an instance of the class defined at construction, using the (optional) parameters and the (optional) Setup object defined at construction for construction and post-construction initialization.

Specified by:
create in interface ObjectPool.Factory
Specified by:
create in class ObjectPool.BaseFactory
Returns:
the newly created object
Throws:
ObjectPoolException - if there is a problem creating the object

destroy

public void destroy(java.lang.Object obj)
This implementation does not do anything.

Specified by:
destroy in interface ObjectPool.Factory
Overrides:
destroy in class ObjectPool.BaseFactory