PART 1 Understand How To Use JDK Dynamic Proxy
If you know it, you have to admit that the JDK Dynamic Proxy is designed elegantly. We can encapsulate the interceptor logic in a class which implements the InvocationHandler interface, after that we are able to dynamically create a proxy instance by calling Proxy.newProxyInstance(classloader, class, invocationhandler). Simple enough, Hum?
PART 2 The Limitations Of JDK Dynamic Proxy
The proxy is interface oriented. Intrusive. Sometimes we need to create a proxy for a class indeed, rather than an interface. So cglib comes into play.
PART 3 How To Use cglib
cglib shares similar usage with JDK Proxy Dynamic. First, we encapsulate the interceptor logic in a class which implements the MethodInterceptor interface, then we call Enhancer's create() to instantiate a proxy dynamically.
Another noteworthy part is cglib's CallbackFilter. What's the counterpart of JDK Dynamic Proxy?
PART 4 Spring
Spring employs JDK Dynamic Proxy for interface proxy, and cglib for class proxy.
PART 5 Hibernate