org.jboss.ejb.plugins.lock
Class NonReentrantLock

java.lang.Object
  extended byorg.jboss.ejb.plugins.lock.NonReentrantLock
All Implemented Interfaces:
Resource (src)

public class NonReentrantLock
extends java.lang.Object
implements Resource (src)

Implementents a non reentrant lock with deadlock detection

It will throw a ReentranceException if the same thread tries to acquire twice or the same transaction tries to acquire twice


Nested Class Summary
static class NonReentrantLock.ReentranceException (src)
           
 
Field Summary
protected  int held
           
protected  Transaction (src) holdingTx
           
protected  java.lang.Object lock
           
protected  java.lang.Thread lockHolder
           
 
Constructor Summary
NonReentrantLock()
           
 
Method Summary
protected  boolean acquireNonReentrant(long waitTime, Transaction (src)  miTx)
           
protected  boolean acquireReentrant(long waitTime, Transaction (src)  miTx)
           
 boolean attempt(long waitTime, Transaction (src)  miTx, boolean nonReentrant)
           
 java.lang.Object getResourceHolder()
           
 void release(boolean nonReentrant)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

lockHolder

protected java.lang.Thread lockHolder

lock

protected java.lang.Object lock

held

protected volatile int held

holdingTx

protected Transaction (src)  holdingTx
Constructor Detail

NonReentrantLock

public NonReentrantLock()
Method Detail

getResourceHolder

public java.lang.Object getResourceHolder()
Specified by:
getResourceHolder in interface Resource (src)

acquireNonReentrant

protected boolean acquireNonReentrant(long waitTime,
                                      Transaction (src)  miTx)
                               throws ApplicationDeadlockException (src) ,
                                      java.lang.InterruptedException,
                                      NonReentrantLock.ReentranceException (src) 
Throws:
ApplicationDeadlockException (src)
java.lang.InterruptedException
NonReentrantLock.ReentranceException (src)

acquireReentrant

protected boolean acquireReentrant(long waitTime,
                                   Transaction (src)  miTx)
                            throws ApplicationDeadlockException (src) ,
                                   java.lang.InterruptedException,
                                   NonReentrantLock.ReentranceException (src) 
Throws:
ApplicationDeadlockException (src)
java.lang.InterruptedException
NonReentrantLock.ReentranceException (src)

attempt

public boolean attempt(long waitTime,
                       Transaction (src)  miTx,
                       boolean nonReentrant)
                throws ApplicationDeadlockException (src) ,
                       java.lang.InterruptedException,
                       NonReentrantLock.ReentranceException (src) 
Throws:
ApplicationDeadlockException (src)
java.lang.InterruptedException
NonReentrantLock.ReentranceException (src)

release

public void release(boolean nonReentrant)