java中的动态代理,我将其粗暴地理解为,将某一对象的某一方交与代理类,代理类在执行此方法的前后可以做一些自定义操作。
在实现动态代理的过程中,会涉及到InvocationHandler接口和Proxy类
其中,InvocationHanlder固名思义,是处理类,一些自定义操作就在此实现。
而Proxy类则是创建动态代理:
@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