activity6.0部署BPMN文件的多种方式,直接上代码
2021/4/14 10:55:17
本文主要是介绍activity6.0部署BPMN文件的多种方式,直接上代码,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!
package test; import org.activiti.engine.ProcessEngine; import org.activiti.engine.ProcessEngines; import org.activiti.engine.repository.Deployment; import org.junit.Test; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.InputStream; import java.util.zip.ZipInputStream; /** * @author *** * @Description: 流程BPMN部署 * @date 2021/04/04 * 在使用的时候,注意activity的数据库配置是否正确,《activiti.cfg.xml》 */ public class ProcessDefinitionTest { /**流程引擎(核心对象),默认加载类路径下命名为activiti.cfg.xml*/ ProcessEngine processEngine = ProcessEngines.getDefaultProcessEngine(); //部署流程定义 @Test public void deployementProcessDefinition(){ Deployment deployment = processEngine.getRepositoryService()//获取流程定义和部署对象相关的Service .createDeployment()//创建部署对象 .name("审计方案管理&审计通知书")//声明流程的名称 .addClasspathResource("process/executeSolutionApproval.bpmn")//加载资源文件,一次只能加载一个文件 .addClasspathResource("process/executeSolutionApproval.png")// .deploy();//完成部署 System.out.println("部署ID:"+deployment.getId());//1 System.out.println("部署时间:"+deployment.getDeploymentTime()); } @Test public void deployementProcessDefinitionByInputStream() throws FileNotFoundException { //获取资源相对路径 String bpmnPath = "process/executeSolutionApproval.bpmn"; String bpmnName = "executeSolutionApproval.bpmn"; String pngPath = "process/executeSolutionApproval.png"; String pngName = "executeSolutionApproval.png"; //读取资源作为一个输入流 FileInputStream bpmnfileInputStream = new FileInputStream(bpmnPath); FileInputStream pngfileInputStream = new FileInputStream(pngPath); ProcessEngine processEngine = ProcessEngines.getDefaultProcessEngine(); Deployment deployment = processEngine.getRepositoryService()//获取流程定义和部署对象相关的Service .createDeployment()//创建部署对象 .addInputStream(bpmnName,bpmnfileInputStream) .addInputStream(pngName, pngfileInputStream) .deploy();//完成部署 System.out.println("部署ID:"+deployment.getId());//1 System.out.println("部署时间:"+deployment.getDeploymentTime()); } /** * 字符串方式部署 * @throws FileNotFoundException */ @Test public void deployementProcessDefinitionByString() throws FileNotFoundException{ //字符串 String text = "<?xml version=\"1.0\" encoding=\"UTF-8\"?><definitions>...</definitions>"; Deployment deployment = processEngine.getRepositoryService()//获取流程定义和部署对象相关的Service .createDeployment()//创建部署对象 .addString("helloworld.bpmn",text) .deploy();//完成部署 System.out.println("部署ID:"+deployment.getId());//1 System.out.println("部署时间:"+deployment.getDeploymentTime()); } /** * 压缩包方式部署 * zip/bar */ @Test public void deployementProcessDefinitionByzip(){ //从classpath路径下读取资源文件 InputStream in = this.getClass().getClassLoader().getResourceAsStream("diagrams/helloworld.zip"); ZipInputStream zipInputStream = new ZipInputStream(in); Deployment deployment = processEngine.getRepositoryService()//获取流程定义和部署对象相关的Service .createDeployment()//创建部署对象 .addZipInputStream(zipInputStream)//使用zip方式部署,将helloworld.bpmn和helloworld.png压缩成zip格式的文件 .deploy();//完成部署 System.out.println("部署ID:"+deployment.getId());//1 System.out.println("部署时间:"+deployment.getDeploymentTime()); } }
多个方式任选,另外,在部署完毕之后,!!!记得准备脚本文件避免线上翻车!!!
这篇关于activity6.0部署BPMN文件的多种方式,直接上代码的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!
- 2024-09-28pyqt 怎么打包整个项目-icode9专业技术文章分享
- 2024-09-28laravel Commands 创建带有参数的 Artisan 命令的步骤和示例-icode9专业技术文章分享
- 2024-09-28antd怎么实现渲染tiff图片-icode9专业技术文章分享
- 2024-09-28英文半角中划线和中文全角的中划线有什么区别-icode9专业技术文章分享
- 2024-09-28nvm npm 和node 他们之间有什么关系-icode9专业技术文章分享
- 2024-09-28Node Version Manager (nvm)使用教程-icode9专业技术文章分享
- 2024-09-28nvm命令太慢,是什么原因-icode9专业技术文章分享
- 2024-09-28Kotlin 如何增加、删除和修改 MutableStateFlow 中的值。-icode9专业技术文章分享
- 2024-09-28Kotlin的stateFlow.update 写法介绍-icode9专业技术文章分享
- 2024-09-28kotlin 怎么获取当前时间格式-icode9专业技术文章分享