java实现动态代理切面编程
2020-12-13 02:19
标签:执行 import handle ram select cat return class oid package proxy; import java.lang.reflect.InvocationHandler; public class MyInvocation implements InvocationHandler{ public void setObj(Object obj) { } package proxy; import java.lang.reflect.Proxy; public class MyProxy { public static Object getProxyInstance(Object obj) { Object newProxyInstance = Proxy.newProxyInstance(obj.getClass().getClassLoader(), } } package proxy; public class ProxyUtii { } public static void main(String[] args) { Object proxyInstance = MyProxy.getProxyInstance(pmaunewMapperImpl); PmaunewMapper pm = (PmaunewMapper) proxyInstance; List } java实现动态代理切面编程 标签:执行 import handle ram select cat return class oid 原文地址:https://www.cnblogs.com/cw828/p/11031308.html
import java.lang.reflect.Method;
import java.lang.reflect.Parameter;
Object obj;
this.obj = obj;
}
@Override
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
Parameter[] parameters = method.getParameters();
for (Parameter parameter : parameters) {
parameter.getName();
}
ProxyUtii.proxyMethod1(method.getName());
Object invoke = method.invoke(obj, args);
ProxyUtii.proxyMethod2(method.getName());
return invoke;
}
MyInvocation mi = new MyInvocation();
mi.setObj(obj);
obj.getClass().getInterfaces(),mi);
return newProxyInstance;
public static void proxyMethod1(String str) {
System.out.println("开始执行sql方法:"+str+"****************************************");
}
public static void proxyMethod2(String str) {
System.out.println("结束执行sql方法:"+str+"****************************************");
}
下一篇:js insertBefore