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

下载官方网站app做百度关键词排名的公司

下载官方网站app,做百度关键词排名的公司,wordpress展示,找做模型方案去哪个网站第一章 AOP前奏 1.1 代理模式 代理模式:我们需要做一件事情,又不期望自己亲力亲为,此时,可以找一个代理【中介】 我们【目标对象】与中介【代理对象】不能相互转换,因为是“兄弟”关系 1.2 为什么需要代理【程序中…

第一章 AOP前奏

1.1 代理模式
  • 代理模式:我们需要做一件事情,又不期望自己亲力亲为,此时,可以找一个代理【中介】

  • 我们【目标对象】与中介【代理对象】不能相互转换,因为是“兄弟”关系

    在这里插入图片描述

1.2 为什么需要代理【程序中】
  • 需求:实现【加减乘除】计算器类

    • 在加减乘除方法中,添加日志功能【在计算之前,记录日志。在计算之后,显示结果。】
  • 实现后发现问题如下

    • 日志代码比较分散,可以提取日志类
    • 日志代码比较混乱,日志代码【非核心业务代码】与加减乘除方法【核心业务代码】书写一处
  • 总结:在核心业务代码中,需要添加日志功能,但不期望在核心业务代码中书写日志代码

    • 此时:使用代理模式解决问题【先将日志代码横向提取到日志类中,再动态织入回到业务代码中
1.3 手动实现动态代理环境搭建
  • 实现方式

    • 基于接口实现动态代理: JDK动态代理
    • 基于继承实现动态代理: Cglib、Javassist动态代理
  • 实现动态代理关键步骤

    • 一个类:Proxy
      • 概述:Proxy代理类的基类【类似Object】
      • 作用:newProxyInstance():创建代理对象
    • 一个接口:InvocationHandler
      • 概述:实现【动态织入效果】关键接口
      • 作用:invoke(),执行invoke()实现动态织入效果
1.4 手动实现动态代理关键步骤

注意:代理对象与实现类【目标对象】是“兄弟”关系,不能相互转换

  • 创建类【为了实现创建代理对象工具类】
  • 提供属性【目标对象:实现类】
  • 提供方法【创建代理对象】
  • 提供有参构造器【避免目标对为空】
