网路冷眼@BlogJava

熙熙攘攘一闲人 以冷静的眼光观察技术
posts - 88, comments - 193, trackbacks - 0, articles - 28
  BlogJava :: 首页 :: 新随笔 :: 联系 :: 聚合  :: 管理

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, nameid 这些属性:

  • 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}


只有注册用户登录后才能发表评论。


网站导航: