public final class ProxyUtil extends Object
| Constructor and Description |
|---|
ProxyUtil() |
| Modifier and Type | Method and Description |
|---|---|
static <T> T |
newProxyInstance(ClassLoader classloader,
InvocationHandler invocationHandler,
Class<?>... interfaces)
创建动态代理对象
动态代理对象的创建原理是: 假设创建的代理对象名为 $Proxy0 1、根据传入的interfaces动态生成一个类,实现interfaces中的接口 2、通过传入的classloder将刚生成的类加载到jvm中。 |
static <T> T |
newProxyInstance(InvocationHandler invocationHandler,
Class<?>... interfaces)
创建动态代理对象
|
static <T> T |
proxy(T target,
Aspect aspect)
使用切面代理对象
|
static <T> T |
proxy(T target,
Class<? extends Aspect> aspectClass)
使用切面代理对象
|
public static <T> T proxy(T target,
Class<? extends Aspect> aspectClass)
T - 切面对象类型target - 目标对象aspectClass - 切面对象类public static <T> T proxy(T target,
Aspect aspect)
T - 被代理对象类型target - 被代理对象aspect - 切面对象public static <T> T newProxyInstance(ClassLoader classloader, InvocationHandler invocationHandler, Class<?>... interfaces)
InvocationHandler.invoke(Object, java.lang.reflect.Method, Object[]) 方法T - 被代理对象类型classloader - 被代理类对应的ClassLoaderinvocationHandler - InvocationHandler ,被代理类通过实现此接口提供动态代理功能interfaces - 代理类中需要实现的被代理类的接口方法public static <T> T newProxyInstance(InvocationHandler invocationHandler, Class<?>... interfaces)
T - 被代理对象类型invocationHandler - InvocationHandler ,被代理类通过实现此接口提供动态代理功能interfaces - 代理类中需要实现的被代理类的接口方法Copyright © 2025. All rights reserved.