org.ow2.jonas.lib.ejb21
Class JFactory

java.lang.Object
  extended by org.ow2.jonas.lib.ejb21.JFactory
All Implemented Interfaces:
BeanFactory
Direct Known Subclasses:
JEntityFactory, JMdbEndpointFactory, JMdbFactory, JSessionFactory

public abstract class JFactory
extends Object
implements BeanFactory

This class is a factory for beans.

Author:
Philippe Durieux, Florent Benoit (JACC security), eyindanga (Life cycle dispatcher)

Field Summary
protected  Class<?> beanclass
           
protected  JContainer cont
           
protected  BeanDesc dd
           
protected  org.ow2.util.event.api.IEventDispatcher dispatcher
          Event dispatcher.
protected  Properties ejb10Env
           
protected  String ejbname
           
protected  String ejbTimeoutSignature
          Signature for ejbTimeout.
protected  boolean isClusterReplicated
           
protected  Context JNDICtx
           
protected  int maxCacheSize
           
protected  int minPoolSize
          initial value for pool size
protected  TimerService myTimerService
           
protected  JNamingManager naming
           
protected  File passivationDir
           
protected  boolean stopped
           
protected  int timerTxAttr
          Transactional attribute for ejbTimeout method.
protected  TransactionManager tm
           
protected  boolean txbeanmanaged
           
protected  WorkManager wm
           
 
Constructor Summary
JFactory()
          constructor (for entity) must be without parameters (required by Jorm).
JFactory(BeanDesc dd, JContainer cont)
          constructor (for session)
 
Method Summary
protected  void checkJonasVersion(String clName)
          Check if the given class have been generated by GenIC tool with a correct version.
 void checkSecurity(EJBInvocation ejbInv)
          Check if the access to the bean is authorized
protected  void checkTransactionContainer(RequestCtx rctx)
          Process Transaction Attribute before calling a business method
 int getCacheSize()
           
 JContainer getContainer()
          Returns the JContainer
 BeanDesc getDeploymentDescriptor()
          Get the Deployement descriptor of this Ejb
 org.ow2.util.event.api.IEventDispatcher getDispatcher()
           
 Properties getEjb10Environment()
           
 String getEJBName()
          get the bean name
 String getEjbTimeoutSignature()
           
 Hashtable getEnv()
          Return the JNDI Environment
 String[] getFileList(File dir, String prefix, String suffix)
           
 InitialContext getInitialContext()
          Returns the InitialContext
 int getMaxCacheSize()
           
 int getMinPoolSize()
           
 File getPassivationDir()
          Get the directory where to store stateful state and timers
abstract  int getPoolSize()
          Get the size of the instance pool for this bean
 IResourceCheckerManager getResourceCheckerManager()
           
abstract  TimerService getTimerService()
           
 int getTimerTxAttribute()
           
 TransactionManager getTransactionManager()
          returns the TransactionManager
 WorkManager getWorkManager()
           
 void init(BeanDesc dd, JContainer cont)
          Init this object
abstract  void initInstancePool()
          Init the pool of instances.
protected  boolean isClassAvailable(String className, boolean unique)
          Assess availability of a class in a given class loader
 boolean isStopped()
           
 boolean isTxBeanManaged()
           
 ClassLoader myClassLoader()
           
 void postInvoke(RequestCtx rctx)
          Common postInvoke
 void postInvokeRemote(RequestCtx rctx)
          postInvoke for Remote access
 RequestCtx preInvoke(int txa)
          Common preInvoke
 RequestCtx preInvokeRemote(int txa)
          preInvoke for Remote access
 void resetComponentContext(Context oldctx)
          reset old Component Context for JNDI environment
 void restartTimers()
          Restart Timers
 Context setComponentContext()
          set the Component Context for JNDI environment
 void setDispatcher(org.ow2.util.event.api.IEventDispatcher dispatcher)
           
 void setResourceCheckerManager(IResourceCheckerManager resourceCheckerManager)
          Sets the resource checker manager.
 void stopContainer()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.ow2.jonas.lib.ejb21.BeanFactory
