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

做影视免费网站违法吗全国最大的招商平台

做影视免费网站违法吗,全国最大的招商平台,软件下载网站整站源码,全球营销策划公司排名1、概念 1.1 介绍 二十三种设计模式中的一种#xff0c;属于结构型模式。它的作用就是通过提供一个代理类#xff0c;让我们在调用目标方法的时候#xff0c;不再是直接对目标方法进行调用#xff0c;而是通过代理类间接调用。让不属于目标方法核心逻辑的代码从目标方法中…1、概念 1.1 介绍 二十三种设计模式中的一种属于结构型模式。它的作用就是通过提供一个代理类让我们在调用目标方法的时候不再是直接对目标方法进行调用而是通过代理类间接调用。让不属于目标方法核心逻辑的代码从目标方法中剥离出来——解耦。调用目标方法时先调用代理对象的方法减少对目标方法的调用和打扰同时让附加功能能够集中在一起也有利于统一维护。 使用代理后 ②生活中的代理 广告商找大明星拍广告需要经过经纪人合作伙伴找大老板谈合作要约见面时间需要经过秘书房产中介是买卖双方的代理 1.2 相关术语 代理将非核心逻辑剥离出来以后封装这些非核心逻辑的类、对象、方法。目标被代理“套用”了非核心逻辑代码的类、对象、方法。 2 静态代理 public interface Calculator {int add(int i, int j);int sub(int i, int j);int mul(int i, int j);int div(int i, int j);}package com.giser.java.spring6.calcu.impl;import com.giser.java.spring6.calcu.Calculator;/*** author giserDev* description 基础实现* date 2024-01-06 23:41:55*/public class CalculatorImpl implements Calculator {Overridepublic int add(int i, int j) {int result i j;System.out.println(方法内部 result result);return result;}Overridepublic int sub(int i, int j) {int result i - j;System.out.println(方法内部 result result);return result;}Overridepublic int mul(int i, int j) {int result i * j;System.out.println(方法内部 result result);return result;}Overridepublic int div(int i, int j) {int result i / j;System.out.println(方法内部 result result);return result;}}创建静态代理类 package com.giser.java.spring6.calcu.impl;import com.giser.java.spring6.calcu.Calculator;/*** author giserDev* description* 提出问题** ①现有代码缺陷** 针对带日志功能的实现类我们发现有如下缺陷** - 对核心业务功能有干扰导致程序员在开发核心业务功能时分散了精力* - 附加功能分散在各个业务功能方法中不利于统一维护** ②解决思路** 解决这两个问题核心就是解耦。我们需要把附加功能从业务功能代码中抽取出来。** ③困难** 解决问题的困难要抽取的代码在方法内部靠以前把子类中的重复代码抽取到父类的方式没法解决。所以需要引入新的技术。* date 2024-01-06 23:43:25*/public class CalculatorLogImpl implements Calculator {Overridepublic int add(int i, int j) {System.out.println([日志] add 方法开始了参数是 i , j);int result i j;System.out.println(方法内部 result result);System.out.println([日志] add 方法结束了结果是 result);return result;}Overridepublic int sub(int i, int j) {System.out.println([日志] sub 方法开始了参数是 i , j);int result i - j;System.out.println(方法内部 result result);System.out.println([日志] sub 方法结束了结果是 result);return result;}Overridepublic int mul(int i, int j) {System.out.println([日志] mul 方法开始了参数是 i , j);int result i * j;System.out.println(方法内部 result result);System.out.println([日志] mul 方法结束了结果是 result);return result;}Overridepublic int div(int i, int j) {System.out.println([日志] div 方法开始了参数是 i , j);int result i / j;System.out.println(方法内部 result result);System.out.println([日志] div 方法结束了结果是 result);return result;}}静态代理的问题 静态代理确实实现了解耦但是由于代码都写死了完全不具备任何的灵活性。就拿日志功能来说将来其他地方也需要附加日志那还得再声明更多个静态代理类那就产生了大量重复的代码日志功能还是分散的没有统一管理。提出进一步的需求将日志功能集中到一个代理类中将来有任何日志需求都通过这一个代理类来实现。这就需要使用动态代理技术了。3 动态代理 package com.giser.spring6.calcu.impl.dynamicproxy;import java.lang.reflect.InvocationHandler; import java.lang.reflect.Method; import java.lang.reflect.Proxy; import java.util.Arrays;/*** author giserDev* description 代理工厂类* date 2024-01-06 23:52:21*/ public class DynamicProxyFactory {/*** 被持有的被代理对象*/private Object target;public DynamicProxyFactory(Object target) {this.target target;}/*** 创建代理对象* return 代理对象*/public Object getProxy(){return Proxy.newProxyInstance(// 代理对象的类加载器target.getClass().getClassLoader(),// 代理对象实现的接口列表target.getClass().getInterfaces(),// 处理器new InvocationHandler() {/**** param proxy the proxy instance that the method was invoked on* 代理对象** param method the {code Method} instance corresponding to* the interface method invoked on the proxy instance. The declaring* class of the {code Method} object will be the interface that* the method was declared in, which may be a superinterface of the* proxy interface that the proxy class inherits the method through.* 代理对象需要实现的方法** param args an array of objects containing the values of the* arguments passed in the method invocation on the proxy instance,* or {code null} if interface method takes no arguments.* Arguments of primitive types are wrapped in instances of the* appropriate primitive wrapper class, such as* {code java.lang.Integer} or {code java.lang.Boolean}.* method对应的方法参数** return* throws Throwable*/Overridepublic Object invoke(Object proxy, Method method, Object[] args) throws Throwable {Object result null;try {System.out.println([动态代理][日志] method.getName()参数 Arrays.toString(args));result method.invoke(target, args);System.out.println([动态代理][日志] method.getName()结果 result);} catch (Exception e) {e.printStackTrace();System.out.println([动态代理][日志] method.getName()异常e.getMessage());} finally {System.out.println([动态代理][日志] method.getName()方法执行完毕);}return result;}});}}测试 package com.giser.spring6;import com.giser.spring6.calcu.Calculator; import com.giser.spring6.calcu.impl.CalculatorImpl; import com.giser.spring6.calcu.impl.dynamicproxy.DynamicProxyFactory;/*** author giserDev* description 动态代理测试* date 2024-01-07 00:02:54*/ public class DynamicProxyTest {public static void main(String[] args) {DynamicProxyFactory dynamicProxyFactory new DynamicProxyFactory(new CalculatorImpl());Calculator proxy (Calculator) dynamicProxyFactory.getProxy();int add proxy.add(1, 3);}}
http://www.zqtcl.cn/news/113422/

