---
title: "Activiti User Guide -- Activit 用户指南 Part09"
author: "cd826"
date: "2010-10-31T10:08:50Z"
tags: []
categories: ["企业架构"]
slug: "activiti-user-guide-activit-part09"
draft: false
lastmod: "2010-10-31T10:08:50Z"
id: 798757
url: "https://cd826.iteye.com/blog/798757"
---

**Sequence flow**

**顺序流**

[]()**Description**

**描述**

A sequence flow is the connector between two elements of a process. After an element is visited during process execution, all outgoing sequence flow will be followed. This means that the default nature of BPMN 2.0 is to be parallel: two outgoing sequence flow will create two separate, parallel paths of execution.

顺序流用来连接流程中的两个元素。流程执行完一个元素时就会获取接下来获取所有外出顺序流进行执行。也就是说BPMN2.0天然就是并行执行的：两个外出顺序流就会创建两个独立的、并行的流程执行路径。

[]()**Graphical notation**

**流程表示**

A sequence flow is visualized as an arrow going from the source element towards the target element. The arrow always points towards the target.

顺序流表示为一个带有箭头的，从起始元素指向目标元素的线。箭头通常指向目标元素。

 

![](http://dl.iteye.com/upload/attachment/340381/be383cb6-8f3d-302d-a9fc-e1c239bcff62.png)

**XML representation**

**XML 表示**

Sequence flow need to have a process-unique **id**, and a reference to an existing **source** and **target** element.

顺序流必须有一个流程唯一的id，并且指向存在起始元素和目标元素。

```
<sequenceFlow id="flow1" sourceRef="theStart" targetRef="theTask" />
```

 **Conditional sequence flow**

**条件顺序流**

[]()**Description**

**描述**

A sequence flow can have a condition defined on it. When a BPMN 2.0 activity is left, the default behavior is to evaluate the conditions on the outgoing sequence flow. When a condition evaluates to *true*, that outgoing sequence flow is selected. When multiple sequence flow are selected that way, multiple *executions* will be generated and the process will be continued in a parallel way.

可以为顺序流定义一个条件。当BPMN2.0中的Activity离开时，默认将先对所有外出顺序流的条件进行评估。当评估为真时，该顺序流就会被选中执行。当多个顺序流同时被选中时，流程就会创建多个流程执行，并进入并行模式继续执行。

**Note:** the above holds for BPMN 2.0 activities (and events), but not for gateways. Gateways will handle sequence flow with conditions in specific ways, depending on the gateway type.

[]()**Graphical notation**

**图形符号**

A conditional sequence flow is visualized as a regular sequence flow, with a small diamond at the beginning. The condition expression is shown next to the sequence flow.

条件顺序流的图形表示与普通顺序流差不多，只是在起始点加一个小的菱形符号。流程条件则显示在图形表示附近。

![](http://dl.iteye.com/upload/attachment/340383/7ccaa5e7-8544-3498-86f1-a43f75e6b69f.png)

**XML representation**

**XML 表示**

A conditional sequence flow is represented in XML as a regular sequence flow, containing a **conditionExpression** sub-element. Note that for the moment only *tFormalExpressions* are supported, Omitting the *xsi:type=""* definition will simply default to this only supported type of expressions.

条件顺序流的XML表示与普通顺序流一样，并增加了一个conditionExpression的子元素。注意现在只有*tFormalExpressions* 被支持，所以可以忽略*xsi:type=""* 的值定义，来缺省使用当前被支持的表达式类型。

```
<sequenceFlow id="flow" sourceRef="theStart" targetRef="theTask">
  <conditionExpression xsi:type="tFormalExpression">
    <![CDATA[${order.price > 100 && order.price < 250}]]>
  </conditionExpression>
</sequenceFlow> 
```

  

Activiti supports two kind of expressions: UEL-value and UEL-method expressions (UEL stands for *Unified Expression Language* and is part of the EE6 specification, see [the EE6 specification](http://docs.sun.com/app/docs/doc/820-7627/gjddd?l=en&a=view) for detailed information)

Activiti支持两种表达式: UEL-value 和 UEL-method (UEL： *Unified Expression Language* 是EE6标准中的一部分,可以参考 [the EE6 specification](http://docs.sun.com/app/docs/doc/820-7627/gjddd?l=en&a=view) 获取更多的信息)。

 

Specifying the type of expression, is done through the **language** attribute on the *expression* element:

可以通过expression元素中的language属性来指定表达式的类型：

```
<conditionExpression xsi:type="tFormalExpression" language="uel-value | uel-method">
  <![CDATA[${order.isStandard}]]>
</conditionExpression>
```

 

- **uel-value**: references data of a process variable, in the typical JavaBean style through getters.
- **uel-value**: 表示一个流程变量，可以通过JavaBean的getter方法获取。

```
<conditionExpression xsi:type="tFormalExpression" language="uel-value">
  <![CDATA[${order.price > 100 && order.price < 250}]]>
</conditionExpression>
```

 

- **uel-method**: invokes a method that resolves to a boolean value.
- **uel-method**: 表示调用一个方法，该方法返回一个布尔值。

```
<conditionExpression xsi:type="tFormalExpression" language="uel-method">
  <![CDATA[${order.isStandardOrder}]]>
</conditionExpression>
```

Note that these expressions support resolving primitives (incl. comparing them), beans, lists, arrays and maps. **If no value for the language attribute is specified, by default the expression is resolved as a value expression.**

注意，这些表达式支持解析基础类型（包含对比它们）、bean、list、array和map。如果language属性没有被指定，缺省则将解析为一个值表达式。

 

The Activiti distribution contains the following example process using value and method expressions (see*org.activiti.examples.bpmn.expression)*:

Activiti发行包中包含俩了下面这个使用值和方法表达式的示例（参见*org.activiti.examples.bpmn.expression*）：

![](http://dl.iteye.com/upload/attachment/340385/23572e2e-bf54-36e4-8b31-f165f55fc3eb.png)