org.objectweb.jonas_ejb.container
Class JSessionFactory

java.lang.Object
  extended byorg.objectweb.jonas_ejb.container.JFactory
      extended byorg.objectweb.jonas_ejb.container.JSessionFactory
All Implemented Interfaces:
BeanFactory
Direct Known Subclasses:
JStatefulFactory, JStatelessFactory

public abstract class JSessionFactory
extends JFactory

This class is a factory for a Session Bean. It is responsible for - managing Home and LocalHome. - keeping the JNDI context for this component (java:comp/env)

Author:
Philippe Durieux, S. Ali Tokmen, Malek Chahine: EJB statistics

Field Summary
protected  JSessionHome home
           
protected  boolean isStateful
           
protected  boolean isSynchro
           
protected  JSessionLocalHome localhome
           
protected  boolean monitoringEnabled
           
protected  int numberOfCalls
           
protected  java.util.ArrayList sessionList
          Pool of free JSessionSwitch objects Used if singleswitch=false.
protected  boolean singleswitch
          If no timeout, we can manage only 1 JSessionSwitch for all sessions.
protected  long totalBusinessProcessingTime
           
protected  long totalProcessingTime
           
protected  JSessionSwitch uniqueSession
          Unique JSessionSwitch when singleswitch=true
protected  int warningThreshold
           
 
Fields inherited from class org.objectweb.jonas_ejb.container.JFactory
beanclass, cont, dd, ejb10Env, ejbname, ejbTimeoutSignature, isClusterReplicated, JNDICtx, maxCacheSize, minPoolSize, myTimerService, naming, passivationDir, stopped, timerTxAttr, tm, txbeanmanaged, wm
 
Constructor Summary
JSessionFactory(SessionDesc dd, JContainer cont)
          constructor
 
Method Summary
 void checkTransaction(RequestCtx rctx)
          Session beans can be container managed or bean managed transaction Session home don't check transactional context.
 JSessionSwitch createEJB()
          Create a new Session Find one in the pool, or create a new object.
protected abstract  JSessionSwitch createNewSession()
           
 JHome getHome()
          returns the home if exist or null if not
abstract  JSessionContext getJContext(JSessionSwitch ss)
           
 JLocalHome getLocalHome()
          returns the local home if exist or null if not
 boolean getMonitoringEnabled()
           
 boolean getMonitoringSettingsDefinedInDD()
           
 int getNumberOfCalls()
           
 int getTimeout()
           
 long getTotalBusinessProcessingTime()
           
 long getTotalProcessingTime()
           
 int getWarningThreshold()
           
 boolean isSessionSynchro()
           
 boolean isStateful()
           
 void removeEJB(JSessionSwitch bs)
          remove a Session.
 void setMonitoringEnabled(boolean monitoringEnabled)
           
 void setMonitoringSettingsDefinedInDD(boolean monitoringSettingsDefinedInDD)
           
 void setNumberOfCalls(int numberOfCalls)
           
 void setTimeout(int t)
           
 void setTotalBusinessProcessingTime(long totalBusinessProcessingTime)
           
 void setTotalProcessingTime(long totalProcessingTime)
           
 void setWarningThreshold(int warningThreshold)
           
 boolean singleSwitchOn()
          Return true if singleswitch option is on.
 void stop()
          stop this EJB.
 void syncDirty(boolean notused)
          synchronize bean instances if needed
 
Methods inherited from class org.objectweb.jonas_ejb.container.JFactory
checkJonasVersion, checkSecurity, checkTransactionContainer, getCacheSize, getContainer, getDeploymentDescriptor, getEjb10Environment, getEJBName, getEjbTimeoutSignature, getEnv, getInitialContext, getMaxCacheSize, getMinPoolSize, getPassivationDir, getPoolSize, getResourceCheckerManager, getTimerService, getTimerTxAttribute, getTransactionManager, getWorkManager, init, initInstancePool, isClassAvailable, isStopped, isTxBeanManaged, myClassLoader, postInvoke, postInvokeRemote, preInvoke, preInvokeRemote, resetComponentContext, restartTimers, setComponentContext, setResourceCheckerManager, 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
reduceCache, storeInstances
 

Field Detail

home

protected JSessionHome home

localhome

protected JSessionLocalHome localhome

isSynchro

protected boolean isSynchro

isStateful

protected boolean isStateful

monitoringEnabled

protected boolean monitoringEnabled

warningThreshold

protected int warningThreshold

numberOfCalls

protected int numberOfCalls

totalBusinessProcessingTime

