org.objectweb.jonas_ejb.container
Class JEntitySwitchCS

java.lang.Object
  extended byorg.objectweb.jonas_ejb.container.JEntitySwitch
      extended byorg.objectweb.jonas_ejb.container.JEntitySwitchCS

public class JEntitySwitchCS
extends JEntitySwitch

JEntitySwitch is used internally to synchronize accesses to the entity context and thus to the entity bean instance. All parts common to EJBObject and EJBLocalObject should be here. Different policies can be applied to manage context/instance pairs: - only 1 pair (container manages the transaction isolation) - 1 pair for each transaction (transaction isolation managed by DataBase) - 2 pairs (1 for transactional accesses, 1 for non transaction accesses)

Author:
Philippe Durieux, Philippe Coq

Field Summary
protected  JEntityContext itContext
          unique EntityContext
protected static int maxtime
           
protected  boolean mustStore
          True if a TX need this instance currently used outside tx When the last release is done, we must store this instance.
protected  boolean reentrant
          reentrant=true if a bean instance can be accessed concurrently.
 
Fields inherited from class org.objectweb.jonas_ejb.container.JEntitySwitch
bf, blockedtx, counter, countIH, discarded, ident, inDirtyList, isremoved, lazyregister, local, lockpolicy, mustReload, myTimerService, pk, remote, runningtx, shared, txUpdates, waiters, writingtx
 
Constructor Summary
JEntitySwitchCS()
          empty constructor.
 
Method Summary
 void endIH()
          Instance is ready to use for new transaction.
protected  JEntityContext getContext4Tx(javax.transaction.Transaction tx)
           
 int getState()
           
protected  void initpolicy(JEntityFactory bf)
           
 void notifyWriting(javax.transaction.Transaction tx, JEntityContext bctx)
           
 boolean passivateIH(boolean passivation)
          try to passivate IH (called from swapper)
 void releaseICtx(javax.transaction.Transaction tx)
          Release a context/instance at end of request.
protected  void removeContext4Tx(javax.transaction.Transaction tx)
           
protected  void setContext4Tx(javax.transaction.Transaction tx, JEntityContext ctx)
           
 void waitmyturn(javax.transaction.Transaction tx)
           
 
Methods inherited from class org.objectweb.jonas_ejb.container.JEntitySwitch
bindICtx, discardICtx, getBeanFactory, getBlockedTx, getBlockingTx, getEntityTimerService, getICtx, getICtx, getLocal, getPolicy, getPrimaryKey, getRemote, init, mapICtx, noLongerUsed, notifyTimeout, registerCtx, terminate, tryBindICtx, txCompleted
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

itContext

protected JEntityContext itContext
unique EntityContext


reentrant

protected boolean reentrant
reentrant=true if a bean instance can be accessed concurrently. this is only pertinent outside transactions.


mustStore

protected boolean mustStore
True if a TX need this instance currently used outside tx When the last release is done, we must store this instance.


maxtime

protected static int maxtime
Constructor Detail

JEntitySwitchCS

public JEntitySwitchCS()
empty constructor. Object is initialized via init() because it is implemented differently according to jorm mappers.

Method Detail

initpolicy

protected void initpolicy(JEntityFactory bf)
Specified by:
initpolicy in class JEntitySwitch

getContext4Tx

protected JEntityContext getContext4Tx(javax.transaction.Transaction tx)

setContext4Tx

protected void setContext4Tx(javax.transaction.Transaction tx,
                             JEntityContext ctx)

removeContext4Tx

protected void removeContext4Tx(javax.transaction.Transaction tx)

waitmyturn

public void waitmyturn(javax.transaction.Transaction tx)

releaseICtx

public void releaseICtx(javax.transaction.Transaction tx)
Release a context/instance at end of request.

Specified by:
releaseICtx in class JEntitySwitch
Parameters:
tx - - transaction associated to this context

passivateIH

public boolean passivateIH(boolean passivation)
try to passivate IH (called from swapper)

Specified by:
passivateIH in class JEntitySwitch
Parameters:
passivation - false if only store bean state.
Returns:
false if instance still in memory (busy for example)

endIH

public void endIH()
Instance is ready to use for new transaction.

Specified by:
endIH in class JEntitySwitch

notifyWriting

public void notifyWriting(javax.transaction.Transaction tx,
                          JEntityContext bctx)
Specified by:
notifyWriting in class JEntitySwitch

getState

public int getState()
Specified by:
getState in class JEntitySwitch
Returns:
State of this instance. State values are 0=in-tx, 1=out-tx, 2=idle, 3=passive, 4=removed. we don't synchronize this method to avoid jadmin blocks