public class ProxyPlugin
extends java.lang.Object
动态代理插件
提供对象拦截器的功能,可以做到 AOP 的业务解耦
注意:
由于使用的是 CGlib,所以被代理的类不能是 final 修饰的,
也就是说必须要可以被继承,因为 CGlib 就是使用 ASM 产生子类和多态来达到动态代理的效果的,
另外,动态代理产生的实例是不是单例的和 Tuz 的配置有关,
详情请参考 cn.com.fishin.tuz.core.TuzConfig.isSingleton,
默认情况下是单例模式的,也就是说不管你创建多少代理对象都是同一个,
如果需要多例的模式,可以修改 Tuz 的配置,调用 cn.com.fishin.tuz.core.TuzConfig.setSingleton
Dynamic proxy plugin
It offers interceptor and aop functions
Notice:
Your target class must be not final, due to CGlib.
That means your target class must be extendable.
Another point to notice, this plugin generates proxy instance in two mode,
one is singleton, and the other one is non-singleton.
So, if you want to switch one to the other one, see cn.com.fishin.tuz.core.TuzConfig.setSingleton
Email: fishinlove@163.com
created by 2019/04/14 23:26:03
TuzConfig.setSingleton(boolean),
ProxyFactory.wrapByCGlib(Object, InvocationHandler),
ProxyFactory.wrapByJDK(Object, java.lang.reflect.InvocationHandler),
ProxyFactory.wrap(Object, Interceptor[])| 构造器和说明 |
|---|
ProxyPlugin() |
| 限定符和类型 | 方法和说明 |
|---|---|
static <T> T |
useInstance(java.lang.Class<T> classType,
boolean singleton,
Interceptor[] interceptors)
得到类被拦截器代理之后的实例
这里会根据 classType 的 getSimpleName() 去获取 key,并且利用反射生成实例对象
Get class instance after intercepting
Use reflect to instance a new object with given classType's simpleName
|
static <T> T |
useInstance(java.lang.Class<T> classType,
Interceptor[] interceptors)
得到类被拦截器代理之后的实例
这里会根据 classType 的 getSimpleName() 去获取 key,并且利用反射生成实例对象
注意这里的实例模式是根据 Tuz.getConfig().isSingleton() 中的设置来决定的
Get class instance after intercepting
Use reflect to instance a new object with given classType's simpleName
Notice that the mode creates the instance depends on Tuz.getConfig().isSingleton()
|
static <T> T |
useInstance(java.lang.String key,
java.lang.Class<T> classType,
boolean singleton,
Interceptor[] interceptors)
得到类被拦截器代理之后的实例
这里会根据 key 值获取 value,并且利用反射生成实例对象
Get class instance after intercepting
Use reflect to instance a new object with given value of key
|
static <T> T |
useInstance(java.lang.String key,
java.lang.Class<T> classType,
Interceptor[] interceptors)
得到类被拦截器代理之后的实例
这里会根据 key 值获取 value,并且利用反射生成实例对象
注意这里的实例模式是根据 Tuz.getConfig().isSingleton() 中的设置来决定的
Get class instance after intercepting
Use reflect to instance a new object with given value of key
Notice that the mode creates the instance depends on Tuz.getConfig().isSingleton()
|
static <T> T |
useInstance(java.lang.String key,
java.lang.String namespace,
java.lang.Class<T> classType,
boolean singleton,
Interceptor[] interceptors)
得到类被拦截器代理之后的实例
这里会根据 key 值获取 value,并且利用反射生成实例对象
Get class instance after intercepting
Use reflect to instance a new object with given value of key
|
static <T> T |
useInstance(java.lang.String key,
java.lang.String namespace,
java.lang.Class<T> classType,
Interceptor[] interceptors)
得到类被拦截器代理之后的实例
这里会根据 key 值获取 value,并且利用反射生成实例对象
注意这里的实例模式是根据 Tuz.getConfig().isSingleton() 中的设置来决定的
Get class instance after intercepting
Use reflect to instance a new object with given value of key
Notice that the mode creates the instance depends on Tuz.getConfig().isSingleton()
|
public static <T> T useInstance(java.lang.Class<T> classType,
boolean singleton,
Interceptor[] interceptors)
得到类被拦截器代理之后的实例
这里会根据 classType 的 getSimpleName() 去获取 key,并且利用反射生成实例对象
Get class instance after intercepting
Use reflect to instance a new object with given classType's simpleName
T - 实际类型
Real type
classType - 类对象的实际类类型
The real type of class instance
singleton - 是否以单例模式创建代理对象实例
Use singleton mode to create proxy instance or not
interceptors - 要使用的多个拦截器
All interceptor you want to use
返回得到的类被拦截器代理之后的实例
Return class instance after intercepting
public static <T> T useInstance(java.lang.Class<T> classType,
Interceptor[] interceptors)
得到类被拦截器代理之后的实例
这里会根据 classType 的 getSimpleName() 去获取 key,并且利用反射生成实例对象
注意这里的实例模式是根据 Tuz.getConfig().isSingleton() 中的设置来决定的
Get class instance after intercepting
Use reflect to instance a new object with given classType's simpleName
Notice that the mode creates the instance depends on Tuz.getConfig().isSingleton()
T - 实际类型
Real type
classType - 类对象的实际类类型
The real type of class instance
interceptors - 要使用的多个拦截器
All interceptor you want to use
返回得到的类被拦截器代理之后的实例
Return class instance after intercepting
Tuz.getConfig(),
TuzConfig.isSingleton()public static <T> T useInstance(java.lang.String key,
java.lang.Class<T> classType,
boolean singleton,
Interceptor[] interceptors)
得到类被拦截器代理之后的实例
这里会根据 key 值获取 value,并且利用反射生成实例对象
Get class instance after intercepting
Use reflect to instance a new object with given value of key
T - 实际类型
Real type
key - 根据这个 key 找到类的全名
Find the class by this key
classType - 类对象的实际类类型
The real type of class instance
singleton - 是否以单例模式创建代理对象实例
Use singleton mode to create proxy instance or not
interceptors - 要使用的多个拦截器
All interceptor you want to use
返回得到的类被拦截器代理之后的实例
Return class instance after intercepting
public static <T> T useInstance(java.lang.String key,
java.lang.Class<T> classType,
Interceptor[] interceptors)
得到类被拦截器代理之后的实例
这里会根据 key 值获取 value,并且利用反射生成实例对象
注意这里的实例模式是根据 Tuz.getConfig().isSingleton() 中的设置来决定的
Get class instance after intercepting
Use reflect to instance a new object with given value of key
Notice that the mode creates the instance depends on Tuz.getConfig().isSingleton()
T - 实际类型
Real type
key - 根据这个 key 找到类的全名
Find the class by this key
classType - 类对象的实际类类型
The real type of class instance
interceptors - 要使用的多个拦截器
All interceptor you want to use
返回得到的类被拦截器代理之后的实例
Return class instance after intercepting
Tuz.getConfig(),
TuzConfig.isSingleton()public static <T> T useInstance(java.lang.String key,
java.lang.String namespace,
java.lang.Class<T> classType,
boolean singleton,
Interceptor[] interceptors)
得到类被拦截器代理之后的实例
这里会根据 key 值获取 value,并且利用反射生成实例对象
Get class instance after intercepting
Use reflect to instance a new object with given value of key
T - 实际类型
Real type
key - 根据这个 key 找到类的全名
Find the class by this key
namespace - 指定的命名空间,用于区分不同的资源文件
Appointed namespace to different resource
classType - 类对象的实际类类型
The real type of class instance
singleton - 是否以单例模式创建代理对象实例
Use singleton mode to create proxy instance or not
interceptors - 要使用的多个拦截器
All interceptor you want to use
返回得到的类被拦截器代理之后的实例
Return class instance after intercepting
public static <T> T useInstance(java.lang.String key,
java.lang.String namespace,
java.lang.Class<T> classType,
Interceptor[] interceptors)
得到类被拦截器代理之后的实例
这里会根据 key 值获取 value,并且利用反射生成实例对象
注意这里的实例模式是根据 Tuz.getConfig().isSingleton() 中的设置来决定的
Get class instance after intercepting
Use reflect to instance a new object with given value of key
Notice that the mode creates the instance depends on Tuz.getConfig().isSingleton()
T - 实际类型
Real type
key - 根据这个 key 找到类的全名
Find the class by this key
namespace - 指定的命名空间,用于区分不同的资源文件
Appointed namespace to different resource
classType - 类对象的实际类类型
The real type of class instance
interceptors - 要使用的多个拦截器
All interceptor you want to use
返回得到的类被拦截器代理之后的实例
Return class instance after intercepting
Tuz.getConfig(),
TuzConfig.isSingleton()Copyright © 2019. All Rights Reserved.