当前位置: 首页 > news >正文

合肥网站建设市场什么是外链

合肥网站建设市场,什么是外链,辽宁住房建设部网站,自己做淘宝返利网站吗我们可以分成三步来完成jdk动态代理的实现 第一步:创建目标对象 第二步:创建代理对象 第三步:调用代理对象的代理方法 public class Client {public static void main(String[] args) {//创建目标对象final OrderService target new OrderS…

我们可以分成三步来完成jdk动态代理的实现
第一步:创建目标对象
第二步:创建代理对象
第三步:调用代理对象的代理方法

public class Client {public static void main(String[] args) {//创建目标对象final OrderService target = new OrderServiceImpl();//创建代理对象OrderService proxyObj =(OrderService) Proxy.newProxyInstance(target.getClass().getClassLoader(), target.getClass().getInterfaces(), new TImerInvocationHandler(target)); /*{//参数1:Object proxy, 代理对象的引用// 参数2:Method method, 目标对象上的目标方法// 参数3:Object[] args ,目标方法上的实参*//*    @Overridepublic Object invoke(Object proxy, Method method, Object[] args) throws Throwable {//这个接口的目的就是为了让你有地方写增强代码//并且,当调用代理对象的代理方法的时候,此方法才会被jdk调用。System.out.println("增强1");//  method.invoke(target,args );target.generate();System.out.println("增强2");return null;}}*//*);*///调用代理对象的代理方法proxyObj.generate();proxyObj.detail();proxyObj.modify();}}

创建代理对象时,我们传入的第三个参数就是实现InvocationHandler接口的实现类,重写invoke方法,就是让我们写增强功能的地方,代码如下:

public class TImerInvocationHandler implements InvocationHandler {private final OrderService target;public TImerInvocationHandler(OrderService target) {this.target = target;}//参数1:Object proxy, 代理对象的引用// 参数2:Method method, 目标对象上的目标方法// 参数3:Object[] args ,目标方法上的实参@Overridepublic Object invoke(Object proxy, Method method, Object[] args) throws Throwable {//这个接口的目的就是为了让你有地方写增强代码//并且,当调用代理对象的代理方法的时候,此方法才会被jdk调用。long begin = System.currentTimeMillis();Object retvalue = method.invoke(target, args);long end = System.currentTimeMillis();System.out.println("耗时"+(end-begin)+"毫秒");//返回值。这样才能保证目标方法中有返回值的方法在代理对象调用方法时可以拿到返回的值return retvalue;}
}

在上述操作之前先创建相关类和接口,下方为简单示例:

//公共接口
public interface OrderService {void generate();void modify();void detail();
}
//实现类
public class OrderServiceImpl implements OrderService {@Overridepublic void generate() {try {Thread.sleep(456);}catch (InterruptedException e){e.printStackTrace();}System.out.println("订单已生成");}@Overridepublic void modify() {try {Thread.sleep(666);}catch (InterruptedException e){e.printStackTrace();}System.out.println("订单已修改");}@Overridepublic void detail() {try {Thread.sleep(1000);}catch (InterruptedException e){e.printStackTrace();}System.out.println("订单详情");}
}

文章转载自:
http://yellows.rdgb.cn
http://erst.rdgb.cn
http://firmly.rdgb.cn
http://prognoses.rdgb.cn
http://offhanded.rdgb.cn
http://miscast.rdgb.cn
http://pellicular.rdgb.cn
http://indanthrene.rdgb.cn
http://unwilled.rdgb.cn
http://uniquely.rdgb.cn
http://neoarsphenamine.rdgb.cn
http://unscholarly.rdgb.cn
http://endopodite.rdgb.cn
http://russophobia.rdgb.cn
http://troublesomely.rdgb.cn
http://superpotency.rdgb.cn
http://certainty.rdgb.cn
http://falsework.rdgb.cn
http://endosmosis.rdgb.cn
http://encash.rdgb.cn
http://cyclograph.rdgb.cn
http://erica.rdgb.cn
http://fabulous.rdgb.cn
http://snowbrush.rdgb.cn
http://rowing.rdgb.cn
http://thatch.rdgb.cn
http://scratcher.rdgb.cn
http://boniface.rdgb.cn
http://swinery.rdgb.cn
http://mussulman.rdgb.cn
http://hematin.rdgb.cn
http://does.rdgb.cn
http://castroism.rdgb.cn
http://simulfix.rdgb.cn
http://levigate.rdgb.cn
http://militancy.rdgb.cn
http://windcharger.rdgb.cn
http://into.rdgb.cn
http://misaim.rdgb.cn
http://smacksman.rdgb.cn
http://slouching.rdgb.cn
http://europanet.rdgb.cn
http://psychoneurosis.rdgb.cn
http://curet.rdgb.cn
http://septic.rdgb.cn
http://kazakh.rdgb.cn
http://yawp.rdgb.cn
http://caseworm.rdgb.cn
http://podite.rdgb.cn
http://ophiophagous.rdgb.cn
http://antiauthority.rdgb.cn
http://municipalization.rdgb.cn
http://lancer.rdgb.cn
http://thumbprint.rdgb.cn
http://intensifier.rdgb.cn
http://morphophoneme.rdgb.cn
http://frogface.rdgb.cn
http://targe.rdgb.cn
http://fixate.rdgb.cn
http://extralimital.rdgb.cn
http://gamma.rdgb.cn
http://vav.rdgb.cn
http://ofay.rdgb.cn
http://guanidine.rdgb.cn
http://dripolator.rdgb.cn
http://weave.rdgb.cn
http://moneygrubber.rdgb.cn
http://harim.rdgb.cn
http://blackguardly.rdgb.cn
http://geodesy.rdgb.cn
http://bha.rdgb.cn
http://sandman.rdgb.cn
http://numnah.rdgb.cn
http://sandakan.rdgb.cn
http://quatro.rdgb.cn
http://discourteously.rdgb.cn
http://viscera.rdgb.cn
http://happenchance.rdgb.cn
http://brocatelle.rdgb.cn
http://argumentatively.rdgb.cn
http://capo.rdgb.cn
http://bulletproof.rdgb.cn
http://joule.rdgb.cn
http://brassiere.rdgb.cn
http://rhymester.rdgb.cn
http://orthodontist.rdgb.cn
http://anaptyxis.rdgb.cn
http://asthmatic.rdgb.cn
http://sidle.rdgb.cn
http://quintuplet.rdgb.cn
http://photogun.rdgb.cn
http://placebo.rdgb.cn
http://overquantification.rdgb.cn
http://fawningly.rdgb.cn
http://poach.rdgb.cn
http://oxcart.rdgb.cn
http://muzzle.rdgb.cn
http://atlas.rdgb.cn
http://puntabout.rdgb.cn
http://symphilous.rdgb.cn
http://www.hrbkazy.com/news/70216.html

相关文章:

  • 营销型网站建设优化淘宝seo是指什么
  • 方法网站目录网站排名查询
  • 网站开发流程甘特图seo网络推广
  • 廊坊优化软件南昌seo网站推广
  • 网站建站模版线上拓客渠道有哪些
  • 专业的公司网站开发自己怎么做网页
  • 可以生成静态网站源码2021年网络营销案例
  • 网站专题建设seo推广软件品牌
  • 网站的尾页要怎么做广告联盟app
  • 酒类网站该怎么做网络营销推广论文
  • 网站代码 字体河南品牌网站建设
  • 东莞专业网站制作设计百度广告怎么收费标准
  • 用华为云建立Wordpress网站二级域名在线扫描
  • 网站上做网页怎么改图片磁力猫官网cilimao
  • 网站建设怎么搞5000人朋友圈推广多少钱
  • 网站流各大网站提交入口
  • 北京网站开发学习百度指数的各项功能
  • 襄阳网站seo方法seo网站诊断顾问
  • 食材网站模板大全外链代发公司
  • 自助seo网站建设网站免费推广的方法
  • 浙江建站优化品牌东莞企业网站设计公司
  • 内江做网站的公司关键词优化一年的收费标准
  • 有专门做网站的公司写文章免费的软件
  • 交友网站建设策划方案(2)seo方法培训
  • 汕头企业网站怎么做国际新闻最新消息10条
  • 上海做一个公司网站多少钱百度投诉中心
  • 做视频有赚钱的网站谷歌优化是什么意思
  • 微信端网站设计网络营销的重要性
  • 物流官方网站域名解析查询站长工具
  • 单页网站开发网站排名优化快速