Browse Source

使用 MethodFilter 机制过滤无需代理的方法

James 2 years ago
parent
commit
780f62f273
1 changed files with 0 additions and 19 deletions
  1. 0 19
      src/main/java/com/jfinal/ext/proxy/JavassistCallback.java

+ 0 - 19
src/main/java/com/jfinal/ext/proxy/JavassistCallback.java

@@ -17,8 +17,6 @@
 package com.jfinal.ext.proxy;
 
 import java.lang.reflect.Method;
-import java.util.HashSet;
-import java.util.Set;
 import com.jfinal.aop.Interceptor;
 import com.jfinal.aop.InterceptorManager;
 import com.jfinal.aop.Invocation;
@@ -30,15 +28,10 @@ import javassist.util.proxy.MethodHandler;
  */
 class JavassistCallback implements MethodHandler {
 	
-	private static final Set<String> excludedMethodName = buildExcludedMethodName();
 	private static final InterceptorManager interMan = InterceptorManager.me();
 	
 	@Override
     public Object invoke(Object target, Method method, Method methodProxy, Object[] args) throws Throwable {
-		if (excludedMethodName.contains(method.getName())) {
-		    return methodProxy.invoke(target, args);
-		}
-		
 		Class<?> targetClass = target.getClass().getSuperclass();
 		
 		MethodKey key = InterceptorCache.getMethodKey(targetClass, method);
@@ -60,18 +53,6 @@ class JavassistCallback implements MethodHandler {
 		invocation.invoke();
 		return invocation.getReturnValue();
 	}
-	
-	private static final Set<String> buildExcludedMethodName() {
-		Set<String> excludedMethodName = new HashSet<String>(64, 0.25F);
-		Method[] methods = Object.class.getDeclaredMethods();
-		for (Method m : methods) {
-			excludedMethodName.add(m.getName());
-		}
-		// getClass() registerNatives() can not be enhanced
-		// excludedMethodName.remove("getClass");	
-		// excludedMethodName.remove("registerNatives");
-		return excludedMethodName;
-	}
 }