Activti跳过中间节点的helloworld实例程序
来源:互联网 发布:足球竞赛编程 编辑:程序博客网 时间:2024/04/29 09:09
此实例是一个最简单的在运行时人为动态改变流程运转的实例,意在为任意流、驳回等功能抛砖引玉.
定义一个最简单的流程,它只有一个“开始事件”、一个“ServiceTask”、一个“结束事件”.
我们现在的要实现的是直接跳过ServiceTask。
ServiceTask的实现类只是简单的在控制台输出一条语句.
public class Log implements JavaDelegate {public void execute(DelegateExecution execution) throws Exception {System.err.println("如果我出现了,就说明我没被忽略");}}
控制流向的代码如下
System.out.println("直接跳过ServiceTask的流程开始..................");RepositoryService repositoryService = activitiRule.getRepositoryService();ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery().deploymentId("1").singleResult();ProcessDefinitionEntity processDefinitionEntity = (ProcessDefinitionEntity) ((RepositoryServiceImpl) repositoryService).getDeployedProcessDefinition(processDefinition.getId());List<ActivityImpl> activities = processDefinitionEntity.getActivities();ActivityImpl start = null;ActivityImpl task = null;ActivityImpl end = null;for (ActivityImpl activity : activities) {if (activity.getId().equals("startevent1")) {start = activity;}if (activity.getId().equals("usertask1")) {task = activity;}if (activity.getId().equals("endevent1")) {end = activity;}}//清除原先的路径List<PvmTransition> cacheTran = start.getOutgoingTransitions();start.getOutgoingTransitions().clear();//创建新路径TransitionImpl tran = start.createOutgoingTransition();tran.setDestination(end);RuntimeService runtimeService = activitiRule.getRuntimeService();runtimeService.startProcessInstanceById(processDefinitionEntity.getProcessDefinition().getId());//恢复原来路径start.getOutgoingTransitions().clear();for (PvmTransition transition : cacheTran) {start.createOutgoingTransition().setDestination((ActivityImpl) transition.getDestination());}这样ServiceTask将被跳过不会自动执行
当注释掉
start.getOutgoingTransitions().clear();
serviceTask将被执行.
这种方法只会影响一个流程实例的流程定义的内存镜像,其他流程不会受到影响.
1 0
- Activti跳过中间节点的helloworld实例程序
- Activti跳过中间节点的helloworld实例程序
- Activti跳过中间节点的helloworld实例程序
- ValueAnimator动画跳过中间过程的问题
- 求单链表的中间节点
- 找链表的中间节点
- 求链表的中间节点
- 单链表的中间节点
- 求单链表的中间节点
- 求链表的中间节点
- 输出单链表的中间节点
- 查找单链表的中间节点
- 寻找单链表的中间节点
- 查找单链表的中间节点
- 寻找单链表的中间节点
- 要寻找一个单链表的中间节点
- 查找链表的中间节点
- 遍历链表一遍取出中间的节点
- UFLDL Tutorial_ICA Style Models
- Android ListView使用BaseAdapter与ListView的优化
- linux dma映射讲解
- nltk.download()下载失败的解决办法
- container_of 理解
- Activti跳过中间节点的helloworld实例程序
- 求两个整数的平方和--嵌套调用函数
- string的成员用法
- POJ 1971 Parallelogram Counting
- 关于代码,关于编程,关于梦想
- VB枚举控件属性
- 山东理工大学ACM平台题答案关于C语言 1164 C语言实验——矩阵转置
- C#与C++/CLI混合编程
- uva 10317 - Equating Equations(dfs)