Chapter 6. Deployment(部署)
Table of Contents
- Business archives(業務檔案)
- Java classes(Java類)
- Deploying programmatically(編程式部署)
- Deploying with ant(以ant方式部署)
- Deploying with Activiti Probe(以Activiti Probe部署)
- Versioning of process definitions(流程定義的版本管理)
Business archives(業務檔案)
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 and any other type of file. In general, a business archive contains a collection of named resources.
為了部署流程,必須將流程打包為流程檔案。一個流程檔案是Activiti引擎的部署單元。基本來說,一個流程檔案等價于一個zip文件。它包含了BPMN 2.0流程,任務表單,規則和其它文件類型。通常,流程檔案包含一個命名資源的集合。
When a business archive is deployed, it is scanned for BPMN files with a extension. Each of those will be parsed and potentially contains multiple process definitions.
當部署業務檔案時,以.bpmn20.xml
擴展名為的BPMN文件方式掃描來掃描它。每個BMPN文件被掃描,它包含多個流程定義。
Note that Java classes present in the business archive will not be added to the classpath. All custom classes used in process definitions in the business archive (for example Java service tasks or event listener implementations) should be present on the activiti-engine's classpath in order to run the processes.
注意業務檔案存在的Java類將不會加入到classpath。為了運行流程,業務檔案里面的流程定義的所有定制類(例如Java服務類或者事件監聽器實現)應當包含在Activiti引擎的classpath里面。
Java classes(Java類)
All custom classes that are used in your process (eg. JavaDelegates used in servicetaks or event-listeners, TaskListeners, ...) should be present on the engine's classpath when an instance of the process is started. It's not nessecairy to have those classes on the classpath when deploying the process-definition into the engine.
當啟動一個流程實例(例如serviceTask或者event-listener,TaskListener)時,定義在流程里面的所有定制類應當包含在引擎的classpath上面 。當把流程定義部署到引擎時,不必將哪些類放到classpath上。
When you are using the demo setup and you want to add your custom classes, you should add a jar containing your classes to the activiti-rest webapp lib. Don't forget to include the dependencies of your custom classes (if any) as wel. This is the same location where the activiti-engine jar is located. You can find this folder inside your distro at the folowing location:
當正在使用demo setup并要加入你自己的定制類時,你應當將包含這些類的jar包添加至activiti-rest webapp lib里面。也不要忘記包含定制類的依賴包(如果有的話),這個和activiti-engine.jar位置相同。在發行版本中的如下位置找到這個文件夾:
${activiti distro}/apps/apache-tomcat-6.0.29/webapps/activiti-rest/lib/
Deploying programmatically(編程式部署)
Deploying a business archive from a zip file can be done like this:
以如下方式完成從zip文件來部署流程檔案:
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。
Deploying with ant(以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
任務。確保配置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" />
Deploying with Activiti Probe(以Activiti Probe部署)
It's possible to deploy process definitions through probe, this is described in Activiti Probe - Deployments.
通過Probe也可以部署流程定義,這在Activiti Probe - Deployments里面描述。
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的倉庫里,所以在部署時,才建立流程定義的版本。在部署期間,在ProcessDefinition
保存到Activiti DB之前,Activiti將為它分布一個版本號。
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
這些屬性:
-
The process id
attribute is used as the process definition key
property
流程id
屬性 用作為流程定義的key
特性
-
The process name
attribute is used as the process definition name
property. If the name attribute is not specified, then id attribute is used as the name.
流程name
屬性 用作為流程定義的特性 name
。如果沒有指定name屬性,那么id屬性作為名稱使用。
-
The first time a process with a particular key is deployed, version 1 is assigned. For all subsequent deployments of process definitions with the same key, the version will be set 1 higher then the max currently deployed version. The key property is used to distinct process definitions.
當一個帶有特殊key的流程第一次部署時,版本分配為1。對帶有相同key的流程定義,在后續部署時,每部署一次,在當前最大部署版本號上加1。key特性用來區分流程定義。
-
The id property is set to {processDefinitionKey}:{processDefinitionVersion}
id特性設置為{processDefinitionKey}:{processDefinitionVersion}