Activiti监听器

Activiti监听器

ExecutionListener:监听全局事件,start(流程启动),end(流程结束),take(经过连线)
TaskListener:监听节点事件,assignment(任务分配),create(任务创建),complete(任务完成),delete(任务被删除),all(监听所有事件)

ExecutionListener的用法:

# 监听start和end定义在根路径

        
            
            
        
 

监听连线事件,当流程经过这条连线时就会被触发。


            
                
            

MyExecutionListener类:

import org.activiti.engine.delegate.DelegateExecution;
import org.activiti.engine.delegate.ExecutionListener;

public class MyExecutionListener implements ExecutionListener {
    public void notify(DelegateExecution execution) {
        String eventName = execution.getEventName();
        if ("start".equals(eventName)) {
            System.out.println("start=========流程启动");
        }else if ("end".equals(eventName)) {
            System.out.println("end=========流程结束");
        } else if("take".equals(eventName))
            System.out.println("take ======经过连线");
    }
}

TaskListener的用法:


            
                
            

MyTaskListener类

import org.activiti.engine.delegate.DelegateTask;
import org.activiti.engine.delegate.TaskListener;

public class MyTaskListener implements TaskListener {
    @Override
    public void notify(DelegateTask delegateTask) {
        String eventName = delegateTask.getEventName();
        if("create".endsWith(eventName))
            System.out.println("task create===");
        else if("assignment".endsWith(eventName))
            System.out.println("task assignment===");
        else if("complete".endsWith(eventName))
            System.out.println("task complete===");
        else if("delete".endsWith(eventName))
            System.out.println("task delete===");
    }
}

注意修改了流程文件就需要重新部署,再启动流程,关于部署和启动流程可以看上一篇博客。
https://blog.csdn.net/Bugggget/article/details/88583607

你可能感兴趣的:(]工作流)