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

seam-commits at lists.jboss.org seam-commits at lists.jboss.org
Fri Aug 22 07:18:16 EDT 2008


Author: shane.bryzak at jboss.com
Date: 2008-08-22 07:18:16 -0400 (Fri, 22 Aug 2008)
New Revision: 8777

Modified:
   branches/Seam_2_0/src/main/org/jboss/seam/core/BijectionInterceptor.java
Log:
JBSEAM-3295

Modified: branches/Seam_2_0/src/main/org/jboss/seam/core/BijectionInterceptor.java
===================================================================
--- branches/Seam_2_0/src/main/org/jboss/seam/core/BijectionInterceptor.java	2008-08-22 11:13:20 UTC (rev 8776)
+++ branches/Seam_2_0/src/main/org/jboss/seam/core/BijectionInterceptor.java	2008-08-22 11:18:16 UTC (rev 8777)
@@ -1,6 +1,8 @@
 //$Id$
 package org.jboss.seam.core;
 
+import java.util.concurrent.atomic.AtomicInteger;
+
 import org.jboss.seam.Component;
 import org.jboss.seam.annotations.intercept.AroundInvoke;
 import org.jboss.seam.annotations.intercept.Interceptor;
@@ -22,37 +24,34 @@
    
    private static final LogProvider log = Logging.getLogProvider(BijectionInterceptor.class);
    
-   private boolean reentrant; //OK, since all Seam components are single-threaded
+   private AtomicInteger reentrantCounter = new AtomicInteger();   
    
    @AroundInvoke
    public Object aroundInvoke(InvocationContext invocation) throws Exception
    {
-      if (reentrant)
+      Component component = getComponent();
+      try
       {
-         if ( log.isTraceEnabled() )
+         if ( log.isTraceEnabled() && reentrantCounter.get() > 0 )
          {
             log.trace("reentrant call to component: " + getComponent().getName() );
          }
-         return invocation.proceed();
+         
+         reentrantCounter.incrementAndGet();            
+         boolean enforceRequired = !component.isLifecycleMethod( invocation.getMethod() );
+         component.inject( invocation.getTarget(), enforceRequired );
+         Object result = invocation.proceed();            
+         component.outject( invocation.getTarget(), enforceRequired );
+         
+         return result;
+         
       }
-      else
+      finally
       {
-         reentrant = true;
-         try
+         if (reentrantCounter.decrementAndGet() == 0)
          {
-            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;
-            
          }
-         finally
-         {
-            reentrant = false;
-         }
       }
    }
 




More information about the seam-commits mailing list