[seam-commits] Seam SVN: r10287 - branches/community/Seam_2_0/src/main/org/jboss/seam/core.

seam-commits at lists.jboss.org seam-commits at lists.jboss.org
Fri Apr 3 02:14:05 EDT 2009


Author: dan.j.allen
Date: 2009-04-03 02:14:04 -0400 (Fri, 03 Apr 2009)
New Revision: 10287

Modified:
   branches/community/Seam_2_0/src/main/org/jboss/seam/core/BijectionInterceptor.java
Log:
JBSEAM-3361 roll back all changes to BijectionInterceptor in 2.0 branch; too big a change for a point release


Modified: branches/community/Seam_2_0/src/main/org/jboss/seam/core/BijectionInterceptor.java
===================================================================
--- branches/community/Seam_2_0/src/main/org/jboss/seam/core/BijectionInterceptor.java	2009-04-03 05:57:46 UTC (rev 10286)
+++ branches/community/Seam_2_0/src/main/org/jboss/seam/core/BijectionInterceptor.java	2009-04-03 06:14:04 UTC (rev 10287)
@@ -1,9 +1,6 @@
 //$Id$
 package org.jboss.seam.core;
 
-import java.lang.reflect.Method;
-import java.util.concurrent.locks.ReentrantLock;
-
 import org.jboss.seam.Component;
 import org.jboss.seam.annotations.intercept.AroundInvoke;
 import org.jboss.seam.annotations.intercept.Interceptor;
@@ -11,128 +8,52 @@
 import org.jboss.seam.intercept.InvocationContext;
 import org.jboss.seam.log.LogProvider;
 import org.jboss.seam.log.Logging;
-import org.jboss.seam.util.Reflections;
 
 /**
  * Before invoking the component, inject all dependencies. After
  * invoking, outject dependencies back into their context.
  * 
  * @author Gavin King
- * @author Shane Bryzak
  */
 @Interceptor
 public class BijectionInterceptor extends AbstractInterceptor
 {
    private static final long serialVersionUID = 4686458105931528659L;
-
+   
    private static final LogProvider log = Logging.getLogProvider(BijectionInterceptor.class);
    
-   private boolean injected;
+   private boolean reentrant; //OK, since all Seam components are single-threaded
    
-   private boolean injecting;
-   
-   private int counter = 0;
-   
-   private ReentrantLock lock = new ReentrantLock();
-         
-   private String initialMethod;
-   
    @AroundInvoke
    public Object aroundInvoke(InvocationContext invocation) throws Exception
    {
-      Component component = getComponent();    
-      Method method = invocation.getMethod();
-      boolean enforceRequired = !component.isLifecycleMethod( method );      
-      
-      try
-      {    
-         lock.lock();
-         try
+      if (reentrant)
+      {
+         if ( log.isTraceEnabled() )
          {
-            if (!injected)
-            {              
-               if (injecting)
-               {
-                  log.warn("Injecting dependencies into " + component.getName() + " for the invocation of " 
-                        + initialMethod + " caused the invocation of a reentrant method: " + Reflections.toString(method) 
-                        + ".  Some injected dependencies may not be available for the duration of this method invocation.");
-               }
-               else
-               {
-                  injecting = true;
-                  try
-                  {
-                     initialMethod = Reflections.toString(method);
-                     component.inject(invocation.getTarget(), enforceRequired);
-                  }
-                  finally
-                  {
-                     injecting = false;
-                     initialMethod = null;
-                  }
-               }
-               injected = true;
-            }
-            
-            counter++;
+            log.trace("reentrant call to component: " + getComponent().getName() );
          }
-         finally
-         {
-            lock.unlock();
-         } 
-                           
-         Object result = invocation.proceed();
-            
-         lock.lock();
+         return invocation.proceed();
+      }
+      else
+      {
+         reentrant = true;
          try
          {
-            counter--;
+            Component component = getComponent();
+            boolean enforceRequired = !component.isLifecycleMethod( invocation.getMethod() );
+            component.inject( invocation.getTarget(), enforceRequired );
+            Object result = invocation.proceed();            
+            component.outject( invocation.getTarget(), enforceRequired );
+            component.disinject( invocation.getTarget() );
+            return result;
             
-            if (counter == 0)
-            {
-               try
-               {                     
-                  component.outject( invocation.getTarget(), enforceRequired );
-               }
-               finally
-               {
-                  // Avoid an extra lock by disinjecting here instead of the finally block
-                  if (injected)
-                  {
-                     injected = false;
-                     component.disinject( invocation.getTarget() );
-                  }
-               }   
-            }
          }
          finally
          {
-            lock.unlock();
+            reentrant = false;
          }
-         
-         return result;
       }
-      finally
-      {            
-         if (injected)
-         {
-            lock.lock();
-            try
-            {
-               counter--;
-               
-               if (counter == 0)
-               {
-                  injected = false;
-                  component.disinject( invocation.getTarget() );     
-               }
-            }
-            finally
-            {
-               lock.unlock();
-            }
-         }
-      }
    }
-   
+
 }




More information about the seam-commits mailing list