org.jboss.ejb.plugins.lock
Class QueuedPessimisticEJBLock
java.lang.Object
|
+--org.jboss.ejb.plugins.lock.BeanLockSupport
|
+--org.jboss.ejb.plugins.lock.QueuedPessimisticEJBLock
- All Implemented Interfaces:
- BeanLock
- Direct Known Subclasses:
- MethodOnlyEJBLock
- public class QueuedPessimisticEJBLock
- extends BeanLockSupport
This class is holds threads awaiting the transactional lock to be free
in a fair FIFO transactional queue. Non-transactional threads
are also put in this wait queue as well. Unlike SimplePessimisticEJBLock which notifies all
threads on transaction completion, this class pops the next waiting transaction from the queue
and notifies only those threads waiting associated with that transaction. This
class should perform better than Simple on high contention loads.
Holds all locks for entity beans, not used for stateful.
All BeanLocks have a reference count.
When the reference count goes to 0, the lock is released from the
id -> lock mapping.
- Version:
- $Revision: 1.3.4.3 $
Revisions:
2001/08/03: billb
- Initial revision
- Author:
- Marc Fleury, Bill Burke
Method Summary |
protected boolean |
attemptMethodLock(MethodInvocation mi,
boolean trace)
Attempt to acquire a method lock. |
protected boolean |
doSchedule(MethodInvocation mi)
doSchedule(MethodInvocation)
doSchedule implements a particular policy for scheduling the threads coming in. |
void |
endTransaction(javax.transaction.Transaction transaction)
|
protected org.jboss.ejb.plugins.lock.QueuedPessimisticEJBLock.TxLock |
getTxLock(javax.transaction.Transaction miTx)
|
protected boolean |
isTxExpired(javax.transaction.Transaction miTx)
|
protected void |
nextTransaction()
|
void |
releaseMethodLock()
releaseMethodLock
if we reach the count of zero it means the instance is free from threads (and reentrency)
we wake up the next thread in the currentLock |
void |
removeRef()
|
void |
schedule(MethodInvocation mi)
|
protected boolean |
waitForTx(javax.transaction.Transaction miTx,
boolean trace)
Wait until no other transaction is running with this lock. |
void |
wontSynchronize(javax.transaction.Transaction trasaction)
|
Methods inherited from class org.jboss.ejb.plugins.lock.BeanLockSupport |
addMethodLock, addRef, getId, getNumMethodLocks, getRefs, getTransaction, isCallAllowed, isMethodLocked, releaseSync, setId, setReentrant, setTimeout, setTransaction, sync |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
QueuedPessimisticEJBLock
public QueuedPessimisticEJBLock()
getTxLock
protected org.jboss.ejb.plugins.lock.QueuedPessimisticEJBLock.TxLock getTxLock(javax.transaction.Transaction miTx)
isTxExpired
protected boolean isTxExpired(javax.transaction.Transaction miTx)
throws java.lang.Exception
schedule
public void schedule(MethodInvocation mi)
throws java.lang.Exception
- Overrides:
schedule
in class BeanLockSupport
doSchedule
protected boolean doSchedule(MethodInvocation mi)
throws java.lang.Exception
- doSchedule(MethodInvocation)
doSchedule implements a particular policy for scheduling the threads coming in.
There is always the spec required "serialization" but we can add custom scheduling in here
Synchronizing on lock: a failure to get scheduled must result in a wait() call and a
release of the lock. Schedulation must return with lock.
waitForTx
protected boolean waitForTx(javax.transaction.Transaction miTx,
boolean trace)
throws java.lang.Exception
- Wait until no other transaction is running with this lock.
- Returns:
- Returns true if this thread was scheduled in txWaitQueue
attemptMethodLock
protected boolean attemptMethodLock(MethodInvocation mi,
boolean trace)
throws java.lang.Exception
- Attempt to acquire a method lock.
nextTransaction
protected void nextTransaction()
endTransaction
public void endTransaction(javax.transaction.Transaction transaction)
- Overrides:
endTransaction
in class BeanLockSupport
wontSynchronize
public void wontSynchronize(javax.transaction.Transaction trasaction)
- Overrides:
wontSynchronize
in class BeanLockSupport
releaseMethodLock
public void releaseMethodLock()
- releaseMethodLock
if we reach the count of zero it means the instance is free from threads (and reentrency)
we wake up the next thread in the currentLock
- Overrides:
releaseMethodLock
in class BeanLockSupport
removeRef
public void removeRef()
- Overrides:
removeRef
in class BeanLockSupport
Copyright © 2000 The JBoss Organization. All Rights Reserved.