org.ow2.jonas.lib.ejb21
Class JSessionFactory

java.lang.Object
  extended by org.ow2.jonas.lib.ejb21.JFactory
      extended by org.ow2.jonas.lib.ejb21.JSessionFactory
All Implemented Interfaces:
BeanFactory, org.ow2.util.event.api.IEventListener
Direct Known Subclasses:
JStatefulFactory, JStatelessFactory

public abstract class JSessionFactory
extends JFactory
implements org.ow2.util.event.api.IEventListener

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, Malek Chahine: EJB statistics, eyindanga (Refactoring of statistic event dispatcher)

Field Summary
protected  JSessionHome home
           
protected  boolean isStateful
           
protected  boolean isSynchro
           
protected  JSessionLocalHome localhome
           
protected  boolean monitoringEnabled
           
protected  long numberOfCalls
           
protected  ArrayList<JSessionSwitch> 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.ow2.jonas.lib.ejb21.JFactory
beanclass, cont, dd, dispatcher, 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
 boolean accept(org.ow2.util.event.api.IEvent event)
           
 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()
           
 long getNumberOfCalls()
           
 org.ow2.util.event.api.EventPriority getPriority()
           
 int getTimeout()
           
 long getTotalBusinessProcessingTime()
           
 long getTotalProcessingTime()
           
 int getWarningThreshold()
           
 void handle(org.ow2.util.event.api.IEvent event)
           
 boolean isSessionSynchro()
           
 boolean isStateful()
           
 void removeEJB(JSessionSwitch bs)
          remove a Session.
 void setMonitoringEnabled(boolean monitoringEnabled)
           
 void setMonitoringSettingsDefinedInDD(boolean monitoringSettingsDefinedInDD)
           
 void setNumberOfCalls(long numberOfCalls)
           
 void setTimeout(int t)
          set the current timeout value for Jmx
 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.ow2.jonas.lib.ejb21.JFactory
checkJonasVersion, checkSecurity, checkTransactionContainer, getCacheSize, getContainer, getDeploymentDescriptor, getDispatcher, getEjb10Environment, getEJBName, getEjbTimeoutSignature, getEnv, getFileList, getInitialContext, getMaxCacheSize, getMinPoolSize, getPassivationDir, getPoolSize, getResourceCheckerManager, getTimerService, getTimerTxAttribute, getTransactionManager, getWorkManager, init, initInstancePool, isClassAvailable, isStopped, isTxBeanManaged, myClassLoader, postInvoke, postInvokeRemote, preInvoke, preInvokeRemote, resetComponentContext, restartTimers, setComponentContext, setDispatcher, 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.ow2.jonas.lib.ejb21.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 long numberOfCalls

totalBusinessProcessingTime

protected long totalBusinessProcessingTime

totalProcessingTime

protected long totalProcessingTime

sessionList

protected ArrayList<JSessionSwitch> 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.

Specified by:
stop in interface BeanFactory

syncDirty

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

Specified by:
syncDirty in interface BeanFactory
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

Specified by:
getHome in interface BeanFactory
Returns:
the home if exist

getLocalHome

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

Specified by:
getLocalHome in interface BeanFactory
Returns:
the local home if exist

createEJB

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

Returns:
a SessionSwitch
Throws:
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)
set the current timeout value for Jmx

Parameters:
timeout - in seconds

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 long getNumberOfCalls()
Returns:
Total number of calls on this EJB.

setNumberOfCalls

public void setNumberOfCalls(long 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.

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.

accept

public boolean accept(org.ow2.util.event.api.IEvent event)
Specified by:
accept in interface org.ow2.util.event.api.IEventListener

getPriority

public org.ow2.util.event.api.EventPriority getPriority()
Specified by:
getPriority in interface org.ow2.util.event.api.IEventListener

handle

public void handle(org.ow2.util.event.api.IEvent event)
Specified by:
handle in interface org.ow2.util.event.api.IEventListener

getJContext

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

createNewSession

protected abstract JSessionSwitch createNewSession()
                                            throws RemoteException
Throws:
RemoteException


Copyright © 2010 OW2 Consortium. All Rights Reserved.