org.objectweb.jonas_ejb.container
Class JEntitySwitchDB

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

public class JEntitySwitchDB
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 ihContext
          EntityContext for non-transacted requests
protected  java.util.HashMap itsContext
          Map of EntityContext's for transactions Key is the Transaction.
 
Fields inherited from class org.objectweb.jonas_ejb.container.JEntitySwitch
bf, blockedtx, counter, countIH, discarded, ident, inDirtyList, lazyregister, local, lockpolicy, mustReload, myTimerService, pk, remote, runningtx, shared, txUpdates, waiters, writingtx
 
Constructor Summary
JEntitySwitchDB()
          empty constructor.
 
Method Summary
 void endIH()
           
protected  JEntityContext getContext4Tx(javax.transaction.Transaction tx)
           
protected  void initpolicy(JEntityFactory bf)
           
 JEntityContext mapICtx(javax.transaction.Transaction tx, JEntityContext bctx, boolean forced, boolean holdit)
          Map a context and its instance.
 void notifyWriting(javax.transaction.Transaction tx, JEntityContext bctx)
          This transaction has just modified this instance.
 boolean passivateIH(boolean passivation)
           
 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)
           
 
Methods inherited from class org.objectweb.jonas_ejb.container.JEntitySwitch
bindICtx, discardICtx, getBeanFactory, getBlockedTx, getBlockingTx, getEntityTimerService, getICtx, getICtx, getLocal, getPolicy, getPrimaryKey, getRemote, getState, init, noLongerUsed, notifyTimeout, registerCtx, tryBindICtx, txCompleted
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ihContext

protected JEntityContext ihContext
EntityContext for non-transacted requests


itsContext

protected java.util.HashMap itsContext
Map of EntityContext's for transactions Key is the Transaction.

Constructor Detail

JEntitySwitchDB

public JEntitySwitchDB()
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)
Parameters:
tx - The Transaction
Returns:
the JEntityContext used for this tx

setContext4Tx

protected void setContext4Tx(javax.transaction.Transaction tx,
                             JEntityContext ctx)
Parameters:
tx - The Transaction

removeContext4Tx

protected void removeContext4Tx(javax.transaction.Transaction tx)

mapICtx

public JEntityContext mapICtx(javax.transaction.Transaction tx,
                              JEntityContext bctx,
                              boolean forced,
                              boolean holdit)
Map a context and its instance.

Specified by:
mapICtx in class JEntitySwitch
Parameters:
tx - - the Transaction object
bctx - - the JEntityContext to bind if not null
forced - - force to take this context. (case of create)
holdit - - increment count to hold it, a release will be called later.
Returns:
JEntityContext actually mapped

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)
Specified by:
passivateIH in class JEntitySwitch

endIH

public void endIH()
Specified by:
endIH in class JEntitySwitch

notifyWriting

public void notifyWriting(javax.transaction.Transaction tx,
                          JEntityContext bctx)
This transaction has just modified this instance. (CMP2 only)

Specified by:
notifyWriting in class JEntitySwitch
Parameters:
tx - transaction