Activiti入门程序-部署流程定义

2019-03-23 23:11|来源: 网路

ProcessEngines.getDefaultProcessEngine()会自动自动加载classpath下名为activiti.cfg.xml文件(activiti-context.xml也会加载,但是要依赖于spring)
RepositoryService是Activiti的仓库服务类,流程定义和部署对象相关的Service,所谓的仓库指流程定义文档的两个文件:bpmn文件和流程图片
DeploymentBuilder,用来定义流程部署的相关参数
调用DeploymentBuilder的deploy部署流程定义,会返回Deployment对象,可以从此对象中获取流程的相关值


示例程序


package com._656463.activiti.test;
 
import org.activiti.engine.ProcessEngine;
import org.activiti.engine.ProcessEngines;
import org.activiti.engine.RepositoryService;
import org.activiti.engine.repository.Deployment;
import org.activiti.engine.repository.DeploymentBuilder;
import org.junit.Before;
import org.junit.Test;
 
/**
 * Activiti入门程序
 */
public class TestActivitiHello {
    ProcessEngine processEngine = null;
    @Before
    public void init(){
        //自动加载classpath下名为activiti.cfg.xml文件
        processEngine = ProcessEngines.getDefaultProcessEngine();
    }
 
    /** 部署流程定义 */
    @Test
    public void deploymentProcessDefinitionTest() {
        /**
         * RepositoryService是Activiti的仓库服务类,流程定义和部署对象相关的Service
         * 所谓的仓库指流程定义文档的两个文件:bpmn文件和流程图片
         */
        RepositoryService repositoryService = processEngine.getRepositoryService();
        // 创建一个部署对象DeploymentBuilder,用来定义流程部署的相关参数
        DeploymentBuilder deploymentBuilder = repositoryService.createDeployment();
        // 添加部署的名称
        deploymentBuilder.name("activiti入门程序");
        // 添加hello.bpmn和hello.png
        deploymentBuilder.addClasspathResource("diagrams/hello.bpmn");
        deploymentBuilder.addClasspathResource("diagrams/hello.png");
        // 部署流程定义
        Deployment deployment = deploymentBuilder.deploy();
 
        System.out.println("部署ID:" + deployment.getId());//1
        System.out.println("部署名称:" + deployment.getName());//activiti入门程序
    }
}


查看数据库变化:
act_re_procdef


act_re_deployment


act_ge_bytearray


本文参考网络


相关问答

更多

activiti explorer怎么添加到已部署流程定义

下面小结下,代码其实很简单,如下: [code="java"] @Test public void testDynamicDeploy() throws Exception { //创建bpmn模型 BpmnModel model = new BpmnModel(); Process process = new Process(); model.addProcess(process); process.setId("my-process"); //创建bpmn元素

activiti modeler 怎么将设计的流程保存到后台的?后台哪里接收的?

package org.activiti.editor.rest.model; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.InputStream; import org.activiti.editor.constants.ModelDataJsonConstants; import org.activiti.engine.ProcessEngines; impo ...

如何实现Activiti的流程定义的设置

ProcessInstancepi=runtimeService.createProcessInstanceQuery()//.processInstanceId(processInstanceId)//使用流程实例ID查询.singleResult();if(pi==null){return"流程结束";}else{return"未结束";}

activiti怎么实现用户自定义流程

ProcessInstancepi=runtimeService.createProcessInstanceQuery()//.processInstanceId(processInstanceId)//使用流程实例ID查询.singleResult();if(pi==null){return"流程结束";}else{return"未结束";}

activiti工作流在tomcat重启后需要重新部署流程

试试 设置下processEngine 的asyncExecutorEnable

相关文章

更多

最近更新

更多