Class CglibProxyFactory

java.lang.Object
com.ultikits.ultitools.aop.CglibProxyFactory

public class CglibProxyFactory extends Object
Factory for creating CGLIB-based proxies.

CGLIB proxies work by generating a subclass of the target class, which allows proxying classes without interfaces (unlike JDK dynamic proxies).

Limitations:

  • Cannot proxy final classes
  • Cannot intercept final methods
  • Self-invocation (this.method()) bypasses the proxy
Since:
6.2.0
Author:
wisdomme
  • Field Details

  • Constructor Details

    • CglibProxyFactory

      public CglibProxyFactory(List<MethodInterceptor> interceptors)
      Creates a new CGLIB proxy factory with the given interceptors.
      Parameters:
      interceptors - the interceptors to apply to proxied methods
  • Method Details

    • createProxy

      public <T> T createProxy(T target)
      Creates a proxy for the given target object.
      Type Parameters:
      T - the type of the target
      Parameters:
      target - the object to proxy
      Returns:
      a proxy instance
    • createProxy

      public <T> T createProxy(Class<T> targetClass, T target)
      Creates a proxy for the given target class and instance.
      Type Parameters:
      T - the type of the target
      Parameters:
      targetClass - the class to create a proxy for
      target - the actual target instance
      Returns:
      a proxy instance