Chapter 6. Deployment
第六章 部署
Table of Contents
Versioning of process definitions
业务档案
To deploy processes, they have to be wrapped in a business archive. A business archive is the unit of deployment to an Activiti Engine. Basically a business archive is equivalent to a zip file. It can contain BPMN 2.0 processes, task forms, rules, java classes and any other type of file. In general, a business archive contains a collection of named resources.
为了部署一个流程,你必须将数据打包成一个业务档案。业务档案是Activiti引擎进行部署的一个单元。基本上一个业务档案相当于一个打包文件。它包含了BPMN2.0流程定义,任务表单,规则,java类和其它一些类型的文件。总的来说,一个业务档案包含了一组命名的资源文件。
When a business archive is deployed, it is scanned for BPMN files with a .bpmn20.xml extension. Each of those will be parsed and potentially contains multiple process definitions.
当一个业务档案被部署时,流程引擎将首先获取以.bpmn20.xml结尾的BPMN流程配置文件。然后它们会被逐个被解析,有可能它们包含了多个流程定义。
基于程序进行部署
Deploying a business archive from a zip file can be done like this:
通过一个压缩文件来部署业务档案时,程序大概如下:
String barFileName = "path/to/process-one.bar"; ZipInputStream inputStream = new ZipInputStream(new FileInputStream(barFileName)); repositoryService.createDeployment() .name("process-one.bar") .addZipInputStream(inputStream) .deploy();It's also possible to build a deployment from individual resources. See javadocs for more details.
也可以通过独立资源文件进行部署。详细可以参考javadoc。
使用ant进行部署
To deploy a business archive with ant, first the deploy-bar task needs to be defined. Make sure that the configuration jar is on the classpath, as well as the Activiti jar and all its dependencies:
当时有ant进行业务档案部署时,你必须首先定义一个deploy-bar的task,并确认配置文件打包成的jar、Activiti的jar以及所依赖的包存在classpath目录下:
<taskdef name="deploy-bar" classname="org.activiti.engine.impl.ant.DeployBarTask"> <classpath> <fileset dir="..."> <include name="activiti-cfg.jar"/> <include name="your-db-driver.jar"/> </fileset> <fileset dir="${activiti.home}/lib"> <include name="activiti-engine-${activiti.version}.jar"/> <include name="ibatis-sqlmap-*.jar"/> </fileset> </classpath> </taskdef> <deploy-bar file=".../yourprocess.bar" />Versioning of process definitions
流程定义的版本
BPMN doesn't have a notion of versioning. And that is good because the executable BPMN process file will probably live in an SVN repository as part of your development project. Versions of process definitions are created during deployment. During deployment, Activiti will assign a version to the ProcessDefinition before it is stored in the Activiti DB.
BPMN本身没有版本概念。这是因为可执行的BPMN流程定义文件或许作为你开发项目的一部分存在SVN仓库中。流程定义的版本是在部署时创建的。当进行流程部署时,Activiti将为ProcessDefinition分配一个版本,然后在存入到数据库中。
For each process definition in a business archive the following steps are performed to initialize the properties key, version, name and id:
业务档案中的每一个流程定义将按照下面的顺序对key、version、name和id等属性进行初始化: