org.objectweb.easybeans.container
Class AbsFactory<PoolType extends EasyBeansBean>

java.lang.Object
  extended by org.objectweb.easybeans.container.AbsFactory<PoolType>
Type Parameters:
PoolType - the type of bean instance.
All Implemented Interfaces:
Factory<PoolType,java.lang.Long>
Direct Known Subclasses:
MDBFactory, SessionFactory

public abstract class AbsFactory<PoolType extends EasyBeansBean>
extends java.lang.Object
implements Factory<PoolType,java.lang.Long>

Abstract factory which implements common and defaults methods.
It should be extended by Bean factories.

Author:
Florent Benoit

Field Summary
private  java.lang.Class<PoolType> beanClass
          Class used to build bean's instance.
private  java.lang.String className
          Name of the class of the managed bean.
private  EZBContainer container
          Container that created this factory.
private  java.util.Map<java.lang.Long,java.lang.reflect.Method> hashes
          Keep a direct reference to the method so that we don't need to compute each time the method object to invoke.
http://java.sun.com/j2se/1.5.0/docs/guide/rmi/spec/rmi-stubs24.html
private  java.lang.String id
          Id of this container.
private  java.util.List<ResourceInjector> injectors
          List of external Resources injectors.
private  javax.naming.Context javaContext
          Context for java: lookups.
private static JLog logger
          Logger.
private static NamingManager namingManager
          Reference on the naming manager.
private  Pool<PoolType,java.lang.Long> pool
          Pool that manage beans instance.
 
Constructor Summary
AbsFactory(java.lang.String className, EZBContainer container)
          Builds a new factory with a given name and its container.
 
Method Summary
 java.lang.Class<PoolType> getBeanClass()
          Gets the bean's class.
 java.lang.String getClassName()
          Gets the className used by this factory.
 EZBContainer getContainer()
          Gets the container used by this factory.
protected  java.util.Map<java.lang.Long,java.lang.reflect.Method> getHashes()
          Gets the computed hashes.
 java.lang.String getId()
          Gets the id of this container.
 javax.naming.Context getJavaContext()
          Gets the java: context.
protected static NamingManager getNamingManager()
          Gets the reference on the naming manager.
 Pool<PoolType,java.lang.Long> getPool()
          Gets the pool used by this factory.
 void init()
          Init the factory.
protected  void injectResources(PoolType instance)
          Injects Resources into the Bean.
 void remove(PoolType instance)
          Callback called when object is gonna be removed.
abstract  EJBResponse rpcInvoke(EJBRequest request)
          A request comes to the bean factory and needs to be handled.
A response is done which contains the answer.
protected  void setBeanClass(java.lang.Class<PoolType> beanClass)
          Sets the bean class that will be used to build bean's instance.
protected  void setHashes(java.util.Map<java.lang.Long,java.lang.reflect.Method> hashes)
          Sets the hashes for the current bean class.
 void setJavaContext(javax.naming.Context javaContext)
          Sets the java: context.
protected  void setPool(Pool<PoolType,java.lang.Long> pool)
          Sets the pool used by this factory.
 void stop()
          Stops the factory.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.objectweb.easybeans.api.Factory
getBeanInfo, localCall
 

Field Detail

logger

private static JLog logger
Logger.


className

private java.lang.String className
Name of the class of the managed bean.


container

private EZBContainer container
Container that created this factory.


pool

private Pool<PoolType extends EasyBeansBean,java.lang.Long> pool
Pool that manage beans instance.


beanClass

private java.lang.Class<PoolType extends EasyBeansBean> beanClass
Class used to build bean's instance.


javaContext

private javax.naming.Context javaContext
Context for java: lookups.


namingManager

private static NamingManager namingManager
Reference on the naming manager.


injectors

private java.util.List<ResourceInjector> injectors
List of external Resources injectors.


hashes

