org.jboss.ejb.plugins.lock
Class SimpleReadWriteEJBLock

java.lang.Object
  extended byorg.jboss.ejb.plugins.lock.BeanLockSupport (src) 
      extended byorg.jboss.ejb.plugins.lock.SimpleReadWriteEJBLock
All Implemented Interfaces:
BeanLock (src) , BeanLockExt (src) , Resource (src)

public class SimpleReadWriteEJBLock
extends BeanLockSupport (src)

This lock allows multiple read locks concurrently. Once a writer has requested the lock, future read-lock requests whose transactions do not already have the read lock will block until all writers are done -- then all the waiting readers will concurrently go (depending on the reentrant setting / methodLock). A reader who promotes gets first crack at the write lock -- ahead of other waiting writers. If there is already a reader that is promoting, we throw an inconsistent read exception. Of course, writers have to wait for all read-locks to release before taking the write lock.


Field Summary
 
Fields inherited from class org.jboss.ejb.plugins.lock.BeanLockSupport (src)
container, id, refs, synched, synchedDepth, tx, txTimeout
 
Constructor Summary
SimpleReadWriteEJBLock()
           
 
Method Summary
 void endInvocation(Invocation (src)  mi)
          Callback to the BeanLock to inform it that a method invocation has ended.
 void endTransaction(Transaction (src)  transaction)
          Informs the lock that the given transaction has ended.
 void schedule(Invocation (src)  mi)
          This method implements the actual logic of the lock.
 void wontSynchronize(Transaction (src)  transaction)
          Signifies to the lock that the transaction will not Synchronize (Tx demarcation not seen).
 
Methods inherited from class org.jboss.ejb.plugins.lock.BeanLockSupport (src)
addRef, attemptSync, getId, getRefs, getResourceHolder, getTransaction, releaseSync, removeRef, setContainer, setId, setTimeout, setTransaction, sync
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SimpleReadWriteEJBLock

public SimpleReadWriteEJBLock()
Method Detail

schedule

public void schedule(Invocation (src)  mi)
Description copied from interface: BeanLock (src)
This method implements the actual logic of the lock. In the case of an EJB lock it must at least implement the serialization of calls

Specified by:
schedule in interface BeanLock (src)
Specified by:
schedule in class BeanLockSupport (src)

endTransaction

public void endTransaction(Transaction (src)  transaction)
Description copied from interface: BeanLock (src)
Informs the lock that the given transaction has ended.

Specified by:
endTransaction in interface BeanLock (src)
Specified by:
endTransaction in class BeanLockSupport (src)

wontSynchronize

public void wontSynchronize(Transaction (src)  transaction)
Description copied from interface: BeanLock (src)
Signifies to the lock that the transaction will not Synchronize (Tx demarcation not seen).

OSH: This method does not seem to be called from anywhere. What is it meant for? To be called on a timeout before the transaction has terminated?

Specified by:
wontSynchronize in interface BeanLock (src)
Specified by:
wontSynchronize in class BeanLockSupport (src)

endInvocation

public void endInvocation(Invocation (src)  mi)
Description copied from interface: BeanLock (src)
Callback to the BeanLock to inform it that a method invocation has ended. A common use of this method is to release a method lock.

Specified by:
endInvocation in interface BeanLock (src)
Specified by:
endInvocation in class BeanLockSupport (src)