Class ProxyFactory<T>
java.lang.Object
cloud.opencode.base.reflect.proxy.ProxyFactory<T>
- Type Parameters:
T- the primary interface type | 主接口类型
Proxy Factory
代理工厂
Fluent factory for creating dynamic proxies with various configurations.
用于创建具有各种配置的动态代理的流式工厂。
Features | 主要功能:
- Fluent proxy configuration API - 流式代理配置API
- Multiple interface support - 多接口支持
- Method-level interceptor binding - 方法级拦截器绑定
- Target delegation - 目标委托
Usage Examples | 使用示例:
MyService proxy = ProxyFactory.forInterface(MyService.class)
.target(realService)
.intercept(loggingInterceptor)
.create();
Security | 安全性:
- Thread-safe: No (builder pattern, not thread-safe during construction) - 线程安全: 否(构建器模式,构建期间非线程安全)
- Null-safe: No (caller must ensure non-null interface class) - 空值安全: 否(调用方须确保非空接口类)
- Since:
- JDK 25, opencode-base-reflect V1.0.0
- Author:
- Leon Soo www.LeonSoo.com
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classBuilder for creating proxy with lambda-style configuration 用Lambda风格配置创建代理的构建器 -
Method Summary
Modifier and TypeMethodDescriptionclassLoader(ClassLoader classLoader) Sets the ClassLoader 设置ClassLoadercreate()Creates the proxy 创建代理static <T> ProxyFactory<T> forInterface(Class<T> interfaceClass) Creates a ProxyFactory for an interface 为接口创建ProxyFactoryhandler(InvocationHandler handler) Sets a custom invocation handler 设置自定义调用处理器Adds an additional interface 添加额外接口intercept(MethodInterceptor interceptor) Sets the default interceptor 设置默认拦截器intercept(String methodName, MethodInterceptor interceptor) Sets an interceptor for a specific method 为特定方法设置拦截器intercept(String methodName, Class<?>[] parameterTypes, MethodInterceptor interceptor) Sets an interceptor for a specific method with parameter types 为特定方法(带参数类型)设置拦截器Sets a target object for delegation 设置委托的目标对象
-
Method Details
-
forInterface
Creates a ProxyFactory for an interface 为接口创建ProxyFactory- Type Parameters:
T- the interface type | 接口类型- Parameters:
interfaceClass- the interface class | 接口类- Returns:
- the factory | 工厂
-
implement
Adds an additional interface 添加额外接口- Parameters:
interfaceClass- the interface class | 接口类- Returns:
- this factory | 此工厂
-
classLoader
Sets the ClassLoader 设置ClassLoader- Parameters:
classLoader- the class loader | 类加载器- Returns:
- this factory | 此工厂
-
target
Sets a target object for delegation 设置委托的目标对象- Parameters:
target- the target object | 目标对象- Returns:
- this factory | 此工厂
-
intercept
Sets the default interceptor 设置默认拦截器- Parameters:
interceptor- the interceptor | 拦截器- Returns:
- this factory | 此工厂
-
intercept
Sets an interceptor for a specific method 为特定方法设置拦截器- Parameters:
methodName- the method name | 方法名interceptor- the interceptor | 拦截器- Returns:
- this factory | 此工厂
-
intercept
public ProxyFactory<T> intercept(String methodName, Class<?>[] parameterTypes, MethodInterceptor interceptor) Sets an interceptor for a specific method with parameter types 为特定方法(带参数类型)设置拦截器- Parameters:
methodName- the method name | 方法名parameterTypes- the parameter types | 参数类型interceptor- the interceptor | 拦截器- Returns:
- this factory | 此工厂
-
handler
Sets a custom invocation handler 设置自定义调用处理器- Parameters:
handler- the handler | 处理器- Returns:
- this factory | 此工厂
-
create
-