标签:
需要用到的类和接口:
InvocationHandler:
Object invoke(Object proxy, Method method, Object[] args) throws Throwable
Object proxy:代理调用方法的实例
Method method:执行的方法
Object[] args:执行方法时的参数对象数组
@param proxy the proxy instance that the method was invoked on @param method the {@code Method} instance corresponding to the interface method invoked on the proxy instance. @param args an array of objects containing the values of the arguments passed in the method invocation on the proxy instance, or {@code null} if interface method takes no arguments. @return the value to return from the method invocation on the proxy instance.
Proxy:
public static Object newProxyInstance(ClassLoader loader, Class<?>[] interfaces, InvocationHandler h) throws IllegalArgumentException
ClassLoader loader:ClassLoader对象,用于对生成的代理对象进行加载 Class<?>[] interfaces:Interface对象的数组,代理对象实现的方法 InvocationHandler h:InvocationHandler对象,用指定的加载器加载,并且实现了指定的接口的InvocationHandler的代理实例
@param loader the class loader to define the proxy class @param interfaces the list of interfaces for the proxy class to implement @param h the invocation handler to dispatch method invocations to @return a proxy instance with the specified invocation handler of a proxy class that is defined by the specified class loader and that
implements the specified interfaces
标签:
原文地址:http://www.cnblogs.com/angryorange/p/5252371.html