实现框架的类的方法为什么会在众多集成者中被调用
来源:互联网 发布:数据统计的软件 编辑:程序博客网 时间:2024/05/22 00:51
以activities为例
实现了:
/** * @author Tom Baeyens */public interface Command <T> { T execute(CommandContext commandContext); }
实现类
public class HistoryProcessInstanceDiagramCmd implements Command<InputStream> {protected String historyProcessInstanceId;public HistoryProcessInstanceDiagramCmd(String historyProcessInstanceId) {this.historyProcessInstanceId = historyProcessInstanceId;}public InputStream execute(CommandContext commandContext) {try {CustomProcessDiagramGenerator customProcessDiagramGenerator = new CustomProcessDiagramGenerator();return customProcessDiagramGenerator.generateDiagram(historyProcessInstanceId);} catch (Exception ex) {throw new RuntimeException(ex);}}}如何execute被调用的呢?
Command<InputStream> cmd = new HistoryProcessInstanceDiagramCmd(pid); InputStream is = ProcessEngines.getDefaultProcessEngine().getManagementService().executeCommand(cmd);重点在于这个传入的方法cmd,
private final CommandInterceptor first;
@Override public <T> T execute(CommandConfig config, Command<T> command) { return first.execute(config, command); }之后根据拦截器list加入的顺序走到这步(activiti源码分析(一)设计模式):其实就是最先传入的cmd自己调用自己的方法
/** * @author Tom Baeyens */public class CommandInvoker extends AbstractCommandInterceptor { @Override public <T> T execute(CommandConfig config, Command<T> command) { return command.execute(Context.getCommandContext()); }
0 0
- 实现框架的类的方法为什么会在众多集成者中被调用
- java在调用System.out.println()打印一个新new的对象时,为什么会调用toString方法?
- 父类引用指向子类对象,为什么会调用的是子类中重新的方法
- 为什么在实例化子类的对象的时候会调用先调用父类的构造函数
- 为什么子类在重写父类的方法后,会替代原有方法?
- 调用线程对象的start()方法会执行run(),为什么不能直接调用run()方法??
- 慎用Spring框架 - 子类会调用父类的@PostConstruct方法
- excel在系统中集成调用的方法,C#
- 实现ApplicationContextAware的实例会自动调用setApplicationContext()方法
- ListView的观察者模式的应用,以及调用notifyDataSetChanged()方法时,为什么会刷新ListView
- 众多中缀运算符的调用机制
- Android之什么时候调用onSaveInstance方法的时候(为什么按Home键盘会调用,按Back不调用)
- python: __call__() 为什么在绑定实例的时候会调用呢?
- 不要在构造函数中调用以后会被子类重写的方法
- 为什么要视图集成?视图集成的方法是什么?
- Java中不要在父类的构造方法中调用会被子类重写的方法
- 判断文件是否存在的众多方法
- 为什么toString 方法会自动被调用
- js的正则表达式 1
- 人脸识别API/SDK 汇总
- C语言基础(三)之控制流
- easyui datagrid增加一行或删除一行
- Unified Diagnostic Services
- 实现框架的类的方法为什么会在众多集成者中被调用
- AHUOJ 高级语言程序设计实验(六)素数判断
- HTML5新api即pushState和replaceState实现无刷新修改url
- 《算法(第四版)》 习题:1.3.9
- 排序--归并排序
- 蓝桥杯 波动数列 DP背包
- git套路
- 泛型的高级应用
- Handler详解