JDK dynamic proxies are primarily using the Java Reflection mechanism (both java.lang.reflect packages)
Dynamic agents: When a program runs, it uses the JDK to provide a tool class (proxy), which dynamically creates a class that is typically used for proxies.
proxy class need to implement invocationhandler interface, and override the invoke method, the parameters in the Invoke method are generated from the bottom of the system and do not need to be given, Just use method methods to override the method.
Object proxyobj = proxy.newproxyinstance (parameter 1, parameter 2, parameter 3);
Parameter 1:ClassLoader, which is responsible for dynamically creating classes, loads into memory. The current class . Class.getclassloader ();
Parameter 2:class[] interfaces, the proxy class needs to implement all the interfaces (deterministic methods)that are represented by the class instance . GetClass (). Getinterfaces ();
Parameter 3:Invocationhandler, the request processing class, the proxy class does not have any function, when each method of the proxy class executes, invokes the processing class invoke method.
Voke (Object proxy , Method, object[] args)
Parameter 1: proxy instance
Parameter 2: currently executing method
Parameter 3: Method actual parameters.
The dynamic agent of Java EE