getHome, getLocalHome, reduceCache, stop, storeInstances, syncDirty
 

Field Detail

cont

protected JContainer cont

stopped

protected boolean stopped

naming

protected JNamingManager naming

tm

protected TransactionManager tm

wm

protected WorkManager wm

JNDICtx

protected Context JNDICtx

ejbname

protected String ejbname

dd

protected BeanDesc dd

ejb10Env

protected Properties ejb10Env

myTimerService

protected TimerService myTimerService

txbeanmanaged

protected boolean txbeanmanaged

beanclass

protected Class<?> beanclass

passivationDir

protected File passivationDir

minPoolSize

protected int minPoolSize
initial value for pool size


maxCacheSize

protected int maxCacheSize

isClusterReplicated

protected boolean isClusterReplicated

timerTxAttr

protected int timerTxAttr
Transactional attribute for ejbTimeout method. default is TX_REQUIRES_NEW


ejbTimeoutSignature

protected String ejbTimeoutSignature
Signature for ejbTimeout.


dispatcher

protected org.ow2.util.event.api.IEventDispatcher dispatcher
Event dispatcher.

Constructor Detail

JFactory

public JFactory()
constructor (for entity) must be without parameters (required by Jorm).


JFactory

public JFactory(BeanDesc dd,
                JContainer cont)
constructor (for session)

Parameters:
dd - The bean deployment descriptor
cont - the container for this bean
Method Detail

stopContainer

public void stopContainer()

isStopped

public boolean isStopped()

getPassivationDir

public File getPassivationDir()
Get the directory where to store stateful state and timers


init

public void init(BeanDesc dd,
                 JContainer cont)
Init this object

Parameters:
dd - the deployment descriptor
cont - the Container

getWorkManager

public WorkManager getWorkManager()
Returns:
Returns the WorkManager.

initInstancePool

public abstract void initInstancePool()
Init the pool of instances. Not used for stateful beans

Specified by:
initInstancePool in interface BeanFactory

restartTimers

public void restartTimers()
Restart Timers

Specified by:
restartTimers in interface BeanFactory

isClassAvailable

protected boolean isClassAvailable(String className,
                                   boolean unique)
Assess availability of a class in a given class loader

Parameters:
className - the name of the class without the .class extension
unique - flag indicating if the class should be found only once in the classloader
Returns:
True if class is available in the current class loader.

getEJBName

public String getEJBName()
Description copied from interface: BeanFactory
get the bean name

Specified by:
getEJBName in interface BeanFactory
Returns:
the bean name

getPoolSize

public abstract int getPoolSize()
Description copied from interface: BeanFactory
Get the size of the instance pool for this bean

Specified by:
getPoolSize in interface BeanFactory
Returns:
the Instance pool size for this Ejb

getDeploymentDescriptor

public BeanDesc getDeploymentDescriptor()
Get the Deployement descriptor of this Ejb

Specified by:
getDeploymentDescriptor in interface BeanFactory
Returns:
BeanDesc The bean deployment descriptor

getTransactionManager

public TransactionManager getTransactionManager()
Description copied from interface: BeanFactory
returns the TransactionManager

Specified by:
getTransactionManager in interface BeanFactory
Returns:
the TransactionManager

getContainer

public JContainer getContainer()
Description copied from interface: BeanFactory
Returns the JContainer

Specified by:
getContainer in interface BeanFactory
Returns:
the JContainer object

getEnv

public Hashtable getEnv()
Description copied from interface: BeanFactory
Return the JNDI Environment

Specified by:
getEnv in interface BeanFactory
Returns:
A Hashtable containing the JNDI Environment

getInitialContext

public InitialContext getInitialContext()
Description copied from interface: BeanFactory
Returns the InitialContext

Specified by:
getInitialContext in interface BeanFactory
Returns:
the InitialContext

