User: simone  
  Date: 00/12/12 01:47:34

  Modified:    src/main/org/jboss/ejb/plugins
                        StatefulSessionInstanceInterceptor.java
  Log:
  Updated synchronization logic, see AbstractInstanceCache
  
  Revision  Changes    Path
  1.14      +19 -7     
jboss/src/main/org/jboss/ejb/plugins/StatefulSessionInstanceInterceptor.java
  
  Index: StatefulSessionInstanceInterceptor.java
  ===================================================================
  RCS file: 
/products/cvs/ejboss/jboss/src/main/org/jboss/ejb/plugins/StatefulSessionInstanceInterceptor.java,v
  retrieving revision 1.13
  retrieving revision 1.14
  diff -u -r1.13 -r1.14
  --- StatefulSessionInstanceInterceptor.java   2000/12/07 15:44:25     1.13
  +++ StatefulSessionInstanceInterceptor.java   2000/12/12 09:47:34     1.14
  @@ -18,6 +18,7 @@
   import org.jboss.ejb.MethodInvocation;
   import org.jboss.logging.Logger;
   import org.jboss.metadata.SessionMetaData;
  +import org.jboss.util.Sync;
   import javax.transaction.Transaction;
   import javax.transaction.RollbackException;
   import javax.transaction.Status;
  @@ -33,7 +34,7 @@
   *   @see <related>
   *   @author Rickard �berg ([EMAIL PROTECTED])
   *   @author <a href="mailto:[EMAIL PROTECTED]">Marc Fleury</a>
  -*   @version $Revision: 1.13 $
  +*   @version $Revision: 1.14 $
   */
   public class StatefulSessionInstanceInterceptor
   extends AbstractInterceptor
  @@ -104,7 +105,7 @@
                        // Still free? Not free if create() was called successfully
                        if (ctx.getId() == null)
                        {
  -                             
container.getInstancePool().free(mi.getEnterpriseContext()); 
  +                             container.getInstancePool().free(ctx); 
                        } 
                }
        }
  @@ -139,14 +140,16 @@
        public Object invoke(MethodInvocation mi)
        throws Exception
        {
  -             EnterpriseInstanceCache cache = 
(EnterpriseInstanceCache)container.getInstanceCache();
  +             AbstractInstanceCache cache = 
(AbstractInstanceCache)container.getInstanceCache();
                Object id = mi.getId();
                EnterpriseContext ctx = null;
  -             Object mutex = cache.getLock(id);
  +             Sync mutex = (Sync)cache.getLock(id);
                
                // We synchronize the locking logic (so we can be reentrant)
  -             synchronized (mutex) 
  +             try 
                {
  +                     mutex.acquire();
  +                     
                        // Get context
                        ctx = container.getInstanceCache().get(mi.getId());
                
  @@ -190,7 +193,12 @@
                                        ctx.lock();
                                }
                        }
  -             } 
  +             }
  +             catch (InterruptedException ignored) {} 
  +             finally 
  +             {
  +                     mutex.release();
  +             }
                
                try
                {
  @@ -222,8 +230,10 @@
                        if (ctx != null)
                        {
                                // Still a valid instance
  -                             synchronized (mutex) 
  +                             try 
                                {
  +                                     mutex.acquire();
  +
                                        // release it
                                        ctx.unlock();
                                
  @@ -234,6 +244,8 @@
                                                
container.getInstanceCache().remove(mi.getId());
                                        }
                                }
  +                             catch (InterruptedException ignored) {}
  +                             finally {mutex.release();}
                        }
                }
        }
  
  
  

Reply via email to