相关文章:

  • 网站semseo先做哪个关键词投放
  • 药品招商网站大全南阳做网站公司电话
  • 优秀手机网站大学生创新产品设计作品
  • 备案期间关闭网站宝应人才网
  • 响应式网站一般做几个版本官网+wordpress
  • 太原网站建设方案服务佛山市建设工程有限公司
  • 智能网站建设平台php mysql 网站源码
  • 夏天做那些网站能致富百度关键词价格怎么查询
  • 厦门微信网站专业从事网站开发公司
  • 网站标题的写法湖南如何做网络营销
  • 设计做兼职的网站求推荐医院英文网站建设
  • 有没得办法可以查询一个网站有没得做竞价呀ai可以用来做网站吗
  • 俄乌局势最新消息惠州seo排名优化
  • 常州发布信息的有什么网站电商平台建设公司
  • 高新区手机网站建设长沙关键词优化服务
  • 网站开发预算报价表推销网站的方法
  • 做网站需要几个人昆明旅行社网站开发
  • 上海产品网站建设网站建设分为哪些
  • 史志网站建设在线网站建设工程标准
  • 青海省建设工程在哪个网站发布北京专业网站外包公司
  • 东营网站建设公司wordpress获取子分类
  • 网站的尾页要怎么做d代码做网站
  • 自己做一元购网站烟台网站设计公司推荐
  • 有没有做彩票直播的网站成都十八个网红打卡地
  • 急求聊城网站建设网站服务器管理系统
  • 做网站需要什么许可证商场设计效果图
  • html网页制作视频windows优化大师有哪些功能
  • 国外建站主机帝国手机网站cms系统
  • 响应式网站建设哪家好网站空间支付方式
  • 腾讯广告建站工具贵州企业网站建设价格