org.jboss.ejb.plugins.lock
Class  SimplePessimisticEJBLock
java.lang.Object
  |
  +--org.jboss.ejb.plugins.lock.BeanLockSupport
        |
        +--org.jboss.ejb.plugins.lock.SimplePessimisticEJBLock
- All Implemented Interfaces: 
- BeanLock
- public class SimplePessimisticEJBLock- extends BeanLockSupport
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.5.4.3 $
 Revisions:
 
 2001/07/29: billb
   
   - Initial revision
 
 2001/08/01: marcf
   
   - Added the schedule method 
   
- The bean lock is now responsible for implementing the locking
   policies, it was before in the interceptor code it is now factored
   out allowing for pluggable lock policies (optimistic for ex) 
   
- Implemented pessimistic locking and straight spec requirement in the
   schedule method would need to factor this in an abstract class for the
   BeanLock that extending policies can use
 
 2001/08/02: marcf
   
   - Did what was said above, moved to an extension based mech with an
   abstract base class.
   
- This is the simple lock, won't scale well (imho) but is robust in
   normal operation
   
- The class must now implement schedule and the various notification
   calls.  EndTransaction wontSynchronize can be radically different (N-Lock)
 
 
- Author: 
- Bill Burke, Marc Fleury
| Field Summary | 
|  java.lang.Object | lockThe actual lock object
 | 
 
 
 
| Method Summary | 
| protected  boolean | doSchedule(MethodInvocation mi)doSchedule implements a particular policy for scheduling the threads
 coming in.
 | 
|  void | endTransaction(javax.transaction.Transaction transaction)This is called up synchronization to notify the end of the transaction.
 | 
|  java.lang.Object | getLock()
 | 
|  void | 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 | schedule(MethodInvocation mi)
 | 
|  void | wontSynchronize(javax.transaction.Transaction transaction)This is called if the synchronization missed registration
 (Sync interceptor).
 | 
 
| Methods inherited from class org.jboss.ejb.plugins.lock.BeanLockSupport | 
| addMethodLock, addRef, getId, getNumMethodLocks, getRefs, getTransaction, isCallAllowed, isMethodLocked, releaseSync, removeRef, setId, setReentrant, setTimeout, setTransaction, sync | 
 
| Methods inherited from class java.lang.Object | 
| clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait | 
 
lock
public java.lang.Object lock
- The actual lock object
SimplePessimisticEJBLock
public SimplePessimisticEJBLock()
getLock
public java.lang.Object getLock()
schedule
public void schedule(MethodInvocation mi)
              throws java.lang.Exception
- 
- Overrides:
- schedulein class- BeanLockSupport
 
doSchedule
protected boolean doSchedule(MethodInvocation mi)
                      throws java.lang.Exception
- 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.- 
- Returns:
- Returns true if the thread is scheduled to go through the 
            rest of the interceptors.  Returns false if the interceptor
            must try the scheduling again.
 
wontSynchronize
public void wontSynchronize(javax.transaction.Transaction transaction)
- This is called if the synchronization missed registration
 (Sync interceptor).- 
- Overrides:
- wontSynchronizein class- BeanLockSupport
 
endTransaction
public void endTransaction(javax.transaction.Transaction transaction)
- This is called up synchronization to notify the end of the transaction.- 
- Overrides:
- endTransactionin class- BeanLockSupport
 
releaseMethodLock
public void 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:
- releaseMethodLockin class- BeanLockSupport
 
Copyright © 2000 The JBoss Organization. All Rights Reserved.