private java.util.Map<java.lang.Long,java.lang.reflect.Method> hashes
Keep a direct reference to the method so that we don't need to compute each time the method object to invoke.
http://java.sun.com/j2se/1.5.0/docs/guide/rmi/spec/rmi-stubs24.html


id

private java.lang.String id
Id of this container.

Constructor Detail

AbsFactory

public AbsFactory(java.lang.String className,
                  EZBContainer container)
           throws FactoryException
Builds a new factory with a given name and its container.

Parameters:
className - name of this factory (name of class that is managed)
container - the root component of this factory.
Throws:
FactoryException - if class can't be loaded.
Method Detail

remove

public void remove(PoolType instance)
Callback called when object is gonna be removed.

Parameters:
instance - that is being removed from the pool.

injectResources

protected void injectResources(PoolType instance)
                        throws PoolException
Injects Resources into the Bean.

Parameters:
instance - The Bean instance to be injected.
Throws:
PoolException - if resources cannot be injected.

getHashes

protected java.util.Map<java.lang.Long,java.lang.reflect.Method> getHashes()
Gets the computed hashes.

Returns:
computed hashes

setHashes

protected void setHashes(java.util.Map<java.lang.Long,java.lang.reflect.Method> hashes)
Sets the hashes for the current bean class.

Parameters:
hashes - method hashes computed as RMI hashes

getJavaContext

public javax.naming.Context getJavaContext()
Gets the java: context.

Specified by:
getJavaContext in interface Factory<PoolType extends EasyBeansBean,java.lang.Long>
Returns:
java: context.

setJavaContext

public void setJavaContext(javax.naming.Context javaContext)
Sets the java: context.

Specified by:
setJavaContext in interface Factory<PoolType extends EasyBeansBean,java.lang.Long>
Parameters:
javaContext - the java: context.

getBeanClass

public java.lang.Class<PoolType> getBeanClass()
Gets the bean's class.

Returns:
bean class used to instantiate beans.

setBeanClass

protected void setBeanClass(java.lang.Class<PoolType> beanClass)
Sets the bean class that will be used to build bean's instance.

Parameters:
beanClass - the instance of the bean class name

setPool

protected void setPool(Pool<PoolType,java.lang.Long> pool)
Sets the pool used by this factory.

Parameters:
pool - the pool which managed bean instances

getContainer

public EZBContainer getContainer()
Gets the container used by this factory.

Specified by:
getContainer in interface Factory<PoolType extends EasyBeansBean,java.lang.Long>
Returns:
container of this factory

getClassName

public java.lang.String getClassName()
Gets the className used by this factory.

Specified by:
getClassName in interface Factory<PoolType extends EasyBeansBean,java.lang.Long>
Returns:
classname that will be instantiated to build bean instance.

getNamingManager

protected static NamingManager getNamingManager()
Gets the reference on the naming manager.

Returns:
the reference on the naming manager.

getPool

public Pool<PoolType,java.lang.Long> getPool()
Gets the pool used by this factory.

Specified by:
getPool in interface Factory<PoolType extends EasyBeansBean,java.lang.Long>
Returns:
pool.

rpcInvoke

public abstract EJBResponse rpcInvoke(EJBRequest request)
A request comes to the bean factory and needs to be handled.
A response is done which contains the answer.

Specified by:
rpcInvoke in interface Factory<PoolType extends EasyBeansBean,java.lang.Long>
Parameters:
request - the EJB request.
Returns:
a response that have been processed by the factory.

init

public void init()
          throws FactoryException
Init the factory.

Specified by:
init in interface Factory<PoolType extends EasyBeansBean,java.lang.Long>
Throws:
FactoryException - if the initialization fails.

getId

public java.lang.String getId()
Gets the id of this container.

Specified by:
getId in interface Factory<PoolType extends EasyBeansBean,java.lang.Long>
Returns:
string id.

stop

public void stop()
Stops the factory.

Specified by:
stop in interface Factory<PoolType extends EasyBeansBean,java.lang.Long>