public final class ProxyUtils extends Object
| 构造器和说明 |
|---|
ProxyUtils() |
| 限定符和类型 | 方法和说明 |
|---|---|
static <A extends Annotation> |
create(Class<A> annotationType,
Map<String,Object> attributes)
Creates proxied annotation type object
|
static <T> T |
create(CombinedInvocationHandler invocationHandler,
Class<?> cls) |
static <T> T |
create(InvocationHandler invocationHandler,
Class<?>... cls)
Creates proxy instance based jdk
|
static <T> T |
create(org.springframework.cglib.proxy.InvocationHandler invocationHandler,
Class<?> superCls)
Creates proxy instance based cglib
需要默认的无参构造函数
|
static <T> Constructor<T> |
getProxyConstructor(Class<T> cls) |
static Object |
getTargetObject(Object object)
获取原始对象(被代理的对象),如:`Service`中的方法加了`@Transactional`注解,`Controller`中被注入的`Service`实际是代理对象,
可以使用`getTargetObject`获取原始的`Service`对象
|
public static <T> T create(InvocationHandler invocationHandler, Class<?>... cls)
T - the interface typeinvocationHandler - the jdk invocation handlercls - the interface classespublic static <T> T create(org.springframework.cglib.proxy.InvocationHandler invocationHandler,
Class<?> superCls)
需要默认的无参构造函数
T - the super class typeinvocationHandler - the spring cglib invocation handlersuperCls - the super classpublic static <T> T create(CombinedInvocationHandler invocationHandler, Class<?> cls)
public static <T> Constructor<T> getProxyConstructor(Class<T> cls)
public static <A extends Annotation> A create(Class<A> annotationType, Map<String,Object> attributes)
A - annotation typeannotationType - the annotation typeattributes - the attribute mapCopyright © 2025. All rights reserved.