java 代码
public class DynamicProxy implements InvocationHandler {
private Object originalObj;
public Object bind(Object obj){
this.originalObj = obj;
return Proxy.newProxyInstance(obj.getClass().getClassLoader(),
obj.getClass().getInterfaces(),
this);
}
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
// TODO Auto-generated method stub
System.out.println("before invoking....");
Object obj = method.invoke(originalObj,args);
System.out.println("after invoking....");
return obj;
}
}
|