[weld-commits] Weld SVN: r5892 - in core/trunk/impl/src/main/java/org/jboss/weld/bean: proxy and 1 other directory.

weld-commits at lists.jboss.org weld-commits at lists.jboss.org
Fri Feb 19 20:11:48 EST 2010


Author: marius.bogoevici
Date: 2010-02-19 20:11:48 -0500 (Fri, 19 Feb 2010)
New Revision: 5892

Modified:
   core/trunk/impl/src/main/java/org/jboss/weld/bean/AbstractClassBean.java
   core/trunk/impl/src/main/java/org/jboss/weld/bean/ManagedBean.java
   core/trunk/impl/src/main/java/org/jboss/weld/bean/proxy/ClientProxyProvider.java
Log:
WELD-430


Modified: core/trunk/impl/src/main/java/org/jboss/weld/bean/AbstractClassBean.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/bean/AbstractClassBean.java	2010-02-19 13:54:18 UTC (rev 5891)
+++ core/trunk/impl/src/main/java/org/jboss/weld/bean/AbstractClassBean.java	2010-02-20 01:11:48 UTC (rev 5892)
@@ -523,6 +523,11 @@
       }
    }
 
+   public boolean hasInterceptors()
+   {
+      return this.isInterceptionCandidate() && (this.hasCdiBoundInterceptors() || this.hasDirectlyDefinedInterceptors());
+   }
+
    protected void initDirectlyDefinedInterceptors()
    {
       if (beanManager.getClassDeclaredInterceptorsRegistry().getInterceptionModel(getType()) == null && InterceptionUtils.supportsEjb3InterceptorDeclaration())

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	2010-02-19 13:54:18 UTC (rev 5891)
+++ core/trunk/impl/src/main/java/org/jboss/weld/bean/ManagedBean.java	2010-02-20 01:11:48 UTC (rev 5892)
@@ -186,7 +186,7 @@
 
       public void postConstruct(T instance)
       {
-         if (bean.isInterceptionCandidate() && (bean.hasCdiBoundInterceptors() || bean.hasDirectlyDefinedInterceptors()))
+         if (bean.hasInterceptors())
          {
             InterceptionUtils.executePostConstruct(instance);
          }
@@ -198,13 +198,13 @@
 
       public void preDestroy(T instance)
       {
-         if (!bean.isInterceptionCandidate() || !(bean.hasCdiBoundInterceptors() || bean.hasDirectlyDefinedInterceptors()))
+         if (bean.hasInterceptors())
          {
-            bean.defaultPreDestroy(instance);
+            InterceptionUtils.executePredestroy(instance);
          }
          else
          {
-            InterceptionUtils.executePredestroy(instance);
+            bean.defaultPreDestroy(instance);
          }
       }
 
@@ -244,7 +244,7 @@
 
             }.run();
          }
-         if (bean.isInterceptionCandidate() && (bean.hasCdiBoundInterceptors() || bean.hasDirectlyDefinedInterceptors()))
+         if (bean.hasInterceptors())
          {
             return bean.applyInterceptors(instance, ctx);
          }
@@ -253,6 +253,8 @@
             return instance;
          }
       }
+
+
    }
 
    // Logger

Modified: core/trunk/impl/src/main/java/org/jboss/weld/bean/proxy/ClientProxyProvider.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/bean/proxy/ClientProxyProvider.java	2010-02-19 13:54:18 UTC (rev 5891)
+++ core/trunk/impl/src/main/java/org/jboss/weld/bean/proxy/ClientProxyProvider.java	2010-02-20 01:11:48 UTC (rev 5892)
@@ -25,7 +25,9 @@
 
 import javax.enterprise.inject.spi.Bean;
 
+import org.jboss.interceptor.proxy.LifecycleMixin;
 import org.jboss.weld.Container;
+import org.jboss.weld.bean.AbstractClassBean;
 import org.jboss.weld.exceptions.DefinitionException;
 import org.jboss.weld.exceptions.WeldException;
 import org.jboss.weld.serialization.spi.ContextualStore;
@@ -91,7 +93,16 @@
    {
       try
       {
-         return Proxies.<T>createProxy(new ClientProxyMethodHandler(bean, id), TypeInfo.of(bean.getTypes()).add(Serializable.class));
+         TypeInfo typeInfo;
+         if ((bean instanceof AbstractClassBean) && ((AbstractClassBean)bean).hasInterceptors())
+         {
+             typeInfo = TypeInfo.of(bean.getTypes()).add(Serializable.class).add(LifecycleMixin.class);
+         }
+         else
+         {
+             typeInfo = TypeInfo.of(bean.getTypes()).add(Serializable.class);
+         }
+         return Proxies.<T>createProxy(new ClientProxyMethodHandler(bean, id), typeInfo);
       }
       catch (InstantiationException e)
       {



More information about the weld-commits mailing list