当前位置:网站首页>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;
}
}
边栏推荐
猜你喜欢
随机推荐
错误:with open(txt_path,‘r‘) as f: FileNotFoundError: [Errno 2] No such file or directory:
数据库操作作业
MySQL分页查询的5种方法
【程序人生】做了多年的运维,靠什么转行拿下12K+年终奖的薪资?
Monaco Editor 的基本用法
磷脂-聚乙二醇-酰肼,DSPE-PEG-Hydrazide,DSPE-PEG-HZ,MW:5000
腾讯50题
A senior test engineer asked me these questions as soon as the interview came
oracle内连接和外连接
小程序组件总结
Good Key, Bad Key (thinking, temporary exchange, classic method)
JSP WebSehll backdoor script
MySQL中JOIN的用法
@DateTimeFormat注解
连接数据库时遇到的bug1号
Chapter 10 Clustering
TRICK第二弹
知识工程作业2:知识工程相关领域介绍
@ApiModel 和 @ApiModelProperty
我的两周年创作纪念日









