org.objectweb.jonas_ejb.container
Class JFactory

java.lang.Object
  extended by org.objectweb.jonas_ejb.container.JFactory
All Implemented Interfaces:
BeanFactory
Direct Known Subclasses:
JEntityFactory, JMdbEndpointFactory, JMdbFactory, JSessionFactory

public abstract class JFactory
extends java.lang.Object
implements BeanFactory

This class is a factory for beans.

Author:
Philippe Durieux, Florent Benoit (JACC security)

Field Summary
protected  java.lang.Class beanclass
           
protected  JContainer cont
           
protected  BeanDesc dd
           
protected  java.util.Properties ejb10Env
           
protected  java.lang.String ejbname
           
protected  java.lang.String ejbTimeoutSignature
          Signature for ejbTimeout
protected  boolean isClusterReplicated
           
protected  javax.naming.Context JNDICtx
           
protected  int maxCacheSize
           
protected  int minPoolSize
          initial value for pool size
protected  javax.ejb.TimerService myTimerService
           
protected  ContainerNaming naming
           
protected  java.io.File passivationDir
           
protected  boolean stopped
           
protected  int timerTxAttr
          Transational attribute for ejbTimeout method.
protected  org.objectweb.transaction.jta.TransactionManager tm
           
protected  boolean txbeanmanaged
           
protected  javax.resource.spi.work.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(java.lang.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
 java.util.Properties getEjb10Environment()
           
 java.lang.String getEJBName()
          get the bean name
 java.lang.String getEjbTimeoutSignature()
           
 java.util.Hashtable getEnv()
          Return the JNDI Environment
 javax.naming.InitialContext getInitialContext()
          Returns the InitialContext
 int getMaxCacheSize()
           
 int getMinPoolSize()
           
 java.io.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
abstract  javax.ejb.TimerService getTimerService()
           
 int getTimerTxAttribute()
           
 org.objectweb.transaction.jta.TransactionManager getTransactionManager()
          returns the TransactionManager
 javax.resource.spi.work.WorkManager getWorkManager()
          Return the WorkManager
 void init(BeanDesc dd, JContainer cont)
          Init this object
abstract  void initInstancePool()
          Init the pool of instances.
protected  boolean isClassAvailable(java.lang.String className, boolean unique)
          Assess availability of a class in a given class loader
 boolean isStopped()
           
 boolean isTxBeanManaged()
           
 java.lang.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(javax.naming.Context oldctx)
          reset old Component Context for JNDI environment
 void restartTimers()
          Restart Timers
 javax.naming.Context setComponentContext()
          set the Component Context for JNDI environment
 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.objectweb.jonas_ejb.container.BeanFactory
getHome, getLocalHome, reduceCache, stop, storeInstances, syncDirty
 

Field Detail

cont

protected JContainer cont

stopped

protected boolean stopped

naming

protected ContainerNaming naming

tm

protected org.objectweb.transaction.jta.TransactionManager tm

wm

protected javax.resource.spi.work.WorkManager wm

JNDICtx

protected javax.naming.Context JNDICtx

ejbname

protected java.lang.String ejbname

dd

protected BeanDesc dd

ejb10Env

protected java.util.Properties ejb10Env

myTimerService

protected javax.ejb.TimerService myTimerService

txbeanmanaged

protected boolean txbeanmanaged

beanclass

protected java.lang.Class beanclass

passivationDir

protected java.io.File passivationDir

minPoolSize

protected int minPoolSize
initial value for pool size


maxCacheSize

protected int maxCacheSize

isClusterReplicated

protected boolean isClusterReplicated

timerTxAttr

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


ejbTimeoutSignature

protected java.lang.String ejbTimeoutSignature
Signature for ejbTimeout

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 java.io.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 javax.resource.spi.work.WorkManager getWorkManager()
Return 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(java.lang.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 java.lang.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 org.objectweb.transaction.jta.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 java.util.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 javax.naming.InitialContext getInitialContext()
Description copied from interface: BeanFactory
Returns the InitialContext

Specified by:
getInitialContext in interface BeanFactory
Returns:
the InitialContext

getTimerService

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

getEjb10Environment

public java.util.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 javax.naming.Context setComponentContext()
set the Component Context for JNDI environment

Returns:
previous Context

resetComponentContext

public void resetComponentContext(javax.naming.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 java.lang.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:
javax.ejb.EJBException

postInvoke

public void postInvoke(RequestCtx rctx)
Common postInvoke

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

preInvokeRemote

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

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

postInvokeRemote

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

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

checkTransactionContainer

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

Parameters:
rctx - the Request Context
Throws:
javax.ejb.EJBException
javax.ejb.TransactionRequiredLocalException

checkJonasVersion

protected void checkJonasVersion(java.lang.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 java.lang.ClassLoader myClassLoader()
Returns:
the classloader for this container.