[seam-commits] Seam SVN: r8786 - 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 18:20:10 EDT 2008


Author: pete.muir at jboss.org
Date: 2008-08-22 18:20:10 -0400 (Fri, 22 Aug 2008)
New Revision: 8786

Modified:
   branches/Seam_2_0/src/main/org/jboss/seam/core/BijectionInterceptor.java
Log:
backport 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 21:41:01 UTC (rev 8785)
+++ branches/Seam_2_0/src/main/org/jboss/seam/core/BijectionInterceptor.java	2008-08-22 22:20:10 UTC (rev 8786)
@@ -1,15 +1,11 @@
 //$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;
 import org.jboss.seam.intercept.AbstractInterceptor;
 import org.jboss.seam.intercept.InvocationContext;
-import org.jboss.seam.log.LogProvider;
-import org.jboss.seam.log.Logging;
 
 /**
  * Before invoking the component, inject all dependencies. After
@@ -22,37 +18,47 @@
 {
    private static final long serialVersionUID = 4686458105931528659L;
    
-   private static final LogProvider log = Logging.getLogProvider(BijectionInterceptor.class);
-   
-   private AtomicInteger reentrantCounter = new AtomicInteger();   
-   
+   private Integer counter = 0;
+      
    @AroundInvoke
    public Object aroundInvoke(InvocationContext invocation) throws Exception
    {
-      Component component = getComponent();
       try
       {
-         if ( log.isTraceEnabled() && reentrantCounter.get() > 0 )
+         synchronized (counter)
          {
-            log.trace("reentrant call to component: " + getComponent().getName() );
+            if (counter == 0)
+            {
+               Component component = getComponent();
+               boolean enforceRequired = !component.isLifecycleMethod( invocation.getMethod() );
+               component.inject( invocation.getTarget(), enforceRequired );
+            }
+            counter++;
          }
          
-         reentrantCounter.incrementAndGet();            
-         boolean enforceRequired = !component.isLifecycleMethod( invocation.getMethod() );
-         component.inject( invocation.getTarget(), enforceRequired );
-         Object result = invocation.proceed();            
-         component.outject( invocation.getTarget(), enforceRequired );
+         Object result = invocation.proceed();
          
+         if (counter == 1)
+         {
+            Component component = getComponent();
+            boolean enforceRequired = !component.isLifecycleMethod( invocation.getMethod() );
+            component.outject( invocation.getTarget(), enforceRequired );
+         }
          return result;
-         
       }
       finally
       {
-         if (reentrantCounter.decrementAndGet() == 0)
+         synchronized (counter)
          {
-            component.disinject( invocation.getTarget() );
+            if (counter == 1)
+            {
+               Component component = getComponent();
+               component.disinject( invocation.getTarget() );
+            }
+            counter--;
+            
          }
       }
    }
-
+   
 }




More information about the seam-commits mailing list