Save This Page
Home » jboss-5.0.0.CR1-src » org » jboss » ejb » plugins » lock » [javadoc | source]
org.jboss.ejb.plugins.lock
public class: QueuedPessimisticEJBLock [javadoc | source]
java.lang.Object
   org.jboss.ejb.plugins.lock.BeanLockSupport
      org.jboss.ejb.plugins.lock.QueuedPessimisticEJBLock

All Implemented Interfaces:
    Resource, BeanLockExt

Direct Known Subclasses:
    QueuedPessimisticEJBLockNoADE

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. As of 04/10/2002, you can now specify in jboss.xml method attributes that define methods as read-only. read-only methods(and read-only beans) will release transactional locks at the end of the invocation. This decreases likelyhood of deadlock and increases performance. FIXME marcf: we should get solid numbers on this locking, bench in multi-thread environments We need someone with serious SUN hardware to run this lock into the ground

Field Summary
protected  LockMonitor lockMonitor     
protected  boolean deadlockDetection    A flag that disables the deadlock detection check 
Fields inherited from org.jboss.ejb.plugins.lock.BeanLockSupport:
container,  refs,  id,  log,  tx,  synched,  synchedDepth,  txTimeout
Method from org.jboss.ejb.plugins.lock.QueuedPessimisticEJBLock Summary:
doSchedule,   endInvocation,   endTransaction,   getDeadlockDetection,   getTxLock,   isTxExpired,   nextTransaction,   removeRef,   schedule,   setContainer,   setDeadlockDetection,   toString,   waitForTx,   wontSynchronize
Methods from org.jboss.ejb.plugins.lock.BeanLockSupport:
addRef,   attemptSync,   endInvocation,   endTransaction,   getId,   getRefs,   getResourceHolder,   getTransaction,   releaseSync,   removeRef,   schedule,   setContainer,   setId,   setTimeout,   setTransaction,   sync,   wontSynchronize
Methods from java.lang.Object:
equals,   getClass,   hashCode,   notify,   notifyAll,   toString,   wait,   wait,   wait
Method from org.jboss.ejb.plugins.lock.QueuedPessimisticEJBLock Detail:
 protected boolean doSchedule(Invocation mi) throws Exception 
    doSchedule(Invocation) 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.
 public  void endInvocation(Invocation mi) 
    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
 public  void endTransaction(Transaction transaction) 
 public boolean getDeadlockDetection() 
 protected QueuedPessimisticEJBLock.TxLock getTxLock(Transaction miTx) 
 protected boolean isTxExpired(Transaction miTx) throws Exception 
 protected  void nextTransaction() 
 public  void removeRef() 
 public  void schedule(Invocation mi) throws Exception 
 public  void setContainer(Container container) 
 public  void setDeadlockDetection(boolean flag) 
 public String toString() 
 protected boolean waitForTx(Transaction miTx,
    boolean trace) throws Exception 
    Wait until no other transaction is running with this lock.
 public  void wontSynchronize(Transaction trasaction)