Currently, there are two main methods to implement dynamic proxy in Java:
A. Implement Dynamic proxy through the related classes in the Java. Lang. Reflect package
B. implemented through the open-source framework cglib, which is more flexible to implement
Cglib (code generation Library) is a powerful, high-performance, high-quality code generation class library. It can expand Java classes and implement Java interfaces at runtime.
Cglib encapsulates ASM and can dynamically generate new classes at runtime.
Cglib is used for AOP. The proxy in JDK must be based on the interface, but cglib does not have this restriction.
Cglib is the underlying implementation of some frameworks, such as the core packages that spring and hibernate depend on. However, cglib is not the underlying, because it is encapsulated on the ASM package, to enhance ease of use.
It is understood that hibernate3.2 no longer depends on cglib, but directly relies on ASM. These do not affect the powerful functions of cglib.
The bottom layer of cglib is the Java bytecode operating framework-ASM.
The following is an example of how to implement dynamic Proxy:
To be continued ....................