geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From djen...@apache.org
Subject svn commit: r425160 - /geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/kernel/basic/BasicProxyManager.java
Date Mon, 24 Jul 2006 19:49:43 GMT
Author: djencks
Date: Mon Jul 24 12:49:43 2006
New Revision: 425160

URL: http://svn.apache.org/viewvc?rev=425160&view=rev
Log:
GERONIMO-2204 do not forward finalize call to proxied object

Modified:
    geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/kernel/basic/BasicProxyManager.java

Modified: geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/kernel/basic/BasicProxyManager.java
URL: http://svn.apache.org/viewvc/geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/kernel/basic/BasicProxyManager.java?rev=425160&r1=425159&r2=425160&view=diff
==============================================================================
--- geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/kernel/basic/BasicProxyManager.java
(original)
+++ geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/kernel/basic/BasicProxyManager.java
Mon Jul 24 12:49:43 2006
@@ -17,6 +17,7 @@
 package org.apache.geronimo.kernel.basic;
 
 import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
 import java.util.ArrayList;
 import java.util.Collections;
 import java.util.List;
@@ -26,6 +27,8 @@
 import net.sf.cglib.proxy.Callback;
 import net.sf.cglib.proxy.Enhancer;
 import net.sf.cglib.proxy.MethodInterceptor;
+import net.sf.cglib.proxy.NoOp;
+import net.sf.cglib.proxy.CallbackFilter;
 import net.sf.cglib.reflect.FastClass;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
@@ -197,7 +200,8 @@
                 }
             }
             enhancer.setClassLoader(classLoader);
-            enhancer.setCallbackType(MethodInterceptor.class);
+            enhancer.setCallbackFilter(new FinalizeCallbackFilter());
+            enhancer.setCallbackTypes(new Class[] {NoOp.class, MethodInterceptor.class});
             enhancer.setUseFactory(false);
             proxyType = enhancer.createClass();
             fastClass = FastClass.create(proxyType);
@@ -208,7 +212,7 @@
 
             Callback callback = getMethodInterceptor(proxyType, kernel, target);
 
-            Enhancer.registerCallbacks(proxyType, new Callback[]{callback});
+            Enhancer.registerCallbacks(proxyType, new Callback[]{NoOp.INSTANCE, callback});
             try {
                 Object proxy = fastClass.newInstance();
                 interceptors.put(proxy, callback);
@@ -225,6 +229,16 @@
                   throw new ProxyCreationException(e);
                 }
             }
+        }
+    }
+
+    private static class FinalizeCallbackFilter implements CallbackFilter {
+
+        public int accept(Method method) {
+            if (method.getName().equals("finalize") && method.getParameterTypes().length
== 0) {
+                return 0;
+            }
+            return 1;
         }
     }
 



Mime
View raw message