Proxy
Proxy. getProxyClass (ClassLoader loader, Class <?> ... Interfaces) obtains the bytecode object of the proxy Class and returns the Class type.
Proxy. newProxyInstance (ClassLoader loader, Class <?> [] Interfaces, InvocationHandler h) obtains an Instance Object of the dynamic proxy class.
Dynamic Proxy:
Class proxy {
InvocationHandler handler;
ProxyClass (InvocationHandler handler ){
This. handler = handler;
}
Method_1 (Object [] obj ){
Handler. invoke (proxy, Interfaces. getMethod ("method_1"), obj );
}
.....
Method_n (Object [] obj)
Handler. invoke (proxy, Interfaces. getMethod ("method_n"), obj );
}
The InvocationHandler object has only one invoke method. This method is equivalent to a relay method. Its Parameter List is the method called by obj-proxy object and method-proxy object, args-list of parameters for calling a method, which is an array of objects. the methods and system functions of the target class are called and implemented in the InvocationHandler's invoke method.
<! -- [If gte mso 9]> <! [Endif] --> <! -- [If gte mso 9]> <! [Endif] --> <! -- [If gte mso 10]>
Proxy implementation AOP framework