org.ow2.jonas.lib.ejb21
Class JStatefulSwitch

java.lang.Object
  extended by org.ow2.jonas.lib.ejb21.JSessionSwitch
      extended by org.ow2.jonas.lib.ejb21.JStatefulSwitch
All Implemented Interfaces:
TimerEventListener

public class JStatefulSwitch
extends JSessionSwitch

JStatefulSwitch is the implementation of JSessionSwitch dedicated to the Stateful Session Bean.

Author:
Philippe Durieux

Field Summary
 
Fields inherited from class org.ow2.jonas.lib.ejb21.JSessionSwitch
bf, mylocal, myremote, mytimer
 
Constructor Summary
JStatefulSwitch(JStatefulFactory bf)
          constructor.
 
Method Summary
 void bindICtx(Transaction tx, JStatefulContext bctx)
          At each create, bind the Context to the transaction
 boolean canPassivate()
           
 void delistConnections(Transaction tx)
          delist all connections of the list at postInvoke.
 void enlistConnections(Transaction tx)
          enlist all connection of the list at preInvoke.
 JSessionContext getICtx(Transaction tx)
          At each business method, get a BeanContext to run it
 long getLastAccessTime()
           
 List<IResourceChecker> getResources()
           
 int getSessionId()
           
 JStatefulContext getStatefulContext()
           
 boolean isInTransaction()
          This is used for remove on stateful session beans only.
 boolean isPassivated()
           
 void noLongerUsed()
          This Session is no longer used: - unexport Remote Object - return the Session in the pool
 boolean passivate()
          Passivate this instance
 void releaseICtx(RequestCtx req, boolean discard)
          Release the Context after use.
 void saveBeanTx()
          Keep the bean opened transaction for later use in other methods.
 void saveOpenResources()
          Save the open resources.
 void setConnectionList(List cl)
          Save the Connection List after a create method.
 void setMustCommit(boolean mc)
          set a flag to remember that the transaction must be committed
 void timeoutExpired(Object arg)
          The session timeout has expired
 void txCompleted()
          End of Transaction
 
Methods inherited from class org.ow2.jonas.lib.ejb21.JSessionSwitch
getBeanFactory, getLocal, getRemote, startTimer, stopTimer
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JStatefulSwitch

public JStatefulSwitch(JStatefulFactory bf)
                throws RemoteException
constructor.

Parameters:
bf - The Bean Factory
sid - the unique statefulSession ident
Throws:
RemoteException
Method Detail

getSessionId

public int getSessionId()

canPassivate

public boolean canPassivate()
Returns:
true if instance can be passivated

isPassivated

public boolean isPassivated()
Returns:
true if instance has been passivated.

passivate

public boolean passivate()
Passivate this instance


setConnectionList

public void setConnectionList(List cl)
Save the Connection List after a create method.


enlistConnections

public void enlistConnections(Transaction tx)
enlist all connection of the list at preInvoke.

Specified by:
enlistConnections in class JSessionSwitch

delistConnections

public void delistConnections(Transaction tx)
delist all connections of the list at postInvoke.

Specified by:
delistConnections in class JSessionSwitch

timeoutExpired

public void timeoutExpired(Object arg)
The session timeout has expired

Parameters:
arg - Not Used.

getStatefulContext

public JStatefulContext getStatefulContext()
Returns:
the StatefulContext (for passivation)

getICtx

public JSessionContext getICtx(Transaction tx)
At each business method, get a BeanContext to run it

Specified by:
getICtx in class JSessionSwitch
Parameters:
tx - The Transaction Context
Returns:
The Session Context

bindICtx

public void bindICtx(Transaction tx,
                     JStatefulContext bctx)
At each create, bind the Context to the transaction

Parameters:
tx - The current Transaction Context
bctx - The Context to bind

releaseICtx

public void releaseICtx(RequestCtx req,
                        boolean discard)
Release the Context after use.

Specified by:
releaseICtx in class JSessionSwitch
Parameters:
tx - The current Transaction Context
discard - if true, instance must be discarded

noLongerUsed

public void noLongerUsed()
This Session is no longer used: - unexport Remote Object - return the Session in the pool

Specified by:
noLongerUsed in class JSessionSwitch

txCompleted

public void txCompleted()
End of Transaction


isInTransaction

public boolean isInTransaction()
This is used for remove on stateful session beans only.

Returns:
True if bean is participating in a client transaction

setMustCommit

public void setMustCommit(boolean mc)
set a flag to remember that the transaction must be committed

Specified by:
setMustCommit in class JSessionSwitch

saveBeanTx

public void saveBeanTx()
Keep the bean opened transaction for later use in other methods. Stateful session bean may open a transaction and use it in other methods. This is called at postInvoke

Specified by:
saveBeanTx in class JSessionSwitch

saveOpenResources

public void saveOpenResources()
Save the open resources.


getLastAccessTime

public long getLastAccessTime()
Returns:
the last access time in milliseconds

getResources

public List<IResourceChecker> getResources()
Returns:
list of resources.


Copyright © 2010 OW2 Consortium. All Rights Reserved.