博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
activiti--部署bpmn/bar文件详解
阅读量:2386 次
发布时间:2019-05-10

本文共 2673 字,大约阅读时间需要 8 分钟。

本人博客开始迁移,博客整个架构自己搭建及编码  

Everything that is related to 'static' data (such as process definitions) are accessed through the RepositoryService. Conceptually, every such static piece of data is content of the 'repository' of the Activiti engine.

当配置好工作流,启动工作流。我们的第一步就是配置bpmn、bar、bpmn20.xml等文件。

部署bpmn的简单代码:

ProcessEngine processEngine = ProcessEngines.getDefaultProcessEngine();RepositoryService repositoryService = processEngine.getRepositoryService();repositoryService.createDeployment()  .addClasspathResource("org/activiti/test/AssigneeUserAndGroup.bpmn")  .deploy();

简单解释:创建一个部署引擎DeploymentBuilder,然后通过addClasspathResource把文件路径设置进去(最起码activiti需要知道部署哪一个文件啊),然后启动部署方法deploy()。

addClasspathResource()方法其实就是把文件读入到一个输入流中,然后调用addInputStream()方法。addInputStream()主要是创建一个资源类,然后设置名称,字节,并且把这个资源给deployment实体

public DeploymentBuilder addInputStream(String resourceName, InputStream inputStream) {    if (inputStream==null) {      throw new ActivitiIllegalArgumentException("inputStream for resource '"+resourceName+"' is null");    }    byte[] bytes = IoUtil.readInputStream(inputStream, resourceName);    ResourceEntity resource = new ResourceEntity();    resource.setName(resourceName);    resource.setBytes(bytes);    deployment.addResource(resource);    return this;  }  public DeploymentBuilder addClasspathResource(String resource) {    InputStream inputStream = ReflectUtil.getResourceAsStream(resource);    if (inputStream==null) {      throw new ActivitiIllegalArgumentException("resource '"+resource+"' not found");    }    return addInputStream(resource, inputStream);  }

所以也可以直接调用addInputStream(String resourceName, InputStream inputStream)进行文件的部署。

注意:单独部署一个bpmn文件,png会在底层BpmnDeployer中分解出来,并且保存到数据库中。

如果一个部署中涉及到多个文件,我们可以打包一起部署,例如方法addZipInputStream(ZipInputStream zipInputStream),其实addZipInputStream会把这个包下面的所有文件逐一找出来,然后创建资源类,设置到deployment实体中。

public DeploymentBuilder addZipInputStream(ZipInputStream zipInputStream) {    try {      ZipEntry entry = zipInputStream.getNextEntry();      while (entry != null) {        if (!entry.isDirectory()) {          String entryName = entry.getName();          byte[] bytes = IoUtil.readInputStream(zipInputStream, entryName);          ResourceEntity resource = new ResourceEntity();          resource.setName(entryName);          resource.setBytes(bytes);          deployment.addResource(resource);        }        entry = zipInputStream.getNextEntry();      }    } catch (Exception e) {      throw new ActivitiException("problem reading zip input stream", e);    }    return this;  }

下面说说.bar文件怎么打包:

(1)把文件都拷到同一目录下面

 

(2)对diagrams文件夹进行打包

diagrams.zip

(3)修改文件的扩展名diagrams.bar

 其实一切很简单...

 

 

转载于:https://my.oschina.net/winHerson/blog/179022

你可能感兴趣的文章
外部修改应用程序图标的做法
查看>>
database disk image is malformed解决方法
查看>>
有关error PRJ0003错误的思考
查看>>
实现自定义对话框程序快捷键的两种方法
查看>>
如何对抗微软霸权,google给我们上了一课
查看>>
获取windows版本信息的做法
查看>>
忆父亲
查看>>
png库结合zlib库使用出现的一个链接问题的解决
查看>>
STL数组和com数组相互转换的做法
查看>>
开发平台软件中关于第三方库管理的一些思考
查看>>
svn创建分支的做法
查看>>
“当前不会命中断点。源代码与原始版本不同”的问题的有效解决办法
查看>>
对面向对象和面向过程的一些新理解
查看>>
软件开发中的资源管理
查看>>
有关博客的一些断想
查看>>
Windows Server2008上安装VS2008出错及解决办法
查看>>
打开word2010每次都要配置进度的解决办法
查看>>
略论并行处理系统的日志设计
查看>>
开发人员应具备的产品设计意识
查看>>
MSComDlg.CommonDialog服务器不能创建对象错误的解决
查看>>