getTimerService

public abstract TimerService getTimerService()
Returns:
the TimerService for this bean. This works only for stateless or message driven beans.

getEjb10Environment

public Properties getEjb10Environment()
Returns:
the EJB 1.0 style environment associated with the Bean

isTxBeanManaged

public boolean isTxBeanManaged()
Returns:
true if transactions are managed inside the bean false if transactions are managed by the container

setComponentContext

public Context setComponentContext()
set the Component Context for JNDI environment

Returns:
previous Context

resetComponentContext

public void resetComponentContext(Context oldctx)
reset old Component Context for JNDI environment

Parameters:
oldctx - previous Component Context to restore.

getTimerTxAttribute

public int getTimerTxAttribute()
Returns:
the transaction attribute for ejbTimeout method

getEjbTimeoutSignature

public String getEjbTimeoutSignature()
Returns:
the security signature for ejbTimeout method.

getMinPoolSize

public int getMinPoolSize()
Returns:
min pool size for Jmx

getMaxCacheSize

public int getMaxCacheSize()
Returns:
max cache size for Jmx

getCacheSize

public int getCacheSize()
Returns:
max cache size for Jmx

checkSecurity

public void checkSecurity(EJBInvocation ejbInv)
Check if the access to the bean is authorized

Parameters:
ejbInv - object containing security signature of the method, args of method, etc

preInvoke

public RequestCtx preInvoke(int txa)
Common preInvoke

Parameters:
txa - Transaction Attribute (Supports, Required, ...)
Returns:
A RequestCtx object
Throws:
EJBException

postInvoke

public void postInvoke(RequestCtx rctx)
Common postInvoke

Parameters:
rctx - The RequestCtx that was returned at preInvoke()
Throws:
EJBException

preInvokeRemote

public RequestCtx preInvokeRemote(int txa)
                           throws RemoteException
preInvoke for Remote access

Parameters:
txa - Transaction Attribute (Supports, Required, ...)
Returns:
A RequestCtx object
Throws:
java.rmi.TransactionRequiredException
java.rmi.TransactionRolledbackException
NoSuchObjectException
RemoteException - preinvoke raised an EJBException

postInvokeRemote

public void postInvokeRemote(RequestCtx rctx)
                      throws RemoteException
postInvoke for Remote access

Parameters:
rctx - The RequestCtx that was returne t preInvoke()
Throws:
TransactionRequiredException
TransactionRolledbackException
NoSuchObjectException
RemoteException - postinvoke failed

checkTransactionContainer

protected void checkTransactionContainer(RequestCtx rctx)
Process Transaction Attribute before calling a business method

Parameters:
rctx - the Request Context
Throws:
EJBException
TransactionRequiredLocalException

checkJonasVersion

protected void checkJonasVersion(String clName)
Check if the given class have been generated by GenIC tool with a correct version. Trace an error message, if not.

Parameters:
clName - class name

myClassLoader

public ClassLoader myClassLoader()
Returns:
the classloader for this container.

getFileList

public String[] getFileList(File dir,
                            String prefix,
                            String suffix)
Returns:
a list of files with this suffix in directory dstr.

getDispatcher

public org.ow2.util.event.api.IEventDispatcher getDispatcher()
Returns:
the dispatcher

setDispatcher

public void setDispatcher(org.ow2.util.event.api.IEventDispatcher dispatcher)
Parameters:
dispatcher - the dispatcher to set

getResourceCheckerManager

public IResourceCheckerManager getResourceCheckerManager()
Specified by:
getResourceCheckerManager in interface BeanFactory
Returns:
the resource checker manager

setResourceCheckerManager

public void setResourceCheckerManager(IResourceCheckerManager resourceCheckerManager)
Sets the resource checker manager.

Specified by:
setResourceCheckerManager in interface BeanFactory
Parameters:
resourceCheckerManager - the given instance


Copyright © 2010 OW2 Consortium. All Rights Reserved.