User: patriot1burke
  Date: 01/08/08 15:01:31

  Modified:    src/main/org/jboss/ejb/plugins/lock
                        SimplePessimisticEJBLock.java BeanLockSupport.java
  Log:
  refactored BeanLock interface
  
  Revision  Changes    Path
  1.5       +18 -3     
jboss/src/main/org/jboss/ejb/plugins/lock/SimplePessimisticEJBLock.java
  
  Index: SimplePessimisticEJBLock.java
  ===================================================================
  RCS file: 
/cvsroot/jboss/jboss/src/main/org/jboss/ejb/plugins/lock/SimplePessimisticEJBLock.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- SimplePessimisticEJBLock.java     2001/08/03 20:25:45     1.4
  +++ SimplePessimisticEJBLock.java     2001/08/08 22:01:31     1.5
  @@ -31,7 +31,7 @@
    *
    * @author <a href="[EMAIL PROTECTED]">Bill Burke</a>
    * @author <a href="[EMAIL PROTECTED]">Marc Fleury</a>
  - * @version $Revision: 1.4 $
  + * @version $Revision: 1.5 $
    *
    * <p><b>Revisions:</b><br>
    *  <p><b>2001/07/29: billb</b>
  @@ -61,8 +61,22 @@
   public class SimplePessimisticEJBLock
      extends BeanLockSupport  
   {
  +   /** The actual lock object **/
  +   public Object lock = new Object();
  + 
  +   public Object getLock() {return lock;}
  +     
  +   public void schedule(MethodInvocation mi) throws Exception
  +   {
  +      boolean threadScheduled = false;
  +      while (!threadScheduled)
  +      {
  +         /* loop on lock wakeup and restart trying to schedule */
  +         threadScheduled = doSchedule(mi);
  +      }
  +   }
      /**
  -    * Schedule implements a particular policy for scheduling the threads
  +    * 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
       *
  @@ -74,7 +88,7 @@
       *            rest of the interceptors.  Returns false if the interceptor
       *            must try the scheduling again. 
       */
  -   public boolean schedule(MethodInvocation mi) 
  +   protected boolean doSchedule(MethodInvocation mi) 
         throws Exception
      {
         this.sync();
  @@ -254,4 +268,5 @@
         // transaction
         if (numMethodLocks ==0) synchronized(lock) {lock.notifyAll();}
      }
  +
   }
  
  
  
  1.4       +2 -26     jboss/src/main/org/jboss/ejb/plugins/lock/BeanLockSupport.java
  
  Index: BeanLockSupport.java
  ===================================================================
  RCS file: 
/cvsroot/jboss/jboss/src/main/org/jboss/ejb/plugins/lock/BeanLockSupport.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- BeanLockSupport.java      2001/08/03 20:16:03     1.3
  +++ BeanLockSupport.java      2001/08/08 22:01:31     1.4
  @@ -29,7 +29,7 @@
    *
    * @author <a href="[EMAIL PROTECTED]">Bill Burke</a>
    * @author <a href="[EMAIL PROTECTED]">Marc Fleury</a>
  - * @version $Revision: 1.3 $
  + * @version $Revision: 1.4 $
    *
    * <p><b>Revisions:</b><br>
    *  <p><b>2001/07/29: marcf</b>
  @@ -40,9 +40,6 @@
   public abstract class BeanLockSupport
      implements BeanLock
   {
  -   /** The actual lock object **/
  -   public Object lock = new Object();
  - 
      /**
       * Number of threads invoking methods on this bean
       * (1 normally >1 if reentrant)
  @@ -77,8 +74,6 @@
      public void setReentrant(boolean reentrant) {this.reentrant = reentrant;}
      public void setTimeout(int timeout) {txTimeout = timeout;}
        
  -   public Object getLock() {return lock;}
  -     
      public void sync()
      {
         synchronized(this)
  @@ -104,7 +99,7 @@
         }
      }
    
  -   public abstract boolean schedule(MethodInvocation mi) throws Exception;
  +   public abstract void schedule(MethodInvocation mi) throws Exception;
        
      /**
       * The setTransaction associates a transaction with the lock.
  @@ -116,25 +111,6 @@
      public abstract void endTransaction(Transaction tx);
      public abstract void wontSynchronize(Transaction tx);
        
  -   /**
  -    * Notify one.
  -    * 
  -    * <p>You can overwrite these in the extensions
  -    */
  -   public void notifyOne() {
  -      synchronized(lock) {
  -     
  -         lock.notify();
  -      }
  -   }
  -     
  -   public void notifyEveryone() {
  -      synchronized(lock) {
  -                     
  -         lock.notifyAll();
  -      }
  -   }
  -   
      public boolean isMethodLocked() { return numMethodLocks > 0;}
      public int getNumMethodLocks() { return numMethodLocks;}
      public void addMethodLock() { numMethodLocks++; }
  
  
  

_______________________________________________
Jboss-development mailing list
[EMAIL PROTECTED]
http://lists.sourceforge.net/lists/listinfo/jboss-development

Reply via email to