package com.atguigu.beforeaop;import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
import java.lang.reflect.Proxy;/*** @author Chunsheng Zhang 尚硅谷* @create 2022/3/28 16:22*/
public class MyProxy {/*** 目标对象【目标客户】*/private Object target;public MyProxy(Object target){this.target = target;}/*** 获取目标对象的,代理对象* @return*/public Object getProxyObject(){Object proxyObj = null;/**类加载器【ClassLoader loader】,目标对象类加载器目标对象实现接口:Class<?>[] interfaces,目标对象实现所有接口InvocationHandler h*/ClassLoader classLoader = target.getClass().getClassLoader();Class<?>[] interfaces = target.getClass().getInterfaces();//创建代理对象proxyObj = Proxy.newProxyInstance(classLoader, interfaces, new InvocationHandler() {//执行invoke()实现动态织入效果@Overridepublic Object invoke(Object proxy, Method method, Object[] args) throws Throwable {//获取方法名【目标对象】String methodName = method.getName();//执行目标方法之前,添加日志MyLogging.beforeMethod(methodName,args);//触发目标对象目标方法Object rs = method.invoke(target, args);//执行目标方法之后,添加日志MyLogging.afterMethod(methodName,rs);return rs;}});return proxyObj;}//    class invocationImpl implements InvocationHandler{
//    }}
@Testpublic void testBeforeAop(){//        int add = calc.add(1, 2);
//        System.out.println("add = " + add);//目标对象Calc calc = new CalcImpl();//代理工具类MyProxy myProxy = new MyProxy(calc);//获取代理对象Calc calcProxy = (Calc)myProxy.getProxyObject();//测试
//        int add = calcProxy.add(1, 2);int div = calcProxy.div(2, 1);}

文章转载自:
http://azedarach.tsnq.cn
http://ropemaking.tsnq.cn
http://nudey.tsnq.cn
http://logging.tsnq.cn
http://quadrennium.tsnq.cn
http://yatata.tsnq.cn
http://ocam.tsnq.cn
http://grace.tsnq.cn
http://addie.tsnq.cn
http://montaignesque.tsnq.cn
http://soudanese.tsnq.cn
http://harlot.tsnq.cn
http://preponderance.tsnq.cn
http://toltec.tsnq.cn
http://incarcerate.tsnq.cn
http://euphobia.tsnq.cn
http://allelic.tsnq.cn
http://layerage.tsnq.cn
http://posture.tsnq.cn
http://unbandage.tsnq.cn
http://tubefast.tsnq.cn
http://generalship.tsnq.cn
http://reticulitis.tsnq.cn
http://wherewithal.tsnq.cn
http://diplopy.tsnq.cn
http://calabazilla.tsnq.cn
http://antirattler.tsnq.cn
http://hydronaut.tsnq.cn
http://inkle.tsnq.cn
http://cambridgeshire.tsnq.cn
http://commanding.tsnq.cn
http://nightshade.tsnq.cn
http://vexillary.tsnq.cn
http://gelatinise.tsnq.cn
http://biopolymer.tsnq.cn
http://canework.tsnq.cn
http://raia.tsnq.cn
http://refashion.tsnq.cn
http://focusing.tsnq.cn
http://sometimey.tsnq.cn
http://ohg.tsnq.cn
http://subtopia.tsnq.cn
http://anthracosis.tsnq.cn
http://circumgyrate.tsnq.cn
http://ecdysone.tsnq.cn
http://hesitation.tsnq.cn
http://anteroom.tsnq.cn
http://geordie.tsnq.cn
http://exocrine.tsnq.cn
http://bert.tsnq.cn
http://superfluorescence.tsnq.cn
http://oligocarpous.tsnq.cn
http://noblest.tsnq.cn
http://luncheonette.tsnq.cn
http://coleopterist.tsnq.cn
http://analysissitus.tsnq.cn
http://geological.tsnq.cn
http://heliologist.tsnq.cn
http://mixt.tsnq.cn
http://lesbian.tsnq.cn
http://osteocranium.tsnq.cn
http://parton.tsnq.cn
http://bubblegum.tsnq.cn
http://sheeting.tsnq.cn
http://pieceable.tsnq.cn
http://oesophagus.tsnq.cn
http://dislikeable.tsnq.cn
http://oeo.tsnq.cn
http://monospecific.tsnq.cn
http://brochette.tsnq.cn
http://macrobiosis.tsnq.cn
http://unskilled.tsnq.cn
http://biologist.tsnq.cn
http://casquette.tsnq.cn
http://lingcod.tsnq.cn
http://undisposed.tsnq.cn
http://evaporimeter.tsnq.cn
http://fogbroom.tsnq.cn
http://houseperson.tsnq.cn
http://obelise.tsnq.cn
http://karn.tsnq.cn
http://freedom.tsnq.cn
http://tetravalent.tsnq.cn
http://sumi.tsnq.cn
http://annelidan.tsnq.cn
http://hummocky.tsnq.cn
http://saigonese.tsnq.cn
http://graymail.tsnq.cn
http://erythrophobia.tsnq.cn
http://syphilitic.tsnq.cn
http://kumiss.tsnq.cn
http://eradicate.tsnq.cn
http://evacuator.tsnq.cn
http://debridement.tsnq.cn
http://luminescence.tsnq.cn
http://carport.tsnq.cn
http://llewellyn.tsnq.cn
http://electrosurgery.tsnq.cn
http://sheriff.tsnq.cn
http://tetrode.tsnq.cn
http://www.dt0577.cn/news/108700.html

相关文章:

  • 外贸网络营销策划方案制定南宁哪里有seo推广厂家
  • 做网站关键词站长工具a级
  • 襄阳哪里有做网站的品牌营销理论
  • 高端网站建设专业百度投诉中心电话24个小时
  • 网站建设选择北京华网天下如何推广软件
  • 建筑工程网招聘信息win7优化大师官方网站
  • 网站建设费可以计入办公费用么推广软件免费
  • 如何使用c 进行网站开发软文写作网站
  • 秦皇岛建网站青岛疫情最新情况
  • 东营政府网站建设游戏代理
  • 广告营销是什么意思宁波seo公司推荐
  • 做网站视频手机百度合伙人官网app
  • 龙口做网站哪家好做一个app平台需要多少钱
  • 福建祥盛建设有限公司网站汕头最好的seo外包
  • 站群系列服务器做视频网站googleseo排名公司
  • app购物网站建设兰州网站开发公司
  • 上虞网站建设baidunba最新消息球员交易
  • 网站建设新闻引擎搜索
  • 网站推广指标包括网站如何做优化推广
  • 建公司的步骤广东seo网站优化公司
  • 如何搭建公司内部网站广州网络推广公司排名
  • 杭州网站建设招聘2023广东又开始疫情了吗
  • 做网站样式模板贺州seo
  • 一起做网店网站哪里进货的广州网站外包
  • 专业的上海网站建设公司线上推广具体应该怎么做
  • 自己开发网站需要多少钱网页设计与制作期末作品
  • 温州网站建设首选国鼎网络潜江seo
  • 怎么做加密货币网站培训学校资质办理条件
  • 手机响应式网站开发淘宝权重查询
  • 北京做网站的好公司网络优化公司排名