天天看點

jBPM Developers Guide(jBPM開發指南)--Chapter 3. BPMN 2.0(第二部分)

3.7. Process root element(流程根元素)

    The root of an BPMN 2.0 XML process is the definitions elements. As the name states, the subelements will contain the actual definitions of the business process(es). Every process child will be able to have an id and name. An empty business process in BPMN 2.0 looks as follows. Also note that it is handy to have the BPMN2.xsd on the classpath, to enable XML completion.

    BPMN 2.0 XML流程的根是definitions元素。子元素會則包含真正的業務流程定義。每個process子元素可以擁有一個id和name。一個空的BPMN 2.0業務流程定義如下所示。注意需要把BPMN2.xsd放在classpath下,來啟用XML自動補全功能。

<definitions id="myProcesses"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://schema.omg.org/spec/BPMN/2.0 BPMN20.xsd"
  xmlns="http://schema.omg.org/spec/BPMN/2.0" 
  typeLanguage="http://www.w3.org/2001/XMLSchema"
  expressionLanguage="http://www.w3.org/1999/XPath" 
  targetNamespace="http://jbpm.org/example/bpmn2">

  <process id="myBusinessProcess" name="My business processs"> 
  
      ...
      
  </process>
<definitions>     
      

    If an id is defined for a process element, it will be used as business key for that process (ie. starting a process can be done by calling executionService.startProcessInstanceByKey("myBusinessProcess"), otherwise the jBPM engine will create a unique process key (same mechanism as for JPDL).

    如果一個process元素定義了id,它會作為業務流程的key使用。比如,啟動流程可以通過調用executionService.startProcessInstanceByKey("myBusinessProcess"),否則jBPM引擎會流程建立一個唯一key(這一點與jPDL相同)。

3.8. Basic constructs(基本結構)

3.8.1. Events(事件)

    Together with activitites and gateways, events are used in practically every business process. Events allow process modelers to describe business processes in a very natural way, such as 'This process starts when I receive a customer order', 'If the task is not finished in 2 days, terminate the process' or'When I receive a cancel e-mail when the process is running, handle the e-mail using this sub-process'. Notice that typical businesses always work in a very event-driven way. People are not hard-coded sequential creatures, but they tend to react on things that happen in their environment (ie. events). In the BPMN specification, a great number of event types are described, to cover the range of possible things that might occur in context of a business.

    活動、網關和事件幾乎在每個業務流程中被使用。事件讓業務流程模組化者用很自然的方式描述業務流程,比如'當我接收到客戶的訂單時啟動該流程','如果兩天内任務沒結束,就終止流程' 或者'當我收到一封取消郵件,當流程在運作時,使用子流程處理郵件'。注意典型的業務通常使用這種事件驅動的方式。人們不是按照一定順序進行處理事情,而是傾向于根據在他們的環境中發生的事情(比如,事件)來進行處理。在BPMN規範中,定義了很多事件類型,為了能夠覆寫可能在業務環境中出現的各種情況。

3.8.2. Event: None start event(事件:空啟動事件)

    A start event indicates the start of process (or a subprocess). Graphically, it is visualized as a circle with (possibly) a small icon inside. The icon specifies the actual type of event that will trigger the process instance creation.

    一個啟動事件訓示流程(或子流程)的開始。它看起來是一個圓(可能)内部有一個小圖示。圖示表示了事件的實際類型,将會在流程執行個體建立時被觸發。

    The 'none start event' is drawn as a circle without an icon inside, which means that the trigger is unknown or unspecified. The start activity of JPDL basically has the same semantics. Process instances whose process definition has a 'none start event' are created using the typical API calls on the executionService.

    空啟動事件用一個圓來表示,内部沒有圖示,意思是這個觸發器是未知或者未指定的。這與jPDL的開始活動是一樣的。 流程執行個體的流程定義中包含了一個空啟動事件,可以使用executionService的調用建立。

    A none start event is defined as follows. An id is required, a name is optional.

    一個空啟動事件定義如下。id是必需的,name則是可選的。

<startEvent id="start" name="myStart" />      

3.8.3. Event: None end event(事件:空結束事件)

    An end event indicates the end of an execution path in a process instance. Graphically, it is visualized as a circle with a thick border with (possibly) a small icon inside. The icon specifies the type of signal that is thrown when the end is reached.

    結束事件表示流程執行個體中一個流程路徑的結束。它看起來就是一個圓擁有厚邊框(可能)内部有小圖示。圖示表示了流程結束的時候那種信号将會被抛出。

    The 'none end event' is drawn as a circle with thick border with no icon inside, which means that no signal is thrown when the execution reaches the event. The end activity in JPDL has the same semantics as the none end event.

    空結束用一個擁有厚邊框的圓,内部沒有圖示來表示,這意味着當流程到達事件時,不會抛出任何信号。與jPDL中的結束事件的語義相同。

    A none end event is defined as follows. An id is required, a name is optional.

   空結束事件定義如下。id是必需的,name則是可選的。

<endEvent id="end" name="myEnd" />      

    The following example shows a process with only a none start and end event:

    下面的例子顯示了隻使用空開始和結束事件的流程:

jBPM Developers Guide(jBPM開發指南)--Chapter 3. BPMN 2.0(第二部分)

    The corresponding executable XML for this process looks like this (omitting the definitions root element for clarity)

    這個流程對應的可執行XML像這樣(忽略聲明用的definitions根元素)

<process id="noneStartEndEvent" name="BPMN2 Example none start and end event">

    <startEvent id="start" />

    <sequenceFlow id="flow1" name="fromStartToEnd"
      sourceRef="start" targetRef="end" />

    <endEvent id="end" name="End" />

  </process>        
      

    A process instances can now be created by calling the startProcessInstanceXXX operations.

    現在可以通過調用startProcessInstanceXXX操作,建立一個流程執行個體。

ProcessInstance processInstance = executionService.startProcessInstanceByKey("noneStartEndEvent"); 
           

3.8.4. Event: Terminate end event(事件:終止結束事件)

    The difference between a 'terminate' and a 'none' end event lies in the fact how a path of execution is treated (or a 'token' in BPMN 2.0 terminology). The 'terminate' end event will end the complete process instance, whereas the 'none' end event will only end the current path of execution. They both don't throw anything when the end event is reached.

    終止和空結束事件的差別是實際中流程的路徑是如何處理的(或者使用BPMN 2.0的術語叫做token)。 終止結束事件會結束整個流程執行個體,而空結束事件隻會結束目前流程路徑。他們在到達結束事件的時候都不會抛出任何資訊。

    A terminate end event is defined as follows. An id is required, a name is optional.

    一個終止結束事件定義如下。id是必需的,name則是可選的。

<endEvent id="terminateEnd" name="myTerminateEnd">
  <terminateEventDefinition/>
</endEvent>
      

    A terminate end event is depicted as an end event (circle with thick border), with a full circle as icon inside. In the following example, completing the 'task1' will end the process instance, while completing the 'task2' will only end the path of execution which enters the end event, leaving the task1 open.

    終止結束事件使用一個擁有厚邊框的圓和内部圖示為實心圓來表示。在下面的例子中,完成task1會結束流程執行個體,當完成task2時隻會結束到達結束事件的流程路徑,而task1保持為打開狀态不變。

jBPM Developers Guide(jBPM開發指南)--Chapter 3. BPMN 2.0(第二部分)

    See the examples shipped with the jBPM distribution for the unit test and XML counterpart of this business process.

   可以參考jBPM釋出包中的示例,單元測試和業務流程對應XML。

繼續閱讀