In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)05/31 Report--
This article is about how activiti deploys bpmn/bar files. The editor thinks it is very practical, so share it with you as a reference and follow the editor to have a look.
When the workflow is configured, start the workflow. Our first step is to configure bpmn, bar, bpmn20.xml, and so on.
The simple code to deploy bpmn is:
ProcessEngine processEngine = ProcessEngines.getDefaultProcessEngine (); RepositoryService repositoryService = processEngine.getRepositoryService (); repositoryService.createDeployment () .addClasspathResource ("org/activiti/test/AssigneeUserAndGroup.bpmn") .deploy ()
Simple explanation: create a deployment engine DeploymentBuilder, then set the file path through addClasspathResource (at least activiti needs to know which file to deploy), and then start the deployment method deploy ().
The addClasspathResource () method simply reads the file into an input stream and then calls the addInputStream () method. AddInputStream () mainly creates a resource class, then sets the name, bytes, and gives the resource to the deployment entity
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);}
So you can also directly call addInputStream (String resourceName, InputStream inputStream) to deploy the file.
Note: if you deploy a separate bpmn file, the png will be decomposed in the underlying BpmnDeployer and saved to the database.
If multiple files are involved in a deployment, we can package and deploy them together, such as the method addZipInputStream (ZipInputStream zipInputStream). In fact, addZipInputStream will find all the files under the package one by one, and then create a resource class and set it to the deployment entity.
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;}
Here's how to package a .bar file:
(1) copy all the files to the same directory
(2) package the diagrams folder
Diagrams.zip
(3) modify the file extension diagrams.bar
Thank you for reading! This is the end of the article on "how to deploy bpmn/bar files in activiti". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, you can share it out for more people to see!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.