当前位置:网站首页>Dynamic proxy tool class
Dynamic proxy tool class
2022-08-02 03:32:00 【Tom has no Cat】
import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
import java.lang.reflect.Proxy;
public class ProxyInvocationHandler implements InvocationHandler {
/** * 被代理的接口 */
private Object target;
public void setRent(Rent rent) {
this.target = rent;
}
/** * 生成得到代理类 * @return */
public Object getProxy() {
return Proxy.newProxyInstance(this.getClass().getClassLoader(),target.getClass().getInterfaces(),this);
}
/** * 处理代理实例并返回结果 * @param proxy * @param method * @param args * @return * @throws Throwable */
@Override
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
Object result = method.invoke(target, args);
return result;
}
}
边栏推荐
- Double Strings (别总忘记substr)
- 磷脂-聚乙二醇-叠氮,DSPE-PEG-Azide,DSPE-PEG-N3,MW:5000
- 错误:with open(txt_path,‘r‘) as f: FileNotFoundError: [Errno 2] No such file or directory:
- oracle内连接和外连接
- mysql中json类型字段用法
- 2022.7.30 js notes Operators and flow controllers, loops
- 2022ACM夏季集训周报(五)
- MySQL分库分表
- LeetCode:第304场周赛【总结】
- 手把手带你 Unity 入门之从零创建一个时钟(GameObjects 与 Scripts)
猜你喜欢
随机推荐
Redis笔记进阶篇:万字长文-整理Redis,各种知识点,建议收藏
Good Key, Bad Key (thinking, temporary exchange, classic method)
HCIP第十一天_MPLS实验
getattr()函数解析
脚手架安装
[详解C语言]一文带你玩转C语言小游戏---扫雷
连接数据库时遇到的bug1号
Error: with open(txt_path,'r') as f: FileNotFoundError: [Errno 2] No such file or directory:
线性代数学习笔记3-1:矩阵与线性变换、常见矩阵(逆矩阵、伴随矩阵、正交矩阵等)
ImportError: libGL.so.1: cannot open shared object file: No such file or directory
代码随想录笔记_哈希_383赎金信
CV-Model【4】:MobileNet v3
Brute force visitors
Freeswitch操作基本配置
5.nodejs--跨域、CORS、JSONP 、Proxy
Redis的集群模式
【C语言万字长文】 宏定义 结构体 共用体 内存对齐知识点总结
我的两周年创作纪念日
A senior test engineer asked me these questions as soon as the interview came
SOCKS5
![OD-Model [4]: SSD](/img/ad/4ffb3e56538aa38b03173d79d9d213.jpg)








