Skip to content

Instantly share code, notes, and snippets.

@hacke2
Created Aug 25, 2014
Embed
What would you like to do?
动态代理及JDK动态代理源码分析
public class LogProxy implements InvocationHandler {
private Object object;
public LogProxy(Object object) {
super();
this.object = object;
}
@Override
public Object invoke(Object proxy, Method method, Object[] args)
throws Throwable {
method.invoke(this.object, args);
System.out.println("记录到数据库..");
return null;
}
public void setObject(Object object) {
this.object = object;
}
public Object getObject() {
return object;
}
}
public class PowerProxy implements InvocationHandler {
private Object object;
public PowerProxy(Object object) {
super();
this.object = object;
}
@Override
public Object invoke(Object proxy, Method method, Object[] args)
throws Throwable {
System.out.println("进行权限验证..是否是黑名单..");
method.invoke(this.object, args);
return null;
}
public void setObject(Object object) {
this.object = object;
}
public Object getObject() {
return object;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment