|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.ow2.jonas.lib.ejb21.JEntitySwitch
public abstract class 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)
Field Summary | |
---|---|
protected JEntityFactory |
bf
The Factory for this bean |
protected ArrayList<Transaction> |
blockedtx
List of all transactions currently blocked by runningtx |
protected static int |
counter
|
protected int |
countIH
nb of non transacted requests running |
protected int |
countIT
nb of transacted requests running |
protected long |
deadlockTimeout
|
protected long |
estimestamp
timestamp used to free objects when not used for a specified time. |
protected static long |
FEW_SECONDS
|
protected String |
ident
|
protected long |
inactivityTimeout
time in millisec. |
protected boolean |
inDirtyList
True if this instance may have been modified outside transactions. |
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. |
protected TimerService |
myTimerService
The Timer Service |
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
nb of threads waiting (synchronization) |
protected Transaction |
writingtx
transaction that has modified an instance |
Constructor Summary | |
---|---|
JEntitySwitch()
empty constructor. |
Method Summary | |
---|---|
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 void |
endIH()
Called only for CS policy, after passivateIH |
void |
forceDiscardICtx(Transaction tx)
|
JFactory |
getBeanFactory()
|
Transaction |
getBlockingTx(Transaction testedtx)
Look if the specified transaction is blocked. |
TimerService |
getEntityTimerService()
Obtains the TimerService associated for this Entity Bean (one / pk) |
JEntityContext |
getICtx(Transaction tx,
boolean checkr)
Get a context/instance associated with this transaction Called at each request on the bean (including remove) |
JEntityContext |
getICtx(Transaction tx,
JEntityContext newctx)
bind a JEntityContext for a remove method. |
JEntityLocal |
getLocal()
|
int |
getPolicy()
|
Object |
getPrimaryKey()
|
JEntityRemote |
getRemote()
|
abstract int |
getState()
|
void |
init(JEntityFactory bf,
Object pk)
constructor. |
protected abstract void |
initpolicy(JEntityFactory bf)
|
boolean |
lazyRegistering()
|
JEntityContext |
mapICtx(Transaction tx,
JEntityContext bctx,
boolean forced,
boolean holdit,
boolean checkreentrance)
Map a context and its instance. |
void |
notifyTimeout(Timer timer)
Notify a timeout for this bean and this Pk |
void |
notifyWriting(Transaction tx,
JEntityContext bctx)
This transaction has just modified this instance. |
abstract int |
passivateIH(boolean store,
boolean passivate)
|
protected boolean |
registerCtx(Transaction tx,
JEntityContext bctx)
register a Context on the transaction, as a Synchronization. |
void |
releaseICtx(Transaction tx,
boolean discard)
Release a context/instance at end of request. |
boolean |
terminate(Transaction tx)
Release completely this object, since another one will be used. |
boolean |
tryBindICtx(Transaction tx,
JEntityContext bctx,
boolean simple)
Try to bind a JEntityContext if none already bound. |
void |
txCompleted(Transaction tx,
boolean committed)
This transaction is now over. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected JEntityFactory bf
protected Object pk
protected JEntityLocal local
protected JEntityRemote remote
protected long inactivityTimeout
protected long readTimeout
protected boolean shared
protected int lockpolicy
protected boolean txUpdates
protected TimerService myTimerService
protected int countIH
protected int countIT
protected int waiters
protected boolean inDirtyList
protected boolean mustReload
protected boolean mustStore
protected boolean todiscard
protected Transaction runningtx
protected Transaction writingtx
protected long deadlockTimeout
protected ArrayList<Transaction> blockedtx
protected boolean isremoved
protected boolean isdetached
protected static int counter
protected String ident
protected long estimestamp
protected static final long FEW_SECONDS
protected boolean lazyregister
protected boolean reentrant
Constructor Detail |
---|
public JEntitySwitch()
Method Detail |
---|
protected abstract void initpolicy(JEntityFactory bf)
public abstract int passivateIH(boolean store, boolean passivate)
store
- True if want to store instance first (CS policy)passivate
- True if we want to passivate instance
public abstract void endIH()
public void init(JEntityFactory bf, Object pk)
bf
- The Entity Factorypk
- The Primary Keypublic boolean lazyRegistering()
public JEntityLocal getLocal()
public JEntityRemote getRemote()
public TimerService getEntityTimerService()
public void notifyWriting(Transaction tx, JEntityContext bctx)
tx
- transactionpublic void notifyTimeout(Timer timer)
timer
- timer whose expiration caused this notification.public Object getPrimaryKey()
public void bindICtx(Transaction tx, JEntityContext bctx)
tx
- - the Transaction objectbctx
- - the JEntityContext to bindpublic boolean tryBindICtx(Transaction tx, JEntityContext bctx, boolean simple) throws ObjectNotFoundException
tx
- - the Transaction objectbctx
- The Entity Contextsimple
- True if simple finder method
ObjectNotFoundException
public JEntityContext getICtx(Transaction tx, JEntityContext newctx)
tx
- - the Transaction objectnewctx
- - the JEntityContext to bind
public JEntityContext getICtx(Transaction tx, boolean checkr)
tx
- - the Transaction objectcheckr
- - true if we must check non-reentrance.
public boolean terminate(Transaction tx)
tx
- - the Transaction objectpublic JEntityContext mapICtx(Transaction tx, JEntityContext bctx, boolean forced, boolean holdit, boolean checkreentrance)
tx
- - the Transaction objectbctx
- - the JEntityContext to bind if not nullforced
- - force to take this context. (case of create)holdit
- - increment count to hold it, a release will be called
later.checkreentrance
- - true if we must check non-reentrance.
public Transaction getBlockingTx(Transaction testedtx)
testedtx
- Transaction we look for
public void releaseICtx(Transaction tx, boolean discard)
tx
- - transaction associated to this contextdiscard
- - instance must be discardedpublic void forceDiscardICtx(Transaction tx)
public void txCompleted(Transaction tx, boolean committed)
tx
- the transaction objectcommitted
- true if transaction was committed.protected boolean registerCtx(Transaction tx, JEntityContext bctx)
tx
- Transaction objectbctx
- The Context to be registered
protected void detachPk()
protected void discardContext(Transaction tx, boolean forgetpk, boolean pool)
tx
- - the Transaction objectforgetpk
- - true if remove pk from the listpool
- - true if instance can be pooled.public int getPolicy()
public abstract int getState()
public JFactory getBeanFactory()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |