Skip to content

this is a project about java proxy, including JDK dynamic proxy and Cglib

Notifications You must be signed in to change notification settings

clayclayclay/java-proxy-demo

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 

Repository files navigation

java-proxy-demo

this is a project about java proxy, including:

  • jdk dynamic proxy
  • cglib

Jdk Dynamic Proxy

Involved Main Classes and Methods:

  • Proxy

    • Object Proxy.newProxyInstance((ClassLoader loader, Class<?>[] interfaces, InvocationHandler h)
  • InvocationHandler

    • Object InvocationHandler invoke(Object proxy, Method method, Object[] args) throws Throwable

Jdk Dynamic Proxy is a framework for Interface-oriented proxy type.

Cglib Dynamic Proxy

Involved Main Classes and Methods:

  • Enhancer

    • Object Enhancer.create(Class type, Callback callback);
  • MethodInterceptor

    • Object MethodInterceptor intercept(Object object, Method method, Object[] args, MethodProxy methodProxy) throws Throwable

Cglib can proxy any Object whether the target class implements Interface.

In Spring AOP Framework, the default is Jdk Dynamic Proxy, if the bean implements Interface, then Spring will automatically choose Cglib to init bean.

About

this is a project about java proxy, including JDK dynamic proxy and Cglib

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages