Package com.ultikits.ultitools.aop
Class CglibProxyFactory
java.lang.Object
com.ultikits.ultitools.aop.CglibProxyFactory
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
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate static classInternal CGLIB method interceptor that delegates to ourMethodInterceptorchain. -
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionCglibProxyFactory(List<MethodInterceptor> interceptors) Creates a new CGLIB proxy factory with the given interceptors. -
Method Summary
Modifier and TypeMethodDescription<T> TcreateProxy(Class<T> targetClass, T target) Creates a proxy for the given target class and instance.<T> TcreateProxy(T target) Creates a proxy for the given target object.
-
Field Details
-
interceptors
-
-
Constructor Details
-
CglibProxyFactory
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
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 fortarget- the actual target instance- Returns:
- a proxy instance
-