openwebbeans-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bergm...@apache.org
Subject svn commit: r996645 - in /openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans: component/ManagedBean.java proxy/JavassistProxyFactory.java util/WebBeansAnnotatedTypeUtil.java util/WebBeansUtil.java
Date Mon, 13 Sep 2010 19:06:00 GMT
Author: bergmark
Date: Mon Sep 13 19:06:00 2010
New Revision: 996645

URL: http://svn.apache.org/viewvc?rev=996645&view=rev
Log:
[OWB-445] Remove usage of setHandler on the ProxyFactory in the AbstractDecorator case.

Modified:
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/ManagedBean.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/proxy/JavassistProxyFactory.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/WebBeansAnnotatedTypeUtil.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/WebBeansUtil.java

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/ManagedBean.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/ManagedBean.java?rev=996645&r1=996644&r2=996645&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/ManagedBean.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/ManagedBean.java
Mon Sep 13 19:06:00 2010
@@ -21,9 +21,12 @@ package org.apache.webbeans.component;
 import java.io.Serializable;
 import java.lang.reflect.Constructor;
 
+import javassist.util.proxy.ProxyObject;
+
 import javax.enterprise.context.spi.CreationalContext;
 import javax.enterprise.inject.spi.Decorator;
 
+import org.apache.webbeans.decorator.AbstractDecoratorMethodHandler;
 import org.apache.webbeans.inject.InjectableConstructor;
 import org.apache.webbeans.intercept.InterceptorData;
 
@@ -36,6 +39,8 @@ public class ManagedBean<T> extends Abst
 {
     /** Constructor of the web bean component */
     private Constructor<T> constructor;
+    
+    boolean isAbstractDecorator;
 
     public ManagedBean(Class<T> returnType)
     {
@@ -67,6 +72,12 @@ public class ManagedBean<T> extends Abst
 
         T instance = ic.doInjection();
         
+        //If this is an abstract Decorator, we need to set the handler on the Proxy instance
+        if(isAbstractDecorator)
+        {
+            ((ProxyObject)instance).setHandler(new AbstractDecoratorMethodHandler());
+        }
+        
         return instance;
     }
 
@@ -120,4 +131,9 @@ public class ManagedBean<T> extends Abst
         
         return false;
     }
+    
+    public void setIsAbstractDecorator(boolean flag)
+    {
+        isAbstractDecorator = flag;
+    }
 }
\ No newline at end of file

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/proxy/JavassistProxyFactory.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/proxy/JavassistProxyFactory.java?rev=996645&r1=996644&r2=996645&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/proxy/JavassistProxyFactory.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/proxy/JavassistProxyFactory.java
Mon Sep 13 19:06:00 2010
@@ -42,7 +42,6 @@ import org.apache.webbeans.component.Inj
 import org.apache.webbeans.component.OwbBean;
 import org.apache.webbeans.config.WebBeansFinder;
 import org.apache.webbeans.context.creational.CreationalContextImpl;
-import org.apache.webbeans.decorator.AbstractDecoratorMethodHandler;
 import org.apache.webbeans.decorator.WebBeansDecorator;
 import org.apache.webbeans.intercept.ApplicationScopedBeanIntereptorHandler;
 import org.apache.webbeans.intercept.DependentScopedBeanInterceptorHandler;
@@ -147,10 +146,6 @@ public final class JavassistProxyFactory
         try
         {
             ProxyFactory fact = createProxyFactory(bean);
-            AbstractDecoratorMethodHandler handler = new AbstractDecoratorMethodHandler();
-
-            //X TODO we MUST NOT set the handler here! This causes mem leaks!
-            fact.setHandler(handler);
             
             clazz = SecurityUtil.doPrivilegedCreateClass(fact);
         }

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/WebBeansAnnotatedTypeUtil.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/WebBeansAnnotatedTypeUtil.java?rev=996645&r1=996644&r2=996645&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/WebBeansAnnotatedTypeUtil.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/WebBeansAnnotatedTypeUtil.java
Mon Sep 13 19:06:00 2010
@@ -770,6 +770,7 @@ public final class WebBeansAnnotatedType
         Class clazz = JavassistProxyFactory.getInstance().createAbstractDecoratorProxyClass(bean);
 
         bean.setConstructor(WebBeansUtil.defineConstructor(clazz));
+        bean.setIsAbstractDecorator(true);
         return bean;
     }
     

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/WebBeansUtil.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/WebBeansUtil.java?rev=996645&r1=996644&r2=996645&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/WebBeansUtil.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/WebBeansUtil.java
Mon Sep 13 19:06:00 2010
@@ -3004,6 +3004,7 @@ public final class WebBeansUtil
         Class clazz = JavassistProxyFactory.getInstance().createAbstractDecoratorProxyClass(bean);
 
         bean.setConstructor(WebBeansUtil.defineConstructor(clazz));
+        bean.setIsAbstractDecorator(true);
         return bean;
     }
 



Mime
View raw message