Created
August 25, 2014 13:51
-
-
Save hacke2/1000c34eef247ba8b175 to your computer and use it in GitHub Desktop.
动态代理及JDK动态代理源码分析
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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