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

网站底部代码下载上海长宁网站建设

网站底部代码下载,上海长宁网站建设,做网站的软件初中生,论坛搭建一键java 职责链模式当应有几个处理器来执行某项操作并为这些处理器定义特定顺序时#xff0c;就需要采用责任链设计模式。 在运行时处理器顺序的可变性也很重要。模式的UML表示如下#xff1a; 处理程序定义处理器对象的一般结构。 这里的“ HandleRequest”是抽象处理器方法。 … java 职责链模式 当应有几个处理器来执行某项操作并为这些处理器定义特定顺序时就需要采用责任链设计模式。 在运行时处理器顺序的可变性也很重要。模式的UML表示如下 处理程序定义处理器对象的一般结构。 这里的“ HandleRequest”是抽象处理器方法。 处理程序还具有自己的类型引用该引用表示下一个处理程序。 为此应定义一个公共的“ setNextHandler”方法并且该处理程序恰好是一个抽象类。 ConcreteHandler定义处理器的不同表示形式。 最后客户端负责创建所需的处理程序处理器并定义它们之间的链顺序。 通常此模式可能存在两种不同的实现方式。 差异与“链路由业务逻辑的位置”有关。 链路由业务逻辑可以在Handler抽象类或ConcreteHandler类中或在两者中。 下面将给出前两种方法的样本 1.“处理程序”具有链路由业务逻辑 public abstract class Processor {protected Processor next;protected int threshold;public void setNextProcessor(Processor p) {next p;}public void process(String data, int value) {if (value threshold) {process(data);}if (next ! null) {next.message(data, threshold);}}abstract protected void processData(String data); } public class ProcessorA extends Processor {public ProcessorA (int threshold) {this.threshold threshold;}protected void processData(String data) {System.out.println(Processing with A: data);} } public class ProcessorB extends Processor {public ProcessorB (int threshold) {this.threshold threshold;}protected void writeMessage(String data) {System.err.println(Processing with B: data);} } public class Client {public static void main(String[] args) {Processor p, p1, p2;p1 p new ProcessorA(2);p2 new ProcessorB(1);p1.setNextProcessor(p2);// Handled by ProcessorAp.process(data1, 2);// Handled by ProcessorA and ProcessorBp.process(data2, 1);} } 2.ConcreteHandler具有链路由业务逻辑 public abstract class Processor {protected Processor next;protected int threshold;public void setNextProcessor(Processor p) {next p;}abstract protected void processData(String data); } public class ProcessorA extends Processor {public ProcessorA (int threshold) {this.threshold threshold;}protected void processData(String data, int value) {System.out.println(Processing with A: data);if (value threshold next ! null) {next.processData(data, value);}} } public class ProcessorB extends Processor {public ProcessorB (int threshold) {this.threshold threshold;}protected void processData(String data, int value) {System.out.println(Processing with B: data);if (value threshold next ! null) {next.processData(data, value);}} } public class Client {public static void main(String[] args) {Processor p, p1, p2;p1 p new ProcessorA(2);p2 new ProcessorB(1);p1.setNextProcessor(p2);// Handled by ProcessorAp.processData(data1, 1);// Handled by ProcessorA and ProcessorBp.processData(data2, 2);} } 参考来自Java的JCG合作伙伴 Cagdas Basaraner在CodeBuild博客上使用Java实现的“责任链”模式的2种实现 。 翻译自: https://www.javacodegeeks.com/2012/06/chain-of-responsibility-pattern-in-java.htmljava 职责链模式
http://www.pierceye.com/news/655523/

相关文章:

  • 南湖网站建设公司百度app推广方法
  • 做海报用的图片网站数据库端口 wordpress
  • js面向对象网站开发工业控制软件开发
  • 做网站的时候说需求的专业术语app开发定制外包26
  • 辽源网站建设公司做网站有送企业邮箱吗
  • 哈尔滨网站建设可信赖惠州网站制作专业
  • 中法电商网站建设石家庄手机网站建站
  • 北京pk10做号网站官方网站怎么写
  • 半路出家去学计算机网站开发团购做的好的网站
  • 没有网站怎么做CPC模板网站一天建好
  • 淘客网站模版北京网站优化指导
  • 网站域名更改后怎么做映射石家庄新闻主持人
  • 网站报404错误怎么解决办法禹城市建设局网站
  • asp网站建设运用的技术哪里有做商城的网站
  • 沈阳的网站制作公司哪家好七七鱼竞价托管
  • 网站如何做流量赚钱地推公司
  • 众筹网站建设需要多少资金知己图书网站建设策划书
  • 开源房产网站源码网站建设需要数学
  • 网站建设云技术公司推荐企业内部管理软件
  • 网站建设与维护案列北京梵客装饰
  • 网站建设电销话术海口h5建站
  • 网站建设怎么搭建服务器梧州本地网站
  • 佛山哪个做网站的好天津建设工程信息网怎么报名的
  • 专注扬中网站建设无锡免费建设网站
  • 中国建设银行门户网站企业wordpress如何禁止注册
  • 网站 模块wordpress极简风
  • 驻马店网站制作建筑施工特种证书查询入口官网
  • 四川网站建设公司电话网站的空间和域名备案
  • 海南网站建设方案django和WordPress哪个好
  • 已经有域名如何做网站手机优化加速有什么用