Class AbstractInvocationHandler
java.lang.Object
cloud.opencode.base.reflect.proxy.AbstractInvocationHandler
- All Implemented Interfaces:
InvocationHandler
Abstract Invocation Handler
抽象调用处理器
Base class for creating custom invocation handlers. Provides default implementations for Object methods.
创建自定义调用处理器的基类。 为Object方法提供默认实现。
Features | 主要功能:
- Default equals/hashCode/toString handling - 默认equals/hashCode/toString处理
- Simplified handler implementation - 简化的处理器实现
Usage Examples | 使用示例:
InvocationHandler handler = new AbstractInvocationHandler() {
protected Object handleInvocation(Object proxy, Method method, Object[] args) {
return method.invoke(target, args);
}
};
Security | 安全性:
- Thread-safe: Depends on subclass implementation - 线程安全: 取决于子类实现
- Null-safe: No (caller must ensure non-null proxy) - 空值安全: 否(调用方须确保非空代理)
- Since:
- JDK 25, opencode-base-reflect V1.0.0
- Author:
- Leon Soo www.LeonSoo.com
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanprotected ObjecthandleDefaultMethod(Object proxy, Method method, Object[] args) Handles interface default methods 处理接口默认方法protected abstract ObjecthandleInvocation(Object proxy, Method method, Object[] args) Handles the actual method invocation 处理实际的方法调用protected ObjecthandleObjectMethod(Object proxy, Method method, Object[] args) Handles Object class methods 处理Object类方法inthashCode()final Objectprotected booleanproxyEquals(Object proxy, Object other) Determines equality for the proxy 确定代理的相等性protected intproxyHashCode(Object proxy) Computes hash code for the proxy 计算代理的哈希码protected StringproxyToString(Object proxy) Returns string representation for the proxy 返回代理的字符串表示
-
Constructor Details
-
AbstractInvocationHandler
protected AbstractInvocationHandler()Default constructor 默认构造器
-
-
Method Details
-
invoke
-
handleInvocation
protected abstract Object handleInvocation(Object proxy, Method method, Object[] args) throws Throwable Handles the actual method invocation 处理实际的方法调用- Parameters:
proxy- the proxy object | 代理对象method- the method | 方法args- the arguments | 参数- Returns:
- the result | 结果
- Throws:
Throwable- if an error occurs | 如果发生错误
-
handleObjectMethod
-
handleDefaultMethod
Handles interface default methods 处理接口默认方法- Parameters:
proxy- the proxy object | 代理对象method- the method | 方法args- the arguments | 参数- Returns:
- the result | 结果
- Throws:
Throwable- if an error occurs | 如果发生错误
-
proxyEquals
-
proxyHashCode
Computes hash code for the proxy 计算代理的哈希码- Parameters:
proxy- the proxy | 代理- Returns:
- the hash code | 哈希码
-
proxyToString
-
equals
-
hashCode
-