[seam-commits] Seam SVN: r8781 - trunk/src/main/org/jboss/seam/core.

seam-commits at lists.jboss.org seam-commits at lists.jboss.org
Fri Aug 22 13:00:00 EDT 2008


Author: pete.muir at jboss.org
Date: 2008-08-22 12:59:59 -0400 (Fri, 22 Aug 2008)
New Revision: 8781

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

Modified: trunk/src/main/org/jboss/seam/core/BijectionInterceptor.java
===================================================================
--- trunk/src/main/org/jboss/seam/core/BijectionInterceptor.java	2008-08-22 16:42:44 UTC (rev 8780)
+++ trunk/src/main/org/jboss/seam/core/BijectionInterceptor.java	2008-08-22 16:59:59 UTC (rev 8781)
@@ -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,35 +18,45 @@
 {
    private static final long serialVersionUID = 4686458105931528659L;
    
-   private static final LogProvider log = Logging.getLogProvider(BijectionInterceptor.class);
+   private Integer counter = 0;
       
-   private AtomicInteger reentrantCounter = new AtomicInteger();   
-   
    @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