org.objectweb.jonas_ejb.container
Class JEntitySwitchCRW

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

public class JEntitySwitchCRW
extends JEntitySwitch

Container Optimistic lock-policy. Only 1 thread can write. All other threads can read, without waiting for a committed state. There is no wait.

Author:
Philippe Durieux

Field Summary
protected  JEntityContext itContext
          unique EntityContext
protected static int maxtime
           
 
Fields inherited from class org.objectweb.jonas_ejb.container.JEntitySwitch
bf, blockedtx, counter, countIH, countIT, ident, inactivityTimeout, inDirtyList, isremoved, lazyregister, local, lockpolicy, mustReload, mustStore, myTimerService, pk, reentrant, remote, runningtx, shared, timestamp, todiscard, txUpdates, waiters, writingtx
 
Constructor Summary
JEntitySwitchCRW()
          empty constructor.
 
Method Summary
 void endIH()
           
protected  JEntityContext getContext4Tx(javax.transaction.Transaction tx)
           
 int getState()
           
protected  void initpolicy(JEntityFactory bf)
           
 JEntityContext mapICtx(javax.transaction.Transaction tx, JEntityContext bctx, boolean forced, boolean holdit, boolean notused)
          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)
          try to passivate instances
protected  void removeContext4Tx(javax.transaction.Transaction tx)
           
protected  void setContext4Tx(javax.transaction.Transaction tx, JEntityContext ctx)
           
 void waitmyturn(javax.transaction.Transaction tx)
          Must wait only if writingtx is not null, because we must wait for the writing transaction to finish.
 
Methods inherited from class org.objectweb.jonas_ejb.container.JEntitySwitch
bindICtx, discardContext, discardICtx, getBeanFactory, getBlockedTx, getBlockingTx, getEntityTimerService, getICtx, getICtx, getLocal, getPolicy, getPrimaryKey, getRemote, init, lazyRegistering, notifyTimeout, registerCtx, releaseICtx, 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


maxtime

protected static int maxtime
Constructor Detail

JEntitySwitchCRW

public JEntitySwitchCRW()
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)
Must wait only if writingtx is not null, because we must wait for the writing transaction to finish. In all other cases, don't wait to allow more parallellism.


mapICtx

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

Overrides:
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.
notused - - true if we must check non-reentrance.
Returns:
JEntityContext actually mapped

passivateIH

public boolean passivateIH(boolean passivation)
try to passivate instances

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()
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

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