org.sadun.util.pool
Class EjbFactory

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

public class EjbFactory
extends ObjectPool.BaseFactory

An ExtendedObjectPool.Factory implementation which uses reflection to create instances of enterprise java beans, looking up the home interface and invoking a proper create() method.

The JNDI name and the home interface class of the EJB to pool must be provided at construction.

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
EjbFactory(java.lang.String jndiName, java.lang.Class remoteInterface)
           
EjbFactory(java.lang.String jndiName, java.lang.Class remoteInterface, java.lang.Object[] params)
           
EjbFactory(java.lang.String jndiName, java.lang.Class remoteInterface, java.lang.Object[] params, Setup ps)
          Create a factory which makes use of a create() method on the home interface of an EJB with the given JNDI name and expecting the given parameters; after creation, the given Setup object will be used for post initialization.
 
Method Summary
 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)
          This implementation does not do anything.
 javax.ejb.EJBHome getEJBHome()
          Get the home interface used by this factory to produce Enterprise Java Beans
 java.lang.String getJNDIName()
          Return the JNDI name of the Enterprise Java Bean produced by this factory
 
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

EjbFactory

public EjbFactory(java.lang.String jndiName,
                  java.lang.Class remoteInterface,
                  java.lang.Object[] params,
                  Setup ps)
Create a factory which makes use of a create() method on the home interface of an EJB with the given JNDI name and expecting the given parameters; after creation, the given Setup object will be used for post initialization.

Parameters:
jndiName - the JNDI name of the EJB's home interface
remoteInterface - the remote interface of the EJB
params - the types of the parameters expected by the EJB's create() method, or null
ps - the Setup object to be used for post-construction setup, or null

EjbFactory

public EjbFactory(java.lang.String jndiName,
                  java.lang.Class remoteInterface,
                  java.lang.Object[] params)

EjbFactory

public EjbFactory(java.lang.String jndiName,
                  java.lang.Class remoteInterface)
Method Detail

create

public java.lang.Object create()
                        throws ObjectPool.ObjectPoolException
Description copied from class: ObjectPool.BaseFactory
Subclasses must implement the code which actually creates a new instance of the class to pool.

Specified by:
create in interface ObjectPool.Factory
Specified by:
create in class ObjectPool.BaseFactory
Throws:
ObjectPool.ObjectPoolException

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

getJNDIName

public java.lang.String getJNDIName()
Return the JNDI name of the Enterprise Java Bean produced by this factory

Returns:
the JNDI name of the Enterprise Java Bean produced by this factory

getEJBHome

public javax.ejb.EJBHome getEJBHome()
Get the home interface used by this factory to produce Enterprise Java Beans

Returns:
the home interface used by this factory to produce Enterprise Java Beans