protected long totalBusinessProcessingTime

totalProcessingTime

protected long totalProcessingTime

sessionList

protected java.util.ArrayList sessionList
Pool of free JSessionSwitch objects Used if singleswitch=false.


uniqueSession

protected JSessionSwitch uniqueSession
Unique JSessionSwitch when singleswitch=true


singleswitch

protected boolean singleswitch
If no timeout, we can manage only 1 JSessionSwitch for all sessions. Only used in case of stateless, for load balancing.

Constructor Detail

JSessionFactory

public JSessionFactory(SessionDesc dd,
                       JContainer cont)
constructor

Parameters:
dd - The Session Deployment Descriptor
cont - The Container where the bean is defined.
Method Detail

singleSwitchOn

public boolean singleSwitchOn()
Return true if singleswitch option is on.

Returns:

stop

public void stop()
stop this EJB. Mainly unregister it in JNDI.


syncDirty

public void syncDirty(boolean notused)
synchronize bean instances if needed

Parameters:
notused - True if store even if passivation timeout not elapsed

getHome

public JHome getHome()
Description copied from interface: BeanFactory
returns the home if exist or null if not

Returns:
the home if exist

getLocalHome

public JLocalHome getLocalHome()
Description copied from interface: BeanFactory
returns the local home if exist or null if not

Returns:
the local home if exist

createEJB

public JSessionSwitch createEJB()
                         throws java.rmi.RemoteException
Create a new Session Find one in the pool, or create a new object.

Returns:
a SessionSwitch
Throws:
java.rmi.RemoteException

removeEJB

public void removeEJB(JSessionSwitch bs)
remove a Session. This may be called also on timeout. put it back in the pool for later use.

Parameters:
bs - The Bean Session Switch to put back in the pool.

checkTransaction

public void checkTransaction(RequestCtx rctx)
Session beans can be container managed or bean managed transaction Session home don't check transactional context.

Parameters:
rctx - The Request Context

isSessionSynchro

public boolean isSessionSynchro()
Returns:
True if this Session implements SessionSynchronization

getTimeout

public int getTimeout()
Returns:
the current timeout value in seconds for Jmx

setTimeout

public void setTimeout(int t)
Parameters:
t - timeout value for JMX (in seconds)

isStateful

public boolean isStateful()
Returns:
true if this Session is Stateful. Will be used internally by EJBObject or EJBLocalObject because they are common to both types.

getMonitoringSettingsDefinedInDD

public boolean getMonitoringSettingsDefinedInDD()
Returns:
true if EJB monitoring settings have been defined in the deployment descriptor

setMonitoringSettingsDefinedInDD

public void setMonitoringSettingsDefinedInDD(boolean monitoringSettingsDefinedInDD)
Parameters:
monitoringSettingsDefinedInDD - Whether EJB monitoring settings have been defined in the deployment descriptor

getMonitoringEnabled

public boolean getMonitoringEnabled()
Returns:
true if EJB monitoring is active.

setMonitoringEnabled

public void setMonitoringEnabled(boolean monitoringEnabled)
Parameters:
monitoringEnabled - Whether to activate EJB monitoring.

getWarningThreshold

public int getWarningThreshold()
Returns:
Number of milliseconds after which methods will start warning.

setWarningThreshold

public void setWarningThreshold(int warningThreshold)
Parameters:
warningThreshold - Number of milliseconds after which methods will start warning.

getNumberOfCalls

public int getNumberOfCalls()
Returns:
Total number of calls on this EJB.

setNumberOfCalls

public void setNumberOfCalls(int numberOfCalls)
Parameters:
numberOfCalls - Total number of calls on this EJB.

getTotalBusinessProcessingTime

public long getTotalBusinessProcessingTime()
Returns:
Total time (in millis) spent in business execution.

setTotalBusinessProcessingTime

public void setTotalBusinessProcessingTime(long totalBusinessProcessingTime)
Parameters:
totalBusinessProcessingTime - Total time (in millis) spent in business execution.

getTotalProcessingTime

public long getTotalProcessingTime()
Returns:
Total time (in millis) spent in business + container execution.

setTotalProcessingTime

public void setTotalProcessingTime(long totalProcessingTime)
Parameters:
totalProcessingTime - Total time (in millis) spent in business + container execution.

getJContext

public abstract JSessionContext getJContext(JSessionSwitch ss)
Returns:
a JSessionContext

createNewSession

protected abstract JSessionSwitch createNewSession()
                                            throws java.rmi.RemoteException
Throws:
java.rmi.RemoteException