标签:handler throw 动态代理 method bin return cat nts ade
动态代理
public class MyInvocationHandler implements InvocationHandler {
private Object object=null;
public Object bind(Object obj){
object=obj;
return Proxy.newProxyInstance(obj.getClass().getClassLoader(), obj.getClass().getInterfaces(), this);
}
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
Object temp=method.invoke(this.object, args);
return temp;
}
}
通过bind方法绑定代理类
MyInvocationHandler handler=new MyInvocationHandler();
Subject subject=(Subject)handler.bind(new RealSubject());
标签:handler throw 动态代理 method bin return cat nts ade
原文地址:http://www.cnblogs.com/cindy-zhu/p/6854209.html