事件:可以在代码里和配置文件里配置
1, 在根元素<process>,或在节点元素中<task>,使用<on event="">元素指定事件,其中event属性代表事件的类型。
2, 在<on>中用子元素<event-listener class="EventListenerImpl" />,指定处理的类,要求指定的类要实现EventListener接口
3, 事件类型:
3.1 <on>元素放在根元素(<process>)中,可以指定event为start或end,表示流程的开始与结束。
3.2 <on>元素放在节点元素中,可以指定event为start或end,表示节点的进入与离开
3.3 在Start节点中只有end事件,在End节点中只有start事件。
3.4 在<transition>元素中直接写<event-listener class="">,就是配置事件。(因为在这里只有一个事件,所以不用写on与类型)
3.5 在<task>元素中还可以配置assign事件,是在分配任务时触发的。
============================================例子==========================================================
图片:
配置:
类:
public class startImpl implements EventListener {
@Override
public void notify(EventListenerExecution arg0) throws Exception {
// TODO Auto-generated method stub
System.out.println("启动");
}
}
public class EndImpl implements EventListener{ @Override public void notify(EventListenerExecution arg0) throws Exception { // TODO Auto-generated method stub System.out.println("end"); } }
public class TaskStart implements EventListener { @Override public void notify(EventListenerExecution arg0) throws Exception { // TODO Auto-generated method stub System.out.println("Task开始"); } }
public class TaskEnd implements EventListener { @Override public void notify(EventListenerExecution arg0) throws Exception { // TODO Auto-generated method stub System.out.println("Taskend"); } }