| java.lang.Object org.objectweb.jonas_ejb.container.JEntitySwitch
All known Subclasses: org.objectweb.jonas_ejb.container.JEntitySwitchCST, org.objectweb.jonas_ejb.container.JEntitySwitchCRC, org.objectweb.jonas_ejb.container.JEntitySwitchDB,
JEntitySwitch | abstract public class JEntitySwitch (Code) | | 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 author: Philippe Coq |
Field Summary | |
final static int | ALL_DONE | final protected static long | FEW_SECONDS | final static int | NOT_DONE | final static int | STORED | protected JEntityFactory | bf | protected ArrayList | blockedtx | protected int | countIH | protected int | countIT | protected static int | counter | protected long | deadlockTimeout | protected long | estimestamp timestamp used to free objects when not used for a specified time. | protected String | ident | protected boolean | inDirtyList True if this instance may have been modified outside transactions. | protected long | inactivityTimeout time in millisec. | protected boolean | isdetached True if this object is no longer referenced by its factory, i.e. | protected boolean | isremoved True if this object will be garbaged and must not be used any longer. | protected boolean | lazyregister true if we can differ the registration at first write. | protected JEntityLocal | local The EJBLocalObject, or null if bean has no local interface. | protected int | lockpolicy Lock policy used for this entity bean. | protected boolean | mustReload True if instance has been modified by a Transaction. | 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.
Only used when txUpdate is false (i.e. | protected TimerService | myTimerService | protected Object | pk The Primary Key for this bean instance. | protected long | readTimeout time in millisec. | protected boolean | reentrant reentrant=true if a bean instance can be accessed concurrently
in the same transaction, or outside transaction. | protected JEntityRemote | remote The EJBObject, or null if bean has no remote interface. | protected Transaction | runningtx transaction on which a Context has been registered. | protected boolean | shared shared=true if the bean can be modify outside this container. | protected boolean | todiscard True when context/instance has been discarded, to avoids that passivate
store its state on storage. | protected boolean | txUpdates True if a transaction is mandatory for all modifying methods. | protected int | waiters | protected Transaction | writingtx |
Method Summary | |
public void | bindICtx(Transaction tx, JEntityContext bctx) bind a JEntityContext for a create method. | protected void | detachPk() Detach entity switch from PK list. | protected void | discardContext(Transaction tx, boolean forgetpk, boolean pool) Discard instance/Context and free all objects. | abstract public void | endIH() | public synchronized void | forceDiscardICtx(Transaction tx) | public JFactory | getBeanFactory() | public Transaction | getBlockingTx(Transaction testedtx) Look if the specified transaction is blocked. | abstract JEntityContext | getContext4Tx(Transaction tx) | public TimerService | getEntityTimerService() | public JEntityContext | getICtx(Transaction tx, JEntityContext newctx) bind a JEntityContext for a remove method. | public JEntityContext | getICtx(Transaction tx, boolean checkr) Get a context/instance associated with this transaction Called at each
request on the bean (including remove)
Parameters: tx - - the Transaction object Parameters: checkr - - true if we must check non-reentrance. | public JEntityLocal | getLocal() | public int | getPolicy() | public Object | getPrimaryKey() | public JEntityRemote | getRemote() | abstract public int | getState() State of this instance. | public void | init(JEntityFactory bf, Object pk) constructor. | abstract protected void | initpolicy(JEntityFactory bf) | public boolean | lazyRegistering() | public synchronized JEntityContext | mapICtx(Transaction tx, JEntityContext bctx, boolean forced, boolean holdit, boolean checkreentrance) Map a context and its instance.
Parameters: tx - - the Transaction object Parameters: bctx - - the JEntityContext to bind if not null Parameters: forced - - force to take this context. | public void | notifyTimeout(Timer timer) | public synchronized void | notifyWriting(Transaction tx, JEntityContext bctx) This transaction has just modified this instance. | abstract public int | passivateIH(boolean store, boolean passivate) | protected void | registerCtx(Transaction tx, JEntityContext bctx) register a Context on the transaction, as a Synchronization. | public synchronized void | releaseICtx(Transaction tx, boolean discard) Release a context/instance at end of request. | abstract void | removeContext4Tx(Transaction tx) | abstract void | setContext4Tx(Transaction tx, JEntityContext ctx) | public synchronized boolean | terminate(Transaction tx) Release completely this object, since another one will be used. | public synchronized boolean | tryBindICtx(Transaction tx, JEntityContext bctx, boolean simple) Try to bind a JEntityContext if none already bound. | public synchronized void | txCompleted(Transaction tx, boolean committed) This transaction is now over. | abstract void | waitmyturn(Transaction tx) |
ALL_DONE | final static int ALL_DONE(Code) | | |
FEW_SECONDS | final protected static long FEW_SECONDS(Code) | | |
NOT_DONE | final static int NOT_DONE(Code) | | |
STORED | final static int STORED(Code) | | |
blockedtx | protected ArrayList blockedtx(Code) | | List of all transactions currently blocked by runningtx
|
countIH | protected int countIH(Code) | | nb of non transacted requests running
|
countIT | protected int countIT(Code) | | nb of transacted requests running
|
counter | protected static int counter(Code) | | |
deadlockTimeout | protected long deadlockTimeout(Code) | | |
estimestamp | protected long estimestamp(Code) | | timestamp used to free objects when not used for a specified time.
|
inDirtyList | protected boolean inDirtyList(Code) | | True if this instance may have been modified outside transactions. Avoids
to put it twice in dirty list.
Only used for CS policy (non transacted modifying methods)
|
inactivityTimeout | protected long inactivityTimeout(Code) | | time in millisec. to keep objects in memory when not used.
After this time, objects are freed, if instances have been passivated
before.
|
isdetached | protected boolean isdetached(Code) | | True if this object is no longer referenced by its factory, i.e.
it is no longer in the PK list.
|
isremoved | protected boolean isremoved(Code) | | True if this object will be garbaged and must not be used any longer.
|
lazyregister | protected boolean lazyregister(Code) | | true if we can differ the registration at first write.
Cannot be true if shared or prefetch.
|
local | protected JEntityLocal local(Code) | | The EJBLocalObject, or null if bean has no local interface.
|
lockpolicy | protected int lockpolicy(Code) | | Lock policy used for this entity bean. Possible values are :
0 = LOCK_CONTAINER_READ_UNCOMMITTED (1 instance)
1 = LOCK_CONTAINER_SERIALIZED (1 instance)
2 = LOCK_CONTAINER_READ_COMMITTED (2 instances)
3 = LOCK_DATABASE (n instances)
4 = LOCK_READ_ONLY (1 instance)
5 = LOCK_CONTAINER_READ_WRITE (1 instance)
6 = LOCK_CONTAINER_SERIALIZED_TRANSACTED (1 instance)
|
mustReload | protected boolean mustReload(Code) | | True if instance has been modified by a Transaction. This means that
reading outside transaction should reload it before use.
Only used for DB and CRC policies (non transacted instance)
|
mustStore | protected boolean mustStore(Code) | | True if a TX need this instance currently used outside tx When the last
release is done, we must store this instance.
Only used when txUpdate is false (i.e. CS policy)
|
myTimerService | protected TimerService myTimerService(Code) | | The Timer Service
|
pk | protected Object pk(Code) | | The Primary Key for this bean instance.
|
readTimeout | protected long readTimeout(Code) | | time in millisec. to keep objects in memory without rereading them
(for RO policy only)
|
reentrant | protected boolean reentrant(Code) | | reentrant=true if a bean instance can be accessed concurrently
in the same transaction, or outside transaction.
|
remote | protected JEntityRemote remote(Code) | | The EJBObject, or null if bean has no remote interface.
|
runningtx | protected Transaction runningtx(Code) | | transaction on which a Context has been registered.
Registration may be differed at first write in case of lazyregister=true.
This ref is reset to null when the transaction is completed.
|
shared | protected boolean shared(Code) | | shared=true if the bean can be modify outside this container.
|
todiscard | protected boolean todiscard(Code) | | True when context/instance has been discarded, to avoids that passivate
store its state on storage.
|
txUpdates | protected boolean txUpdates(Code) | | True if a transaction is mandatory for all modifying methods. In this
case, all methods outside tranction is considered as read-only.
Only CS policy has txUpdates=false.
|
waiters | protected int waiters(Code) | | nb of threads waiting (synchronization)
|
writingtx | protected Transaction writingtx(Code) | | transaction that has modified an instance
|
JEntitySwitch | public JEntitySwitch()(Code) | | empty constructor. Object is initialized via init() because it is
implemented differently according to jorm mappers.
|
bindICtx | public void bindICtx(Transaction tx, JEntityContext bctx)(Code) | | bind a JEntityContext for a create method.
Parameters: tx - - the Transaction object Parameters: bctx - - the JEntityContext to bind |
detachPk | protected void detachPk()(Code) | | Detach entity switch from PK list.
This should trigger cleaning memory from all these objects by garbage collector.
|
discardContext | protected void discardContext(Transaction tx, boolean forgetpk, boolean pool)(Code) | | Discard instance/Context and free all objects.
Parameters: tx - - the Transaction object Parameters: forgetpk - - true if remove pk from the list Parameters: pool - - true if instance can be pooled. |
endIH | abstract public void endIH()(Code) | | Called only for CS policy, after passivateIH
|
forceDiscardICtx | public synchronized void forceDiscardICtx(Transaction tx)(Code) | | |
getBlockingTx | public Transaction getBlockingTx(Transaction testedtx)(Code) | | Look if the specified transaction is blocked.
Parameters: testedtx - Transaction we look for The blocking transaction |
getEntityTimerService | public TimerService getEntityTimerService()(Code) | | Obtains the TimerService associated for this Entity Bean (one / pk)
a JTimerService instance. |
getICtx | public JEntityContext getICtx(Transaction tx, JEntityContext newctx)(Code) | | bind a JEntityContext for a remove method. called in case of remove(pk)
or remove(handle)
Parameters: tx - - the Transaction object Parameters: newctx - - the JEntityContext to bind the BeanContext |
getICtx | public JEntityContext getICtx(Transaction tx, boolean checkr)(Code) | | Get a context/instance associated with this transaction Called at each
request on the bean (including remove)
Parameters: tx - - the Transaction object Parameters: checkr - - true if we must check non-reentrance. the BeanContext |
getPolicy | public int getPolicy()(Code) | | lock policy for this bean |
getPrimaryKey | public Object getPrimaryKey()(Code) | | the Primary Key Object for this instance. |
getState | abstract public int getState()(Code) | | 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 avoidjadmin blocks |
init | public void init(JEntityFactory bf, Object pk)(Code) | | constructor. A new object is build when a new PK is known in the
container, either when a new bean is created, or when a find occurs. For
create(), PK is not known yet when this object is build.
Parameters: bf - The Entity Factory Parameters: pk - The Primary Key |
lazyRegistering | public boolean lazyRegistering()(Code) | | true if lazy registering enabled. |
mapICtx | public synchronized JEntityContext mapICtx(Transaction tx, JEntityContext bctx, boolean forced, boolean holdit, boolean checkreentrance)(Code) | | Map a context and its instance.
Parameters: tx - - the Transaction object Parameters: bctx - - the JEntityContext to bind if not null Parameters: forced - - force to take this context. (case of create) Parameters: holdit - - increment count to hold it, a release will be calledlater. Parameters: checkreentrance - - true if we must check non-reentrance. JEntityContext actually mapped |
notifyTimeout | public void notifyTimeout(Timer timer)(Code) | | Notify a timeout for this bean and this Pk
Parameters: timer - timer whose expiration caused this notification. |
notifyWriting | public synchronized void notifyWriting(Transaction tx, JEntityContext bctx)(Code) | | This transaction has just modified this instance. (CMP2 only)
Called only if lazyRegister is set and not RO policy.
Parameters: tx - transaction |
passivateIH | abstract public int passivateIH(boolean store, boolean passivate)(Code) | | Parameters: store - True if want to store instance first (CS policy) Parameters: passivate - True if we want to passivate instance result of operation: ALL_DONE, STORED, or NOT_DONE |
registerCtx | protected void registerCtx(Transaction tx, JEntityContext bctx)(Code) | | register a Context on the transaction, as a Synchronization. this will be
used later to store instance state when needed : before a finder, or at
beforeCompletion, and to release instance at commit.
Parameters: tx - Transaction object Parameters: bctx - The Context to be registered |
releaseICtx | public synchronized void releaseICtx(Transaction tx, boolean discard)(Code) | | Release a context/instance at end of request.
Parameters: tx - - transaction associated to this context Parameters: discard - - instance must be discarded |
removeContext4Tx | abstract void removeContext4Tx(Transaction tx)(Code) | | |
terminate | public synchronized boolean terminate(Transaction tx)(Code) | | Release completely this object, since another one will be used.
this occurs in case of create, when another EntitySwitch exist
already.
Parameters: tx - - the Transaction object |
tryBindICtx | public synchronized boolean tryBindICtx(Transaction tx, JEntityContext bctx, boolean simple) throws ObjectNotFoundException(Code) | | Try to bind a JEntityContext if none already bound. Called by finder
methods. This is actually kind of optimization.
Can be bypassed if problems: just return false.
Parameters: tx - - the Transaction object Parameters: bctx - The Entity Context Parameters: simple - True if simple finder method true if context has been bound to this EntitySwitch. |
txCompleted | public synchronized void txCompleted(Transaction tx, boolean committed)(Code) | | This transaction is now over. We can dispose of the instance for another
transaction or discard it.
A special implementation exists for RO policy
Parameters: tx - the transaction object Parameters: committed - true if transaction was committed. |
waitmyturn | abstract void waitmyturn(Transaction tx)(Code) | | |
|
|