[seam-commits] Seam SVN: r10134 - trunk/src/wicket/org/jboss/seam/wicket/ioc.

seam-commits at lists.jboss.org seam-commits at lists.jboss.org
Mon Mar 9 15:26:38 EDT 2009


Author: cpopetz
Date: 2009-03-09 15:26:37 -0400 (Mon, 09 Mar 2009)
New Revision: 10134

Modified:
   trunk/src/wicket/org/jboss/seam/wicket/ioc/BijectionInterceptor.java
   trunk/src/wicket/org/jboss/seam/wicket/ioc/WicketHandler.java
Log:
JBSEAM-3933: Sibling inner class wicket component injection conflict

Modified: trunk/src/wicket/org/jboss/seam/wicket/ioc/BijectionInterceptor.java
===================================================================
--- trunk/src/wicket/org/jboss/seam/wicket/ioc/BijectionInterceptor.java	2009-03-09 18:10:11 UTC (rev 10133)
+++ trunk/src/wicket/org/jboss/seam/wicket/ioc/BijectionInterceptor.java	2009-03-09 19:26:37 UTC (rev 10134)
@@ -1,6 +1,5 @@
 package org.jboss.seam.wicket.ioc;
 
-import org.jboss.seam.wicket.WicketComponent;
 
 
 public class BijectionInterceptor<T> implements StatelessInterceptor<T>
@@ -10,7 +9,6 @@
    {
       invocationContext.getComponent().outject(invocationContext.getBean());
       invocationContext.getComponent().disinject(invocationContext.getBean());
-      disinjectEnclosingInstances(invocationContext);
       return result;
    }
 
@@ -19,7 +17,6 @@
       try
       {
          invocationContext.getComponent().inject(invocationContext.getBean());
-         injectEnclosingInstances(invocationContext);
       }
       catch (Exception e)
       {
@@ -31,39 +28,5 @@
    {
       return exception;
    }
-   
-   private static <T> void injectEnclosingInstances(InvocationContext<T> invocationContext)
-   {
-      InstrumentedComponent enclosingInstance = invocationContext.getInstrumentedComponent().getEnclosingInstance();
-      while (enclosingInstance != null)
-      {
-         if (enclosingInstance.getHandler() != null && !enclosingInstance.getHandler().isReentrant())
-         {
-            WicketComponent.getInstance(enclosingInstance.getClass()).inject(enclosingInstance);
-            enclosingInstance = enclosingInstance.getEnclosingInstance();
-         }
-         else
-         {
-            return;
-         }
-      }
-   }
-   
-   private static <T> void disinjectEnclosingInstances(InvocationContext<T> invocationContext)
-   {
-      InstrumentedComponent enclosingInstance = invocationContext.getInstrumentedComponent().getEnclosingInstance();
-      while (enclosingInstance != null)
-      {
-         if (enclosingInstance.getHandler() != null && !enclosingInstance.getHandler().isReentrant())
-         {
-            WicketComponent.getInstance(enclosingInstance.getClass()).disinject(enclosingInstance);
-            enclosingInstance = enclosingInstance.getEnclosingInstance();
-         }
-         else
-         {
-            return;
-         }
-      }
-   }
 
 }

Modified: trunk/src/wicket/org/jboss/seam/wicket/ioc/WicketHandler.java
===================================================================
--- trunk/src/wicket/org/jboss/seam/wicket/ioc/WicketHandler.java	2009-03-09 18:10:11 UTC (rev 10133)
+++ trunk/src/wicket/org/jboss/seam/wicket/ioc/WicketHandler.java	2009-03-09 19:26:37 UTC (rev 10134)
@@ -67,8 +67,28 @@
          }
       }
       reentrant++;
+      InstrumentedComponent enclosing = getEnclosingInstance(invocationContext.getBean());
+      if (enclosing != null)
+      {
+         enclosing.getHandler().injectEnclosingInstance(enclosing);
+      }
    }
    
+   protected void injectEnclosingInstance(InstrumentedComponent instance)
+   {
+      if (reentrant == 0)
+      {
+         getComponent().inject(instance);
+      }
+      reentrant++;
+      instance = instance.getEnclosingInstance();
+      if (instance != null)
+      {
+         instance.getHandler().injectEnclosingInstance(instance);
+      }
+   }
+   
+   
    public Exception handleException(Object target, Method method, Exception exception)
    {
       return doHandleException(new InvocationContext(method, target, getComponent()), exception);
@@ -94,6 +114,7 @@
    
    private Object doAfterInvoke(InvocationContext invocationContext, Object result)
    {
+      
       reentrant--;
       if (reentrant == 0)
       {
@@ -102,14 +123,36 @@
             result = ((StatelessInterceptor) getComponent().getInterceptors().get(i)).afterInvoke(invocationContext, result);
          }
       }
+      InstrumentedComponent enclosing = getEnclosingInstance(invocationContext.getBean());
+      if (enclosing != null)
+      {
+         enclosing.getHandler().disinjectEnclosingInstance(enclosing);
+      }
+      
       return result;
    }
+   
+   protected void disinjectEnclosingInstance(InstrumentedComponent instance)
+   {
+      reentrant--;
+      if (reentrant == 0)
+      {
+         getComponent().disinject(instance);
+      }
+      instance = instance.getEnclosingInstance();
+      if (instance != null)
+      {
+         instance.getHandler().disinjectEnclosingInstance(instance);
+      }
+   }
 
+
    public boolean isReentrant()
    {
       return reentrant > 0;
    }
    
+   
    public InstrumentedComponent getEnclosingInstance(Object bean)
    {
       Class enclosingType = getComponent().getClass();




More information about the seam-commits mailing list