openwebbeans-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rmannibu...@apache.org
Subject svn commit: r1384120 - in /openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans: intercept/NormalScopedBeanInterceptorHandler.java proxy/JavassistProxyFactory.java
Date Wed, 12 Sep 2012 20:52:57 GMT
Author: rmannibucau
Date: Wed Sep 12 20:52:57 2012
New Revision: 1384120

URL: http://svn.apache.org/viewvc?rev=1384120&view=rev
Log:
OWB-704 using javassist method filter instead of manual filtering in our handlers

Modified:
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/NormalScopedBeanInterceptorHandler.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/proxy/JavassistProxyFactory.java

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/NormalScopedBeanInterceptorHandler.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/NormalScopedBeanInterceptorHandler.java?rev=1384120&r1=1384119&r2=1384120&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/NormalScopedBeanInterceptorHandler.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/NormalScopedBeanInterceptorHandler.java
Wed Sep 12 20:52:57 2012
@@ -45,7 +45,6 @@ public class NormalScopedBeanInterceptor
 {
     /**Serial id*/
     private static final long serialVersionUID = 1L;
-    private static final String FINALIZE = "finalize".intern();
 
     /** this stores the {@link java.lang.reflect.Method#hashCode()} of intercepted methods
*/
     private CopyOnWriteArrayList<Integer> cachedInterceptedMethods = new CopyOnWriteArrayList<Integer>();
@@ -111,16 +110,6 @@ public class NormalScopedBeanInterceptor
 
     public Object invoke(Object instance, Method method, Object[] arguments) throws Throwable
     {
-        if (method.getName() == FINALIZE &&   // Method.getName() is defined to return
.intern() in the VM spec.
-            method.getParameterTypes().length == 0 &&
-            method.getReturnType() == Void.TYPE)
-        {
-            // we should NOT invoke the bean's finalize() from proxied
-            // finalize() method since JVM will invoke it directly.
-            // OWB-366
-            return null;
-        }
-
         //Get instance from context
         Object webbeansInstance = getContextualInstance();
         

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=1384120&r1=1384119&r2=1384120&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
Wed Sep 12 20:52:57 2012
@@ -21,6 +21,7 @@ package org.apache.webbeans.proxy;
 import java.io.Serializable;
 import java.lang.reflect.Constructor;
 import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
 import java.lang.reflect.Type;
 import java.util.HashSet;
 import java.util.Iterator;
@@ -34,6 +35,7 @@ import javax.enterprise.context.spi.Crea
 import javax.enterprise.inject.spi.Bean;
 import javax.enterprise.inject.spi.Decorator;
 
+import javassist.util.proxy.MethodFilter;
 import javassist.util.proxy.ProxyFactory;
 import javassist.util.proxy.ProxyFactory.ClassLoaderProvider;
 import javassist.util.proxy.ProxyObject;
@@ -474,8 +476,9 @@ public final class JavassistProxyFactory
 
         ProxyFactory fact = new ProxyFactory();        
         fact.setInterfaces(interfaceArray);
-        fact.setSuperclass(superClass);        
-        
+        fact.setSuperclass(superClass);
+        fact.setFilter(FinalizeMethodFilter.INSTANCE);
+
         return fact;
         
     }
@@ -489,4 +492,17 @@ public final class JavassistProxyFactory
         return o instanceof ProxyObject;
     }
 
+    private static class FinalizeMethodFilter implements MethodFilter
+    {
+        private static final String FINALIZE = "finalize".intern();
+
+        public static final FinalizeMethodFilter INSTANCE = new FinalizeMethodFilter();
+
+        public boolean isHandled(final Method method)
+        {
+            return !(method.getName() == FINALIZE
+                        && method.getParameterTypes().length == 0
+                        && method.getReturnType() == Void.TYPE);
+        }
+    }
 }



Mime
View raw message