[weld-commits] Weld SVN: r3974 - in core/trunk: tests/src/test/java/org/jboss/weld/test/unit/interceptor/simple and 1 other directory.

weld-commits at lists.jboss.org weld-commits at lists.jboss.org
Mon Oct 12 14:07:54 EDT 2009


Author: marius.bogoevici
Date: 2009-10-12 14:07:54 -0400 (Mon, 12 Oct 2009)
New Revision: 3974

Modified:
   core/trunk/impl/src/main/java/org/jboss/weld/bean/ManagedBean.java
   core/trunk/tests/src/test/java/org/jboss/weld/test/unit/interceptor/simple/SimpleInterceptorTest.java
Log:
Moving interception and decoration to produce.


Modified: core/trunk/impl/src/main/java/org/jboss/weld/bean/ManagedBean.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/bean/ManagedBean.java	2009-10-12 17:34:43 UTC (rev 3973)
+++ core/trunk/impl/src/main/java/org/jboss/weld/bean/ManagedBean.java	2009-10-12 18:07:54 UTC (rev 3974)
@@ -111,22 +111,12 @@
     */
    public T create(CreationalContext<T> creationalContext)
    {
-      InjectionPoint originalInjectionPoint = null;
-      if (hasDecorators())
-      {
-         originalInjectionPoint = attachCorrectInjectionPoint();
-      }
       T instance = getInjectionTarget().produce(creationalContext);
       getInjectionTarget().inject(instance, creationalContext);
-      if (hasDecorators())
-      {
-         instance = applyDecorators(instance, creationalContext, originalInjectionPoint);
-      }
       if (isInterceptionCandidate() && (hasBoundInterceptors() || hasDeclaredInterceptors()))
       {
-         instance = applyInterceptors(instance, creationalContext);
          InterceptionUtils.executePostConstruct(instance);
-      } 
+      }
       else
       {
          getInjectionTarget().postConstruct(instance);
@@ -237,6 +227,19 @@
                   // Without this, the chaining of decorators will fail as the incomplete instance will be resolved
                   ctx.push(instance);
                }
+               InjectionPoint originalInjectionPoint = null;
+               if (hasDecorators())
+               {
+                  originalInjectionPoint = attachCorrectInjectionPoint();
+               }
+               if (hasDecorators())
+               {
+                  instance = applyDecorators(instance, ctx, originalInjectionPoint);
+               }
+               if (isInterceptionCandidate() && (hasBoundInterceptors() || hasDeclaredInterceptors()))
+               {
+                  instance = applyInterceptors(instance, ctx);
+               }
                return instance;
             }
          });

Modified: core/trunk/tests/src/test/java/org/jboss/weld/test/unit/interceptor/simple/SimpleInterceptorTest.java
===================================================================
--- core/trunk/tests/src/test/java/org/jboss/weld/test/unit/interceptor/simple/SimpleInterceptorTest.java	2009-10-12 17:34:43 UTC (rev 3973)
+++ core/trunk/tests/src/test/java/org/jboss/weld/test/unit/interceptor/simple/SimpleInterceptorTest.java	2009-10-12 18:07:54 UTC (rev 3974)
@@ -23,10 +23,13 @@
 import org.jboss.weld.test.AbstractWeldTest;
 import org.jboss.testharness.impl.packaging.Artifact;
 import org.jboss.testharness.impl.packaging.jsr299.BeansXml;
+
 import org.testng.annotations.Test;
+import org.testng.annotations.BeforeMethod;
 
 import javax.enterprise.inject.spi.Bean;
 import javax.enterprise.context.spi.CreationalContext;
+
 import java.util.Set;
 import java.lang.annotation.Annotation;
 
@@ -38,6 +41,18 @@
 public class SimpleInterceptorTest extends AbstractWeldTest
 {
 
+   @BeforeMethod
+   public void resetInterceptors()
+   {
+      SimpleInterceptor.aroundInvokeCalled = false;
+      SimpleInterceptor.postConstructCalled = false;
+      SimpleInterceptor.preDestroyCalled = false;
+      TwoBindingsInterceptor.aroundInvokeCalled = false;
+      SimpleBeanImpl.postConstructCalled = false;
+      SimpleBeanImpl.businessMethodInvoked = false;
+   }
+
+
    @Test
    public void testInterceptorModel()
    {
@@ -52,7 +67,7 @@
    {
       Bean bean = getCurrentManager().getBeans(SimpleBeanImpl.class).iterator().next();
       CreationalContext creationalContext = getCurrentManager().createCreationalContext(bean);
-      SimpleBeanImpl simpleBean = (SimpleBeanImpl)bean.create(creationalContext);
+      SimpleBeanImpl simpleBean = (SimpleBeanImpl) bean.create(creationalContext);
       String result = simpleBean.doSomething();
       assert "decorated-Hello!-decorated".equals(result);
       bean.destroy(simpleBean, creationalContext);
@@ -68,7 +83,7 @@
    {
       Bean bean = getCurrentManager().getBeans(SimpleBeanWithStereotype.class).iterator().next();
       CreationalContext creationalContext = getCurrentManager().createCreationalContext(bean);
-      SimpleBeanWithStereotype simpleBean = (SimpleBeanWithStereotype)bean.create(creationalContext);
+      SimpleBeanWithStereotype simpleBean = (SimpleBeanWithStereotype) bean.create(creationalContext);
       String result = simpleBean.doSomething();
       assert "Hello!".equals(result);
       bean.destroy(simpleBean, creationalContext);
@@ -77,6 +92,5 @@
       assert SimpleInterceptor.preDestroyCalled;
       assert TwoBindingsInterceptor.aroundInvokeCalled;
       assert SimpleBeanWithStereotype.postConstructCalled;
-
    }
 }



More information about the weld-commits mailing list