JBPM知識點------JPDL3.1規範

 

JBPM知識點------JPDL3.1規範

分類: JBPM 656人閱讀 評論 (0) 收藏 舉報

前言:

這是jBPM3.1指南第16章的翻譯。但不僅僅是簡單的翻譯而已。其中加入了我對jBPM的JPDL規範和技術的理解。我已經對其進行了全面的擴充講解!
應該說,本文是一份非常有用的jBPM的技術參考,其內容已經完全涵蓋了jBPM指南的所有要點!
它既可以作爲你的jBPM和JPDL的參考速查手冊,也可以用作學習jBPM和JPDL規範的教材。它完全濃縮了jBPM官方指南的精華。
另外,我還保留了英文原文。這對於您的理解應該是有好處的。如果有的地方我理解錯了,您可以看到原文的表達。另外,對於過於簡單的英文,我就不翻譯了。這是我的風格,希望您能夠喜歡。
注意:
一、節點的命名規則
1,State等待狀態,使用被管理的對象的狀態作爲名字。
 
2,TaskNode任務節點,使用該階段處理的任務的名字作爲名字。而不使用被管理的對象的狀態。
 
    該階段/業務程序、步驟 的任務, 最適合作爲節點的名字! 因爲,不能夠回到start-state。所以,使用被管理對象的狀態,在遇到start-state是會出現問題!
二、 jBPM的所有事件
 1<xs:enumeration value="node-enter"/>節點進入(Start-state沒有)
 2<xs:enumeration value="node-leave"/>節點離開
 3<xs:enumeration value="process-start"/>業務程序實例開始
 4<xs:enumeration value="process-end"/>業務程序實例結束
 5<xs:enumeration value="task-create"/>任務創建
 6<xs:enumeration value="task-assign"/>任務分配(AssignmentHandler)
  7<xs:enumeration value="task-start"/>任務開始
8<xs:enumeration value="task-end"/>任務結束
 9<xs:enumeration value="before-signal"/>執行轉向前
 10<xs:enumeration value="after-signal"/>執行轉向後
 11<xs:enumeration value="superstate-enter"/>進入父狀態
 12<xs:enumeration value="superstate-leave"/>離開父狀態
 13<xs:enumeration value="timer-create"/>創建定時器(創建和首次執行期間可以設duedate延時)
 14<xs:enumeration value="subprocess-created"/>子業務程序實例創建
 15<xs:enumeration value="subprocess-end"/>子業務程序實例結束
 
三、jBPM的WebApp管理程序使用的是:
MyFaces   -----Apache
MyFaces JavaServer(tm) Faces(JSF) Web框架 (JSR 127)的一個實現。JavaServer(tm) Faces Web框架是一個新的實現MVC模式的規範.它可以與Struts框架相媲美甚至的一些特性與觀念已經超過了Struts.【FacesIDE :Eclipse下的一個輔助開發插件】.
 
四、它們3個總是一起的。這可能是jboss seam容器的功能。可以組裝對象。
Class 全類名
attribute
optional
the fully qualified classname of an implementation of org.jbpm.taskmgmt.def.AssignmentHandler
config-type 配置類型
attribute
optional
{ field | bean | constructor | configuration-property }. Specifies how the assignment-handler-object should be constructed and how the content of this element should be used as configuration information for that assignment-handler-object.
 
{content}
optional
the content of the assignment-element can be used as configuration information for your AssignmentHandler implementations. This allows the creation of reusable delegation classes. for more about delegation configuration, see Section 16.2.3, “Configuration of delegations” .
 
五、任務實例TaskInstance
1,TaskNode的任務,默認情況下,會在TaskNode的execute方法中自動創建所有任務的實例。
TaskNode可以有多個任務。
2,Start-state也可以有Task,但只能有一個。這叫做開始任務。
這個開始任務,必須由用戶創建。它的參與者是當前JbpmContext的參與者。
TaskInstance taskInstance = null ;
 
    jbpmContext .setActorId( "cookie monster" );
    // create a task to start the websale process
    taskInstance = processInstance .getTaskMgmtInstance().createStartTaskInstance();
 
3,沒有開始任務,不創建開始任務都是可以的。
 
 
 
正文:
   JPDL specifies an xml schema and the mechanism to package all the process definition related files into a process archive.
JPDL指定了一個XML模式,這個機制打包所有的業務程序定義相關文件進一個業務程序存檔文件。
16.1. The process archive業務程序存檔文件
A process archive is a zip file. The central file in the process archive is processdefinition.xml . The main information in that file is the process graph. The processdefinition.xml also contains information about actions and tasks. A process archive can also contain other process related files such as classes, ui-forms for tasks, ...
processdefinition.xml 文件中的主要信息是業務程序圖表。也包含動作和任務的相關信息。一個業務程序存檔文件也能包含其它業務程序相關文件,例如:類,任務的UI窗體等。(一般不必包含,打包文件實際上是一個目錄*.par)
16.1.1. Deploying a process archive部署一個業務程序存檔文件
Deploying process archives can be done in 3 ways: with the process designer tool, with an ant task or programatically.
3種方法:
1,業務程序設計工具;
2,ant任務
3,編程方式。
Deploying a process archive with the designer tool is still under construction.
設計工具還在開發中。
Deploying a process archive with an ant task can be done as follows:
<target name="deploy.par">

 <taskdef name="deploypar" classname="org.jbpm.ant.DeployParTask">

    <classpath --make sure the jbpm-[version].jar is in this classpath--/> 



  </taskdef> 



  <deploypar par="build/myprocess.par" /> 



</target>

To deploy more process archives at once, use the nested fileset elements. The file attribute itself is optional. Other attributes of the ant task are:
要一次打包和發佈多個業務程序定義,需要嵌套地使用fileset元素。File屬性是可選的。Ant任務的其他屬性是:
  • cfg : cfg is optional, the default value is 'hibernate.cfg.xml'. The hibernate configuration file that contains the jdbc connection properties to the database and the mapping files.
Cfg: 這個是 Hibernate 數據源的配置文件。
  • properties : properties is optional and overwrites *all* hibernate properties as found in the hibernate.cfg.xml
屬性:可選,用來重寫hibernate.cfg.xml中所有的 Hibernate屬性。不能替換一部分,只能全部替換。
  • createschema : if set to true, the jbpm database schema is created before the processes get deployed.
創建模式(數據庫表):如果設爲 true ,那麼每一次部署業務程序之前,都會重新創建 jBPM 初始化的數據庫表!
Process archives can also be deployed programmatically with the class org.jbpm.jpdl.par.ProcessArchiveDeployer
16.1.2. Process versioning業務程序版本
Process definitions should never change because it is extremely difficult (if not, impossible) to predict all possible side effects of process definition changes.
業務程序定義應該從不改變。因爲它是非常重要的。無法預知定義改變可能帶來哪些意想不到的問題。
To get around this problem, jBPM has a sophicticated process versioning mechanism. The versioning mechanism版本機制 allows multiple process definitions of the same name to coexist in the database. A process instance can be started in the latest version available at that time and it will keep on executing in that same process definition for its complete lifetime. When a newer version is deployed, newly created instances will be started in the newest version, while older process instances keep on executing in the older process defintions.
圍繞這個問題,jBPM提供了一個版本機制。版本機制允許多個同名的業務程序定義在數據庫中共存。舊版本業務程序定義的實例將按照舊的定義執行。新版本業務程序定義的實例,將始終依照新的定義執行。
Process definitions are a combination of a declaratively specified process graph and optionally, a set of related java classes. The java classes can be made available to the jBPM runtime environment in 2 ways : by making sure these classes are visible to the jBPM classloader. This usually means that you can put your delegation classes in a .jar file next to the jbpm-[version].jar . The java classes can also be included in the process archive. When you include your delegation classes in the process archive (and they are not visible to the jbpm classloader), jBPM will also apply versioning版本 on these classes. More information about process classloading can be found in Section 16.2, “Delegation”
業務程序定義是特定的業務程序圖表(.xml定義文件)和一系列相關的java類(可以沒有)的結合。這些Java類都是在.xml文件中指定的。當然,還有支持jPDL的jBPM引擎。
jBPM運行時環境可用的Java類有2種方法:
1,確信這些類對於jBPM類載入器是可用的。
Java類能夠和jBPM的jar包放在一起。或者,java類能夠放在業務程序存檔文件中。
總之,在classpath中,就對程序的類載入器可見。
When a process archive gets deployed, it creates a process definition in the jBPM database. Process definitions can be versioned on the basis of the process definition name. When a named process archive gets deployed, the deployer will assign a version number. To assign this number, the deployer will look up the highest version number for process definitions with the same name and adds 1. Unnamed process definitions will always have version number -1.
當一個業務程序存檔文件部署以後,它在JBPM數據庫中創建一個業務程序定義。部署器將分配一個版本號給業務程序定義。未命名的業務程序定義的版本號是-1。
16.1.3. Changing deployed process definitions
更改已部署的業務程序定義
Changing process definitions after they are deployed into the jBPM database has many potential pitfalls. Therefor, this is highly discouraged.
更改已經部署在jBPM數據庫中的業務程序定義有許多潛在的風險,強烈建議你不這樣做。應該重新部署新版本的業務程序定義。
Actually實際上, there is a whole variety of possible changes that can be made to a process definition. Some of those process definitions are harmless, but some other changes have implications far beyond the expected and desirable.
So please consider migrating process instances to a new definition over this approach.
In case you would consider it, these are the points to take into consideration:
需要考慮的事項:
Use hibernate's update : You can just load a process definition, change it and save it with the hibernate session. The hibernate session can be accessed with the method JbpmContext.getSession() .
使用Hibernate的更新:得到Hibernate Session,修改數據庫中的業務程序定義。
The second level cache : A process definition would need to be removed from the second level cache after you've updated an existing process definition. See also Section 7.10, “Second level cache”
二級緩存:更改後,必須將業務程序定義從二級緩存中刪除。原來使用二級緩存是因爲基本上業務程序定義很少更改。
16.1.4. Migrating process instances移植業務程序實例
(尚未開發)
An alternative approach to changing process definitions might be to convert the executions to a new process definition. Please take into account that this is not trivial due to the long-lived nature of business processes. Currently, this is an experimental area so for which there are not yet much out-of-the-box support.
一種可選的改變業務程序定義的方法,可能是把原來業務程序實例轉變爲依照新的業務程序定義。這樣做的理由是,長生命週期的業務程序實例。
如,CMS系統的新聞採集、提交、歸檔。所有發佈中的文檔,都是未結束的工作流管理的對象。如果該條工作流的定義發生了變化。那麼,非常有可能需要把執行中的大量業務程序實例都發出去。
這是一個實驗領域,還沒有很多經驗。
As you know there is a clear distinction between process definition data, process instance data (the runtime data) and the logging data. With this approach, you create a separate new process definition in the jBPM database (by e.g. deploying a new version of the same process).
業務程序定義數據、業務程序實例數據和日誌數據之間有清晰的區別。你創建一個新版本的業務程序定義。
 Then the runtime information is converted to the new process definition. This might involve a translation cause tokens in the old process might be pointing to nodes that have been removed in the new version. So only new data is created in the database. But one execution of a process is spread over two process instance objects.
業務程序實例轉換到新的業務程序定義。這可能造成這樣的情況,token中的節點指針指向了一個新版本中已經刪除的節點。把一個業務程序實例劃分爲多個業務程序實例對象。
 This might become a bit tricky for the tools and statistics calculations. When resources permit us, we are going to add support for this in the future. E.g. a pointer could be added from one process instance to it's predecessor。
未來我們可能提供:業務程序實例中增加一個能夠指向前輩實例的指針。
16.1.5. Process conversion業務程序轉化
A conversion class has been made available to assist you with converting your jBPM 2.0 process archives into jBPM 3.0 compatible process archives. Create an output directory to hold the converted process archives. Enter the following command line from the build directory of the jBPM 3.0 distribution:
 
java -jar converter.jar indirectory outdirectory
Substitute the input directory where your jBPM 2.0 process archives reside for "indirectory". Substitute the output directory for the one you created to hold the newly converted process archives for "outdirectory".
 
16.2. Delegation委派
Delegation is the mechanism used to include the users' custom code in the execution of processes.
委派是一個機制,用來在業務程序的執行中包含用戶的定製代碼。
委派類是指,在業務程序實例的執行過程中被調用的用戶自定義的Java類。
 
委派類,應該是指jPDL定義中需要用到的Java類。如,ActionHandler,執行動作、業務邏輯。
AssignmentHandler,執行任務分派。把任務或泳道分配給用戶或用戶池。
條件等。
這些都使用了參數回調模式。用戶提供的這些類,會被jBPM所調用。這些類可以使用jBPM傳入的業務程序實例和任務等的信息。
委派模式,就是把任務交給下層助手類去處理。jBPM中之所以叫我們自定義的類爲委派類。就是jBPM把任務交給了這些助手類。通過接口調用這些助手類。ActionHandler等實現類,實際上還是委派模式的委派者。它們可能還會繼續把任務委派給助手類!
16.2.1. The jBPM class loader
jBPM類載入器
The jBPM class loader is the class loader that loads the jBPM classes. Meaning, the classloader that has the library jbpm-3.x.jar in its classpath. To make classes visible to the jBPM classloader, put them in a jar file and put the jar file besides the jbpm-3.x.jar . E.g. in the WEB-INF/lib folder in the case of webapplications.
 
16.2.2. The process class loader業務程序類載入器
Delegation classes are loaded with the process class loader of their respective process definition. The process class loader is a class loader that has the jBPM classloader as a parent. The process class loader adds all the classes of one particular process definition. You can add classes to a process definition by putting them in the /classes folder in the process archive. Note that this is only useful when you want to version the classes that you add to the process definition. If versioning is not necessary, it is much more efficient to make the classes available to the jBPM class loader.
在業務程序存檔文件的/classes目錄中的類,增加到了業務程序定義中。每個業務程序定義可以有一個類載入器。他們的父類載入器是jBPM的類載入器。
注意,這僅僅在你要版本化你的業務程序定義的委派類時,才值得這麼做。
即,一個業務程序定義,需要一種委派類。
 
16.2.3. Configuration of delegations委派的配置
Delegation classes contain user code that is called from within the execution of a process. The most common example is an action. In the case of action, an implementation of the interface ActionHandler can be called on an event in the process. Delegations are specified in the processdefinition.xml . 3 pieces of data can be supplied when specifying a delegation :
委派類是指,在業務程序實例的執行過程中被調用的用戶自定義的Java類。
最普通的例子是Action。委派的Java類在processdefinition.xml中被指定。
指定一個委派的Java類需要提供3塊數據:
// 這是通過字段實現的
<action class="org.test.MyAction">

 <city>Atlanta</city>

 <rounds>5</rounds>

</action>

 
  • 1) the class name (required) : the fully qualified class name of the delegation class.
1,類名:委派類的全名
<action class="org.test.MyAction">

 
  • 2) configuration type (optional) : specifies the way to instantiate and configure the delegation object. By default the default constructor is used and the configuration information is ignored.
2,配置類型:
如:
   <assignment class="com.withub.cms.jbpm.assignmenthandler.WriteNewsAssignmentHandler" config-type="constructor"></assignment>
有4種配置類型:
1)Field------直接給目標類的字段賦值。 字段沒有set/get方法,不是一個屬性。該類也不是一個Bean。這應該是使用CGLIB字節碼生成實現的。也可能使用反射。
< assignment class = "com.withub.cms.jbpm.assignmenthandler.WriteNewsAssignmentHandler" >
            < a > a </ a >
         </ assignment >
2)Bean------通過set方法賦值。   這和Spring的<property>是一致的。
< assignment class = "com.withub.cms.jbpm.assignmenthandler.WriteNewsAssignmentHandler" config-type = "bean" >
            < a > a </ a >
         </ assignment >
3)constructor-----傳給構造器的參數。
< assignment class = "com.withub.cms.jbpm.assignmenthandler.WriteNewsAssignmentHandler" config-type = "constructor" >
            a
         </ assignment >
4)compatibility-----兼容性
< assignment class = "com.withub.cms.jbpm.assignmenthandler.WriteNewsAssignmentHandler" config-type = "configuration-property" >
            a
         </ assignment >
就是configuration-property
什麼都沒有,就是默認構造器。
Field 字段,也不需要。
 
< assignment class = "com.withub.cms.jbpm.assignmenthandler.WriteNewsAssignmentHandler" config-type = "configuration-property" >
            a
         </ assignment >
配置類型和配置,類似於Spring IOC容器的對象裝配。
如:<bean id="odExchangeUserForecastDao" class="com.telecom.ldbs.exchange.ExchangeUserForecast.datadeclare.dao.impl.OdExchangeUserForecastDaoImpl">
        <property name="sessionFactory">
               <ref bean="sessionFactory"/>
        </property>
</bean>
這是對屬性的管理
 
<city>
  • 3) configuration (optional) : the configuration of the delegation object in the format as required by the configuration type.
3,配置
Atlanta
 
Next is a description of all the configuration types:
 
配置類型
16.2.3.1. config-type field配置類型字段
 
This is the default configuration type. The config-type field will first instantiate an object of the delegation class and then set values in the fields of the object as specified in the configuration. The configuration is xml, where the elementnames have to correspond with the field names of the class. The content text of the element is put in the corresponding field. If necessary and possible, the content text of the element is converted to the field type.
這是默認的配置類型。不配置,也會使用默認無參構造器生成對象。
config-type ="field" ,或者不設置屬性,那麼會首先實例化委派/回調java類的對象。然後用配置中的值設置對象的字段的值。字段的配置是xml格式的。xml元素名和類的字段名相同。xml元素的文本內容,賦值給這個字段。Xml的文本元素能夠被正確的轉換爲字段所需的類型。
(Spring也可以。是特殊的類型,在Spring中一般是另一個Spring管理的對象)
Supported type conversions:
支持的類型轉換:
  • String doesn't need converting, of course. But it is trimmed.
String不需要轉換,但會2邊切除空格。
  • primitive types such as int, long, float, double, ...
原生類型
  • and the basic wrapper classes for the primitive types.
原生類型的包裝類
  • lists, sets and collections. In that case each element of the xml-content is consitered as an element of the collection and is parsed, recursively applying the conversions. If the type of the elements is different from java.lang.String this can be indicated by specifying a type attribute with the fully qualified type name. For example, following snippet will inject an ArrayList of Strings into field 'numbers':
List,Set,Collection這些集合類。Xml內容的每一個元素被認爲是集合的一個元素。這些元素被分別遞歸轉換類型。
如果元素的類型不是String。可以通過指出類型的全類名來進行轉換。
·                





<numbers>

·                





  <element>one</element>



·                





  <element>two</element>



·                





  <element>three</element>



</numbers>

如,指定元素的屬性

·                





<numbers>

·                





  <element type=

"com.withub.cms.jbpm.assignmenthandler.WriteNewsAssignmentHandler">one</element>

·                





  <element>two</element>



·                





  <element>three</element>



</numbers>

 

 

The text in the elements can be converted to any object that has a String constructor. To use another type then String, specify the element-type in the field element ('numbers' in this case).
Here's another example of a map:
<numbers>

 <entry><key>one</key><value>1</value></entry>

 <entry><key>two</key><value>2</value></entry>

 <entry><key>three</key><value>3</value></entry>

</numbers>

  • maps. In this case, each element of the field-element is expected to have one subelement key and one element value . The key and element are both parsed using the conversion rules recursively. Just the same as with collections, a conversion to java.lang.String is assumed if no type attribute is specified.
  • org.dom4j.Element
  • for any other type, the string constructor is used.
任何使用了String構造器的類。(String唯一參數的構造器)
For example in the following class...
public class MyAction implements ActionHandler {

 // access specifiers can be private, default, protected or public

 private String city;

 Integer rounds;

 ...

}

...this is a valid configuration:
這是有效的配置:
...

<action class="org.test.MyAction">

 <city>Atlanta</city>

 <rounds>5</rounds>

</action>

...

16.2.3.2. config-type bean配置類型Bean
Same as config-type field but then the properties are set via setter methods, rather then directly on the fields. The same conversions are applied.
類似於配置類型字段,但它是通過set方法設置的。而不是直接作用於字段。
 
必有set方法,是屬性(可以沒有get方法)。
 
16.2.3.3. config-type constructor配置類型構造器
This instantiator will take the complete contents of the delegation xml element and passes this as text in the delegation class constructor.
把參數作爲String傳入到構造器中。類必須有這樣的構造器:
Class(String string){
};//這樣的構造器。
 
16.2.3.4. config-type configuration-property配置類型----配置屬性
First, the default constructor is used, then this instantiator will take the complete contents of the delegation xml element, and pass it as text in method void configure(String); . (as in jBPM 2)
第一,使用默認構造器創建對象。會把xml元素定義的內容傳遞到類的方法:
configure(String)
    這個已經不大使用了!
16.3. Expressions表達式
For some of the delegations, there is support for a JSP/JSF EL like expression language. In actions, assignments and decision conditions, you can write an expression like e.g.
在一些委派Java中,支持EL語言。類似於EL表達式。在action,任務分配,決定條件,你能寫一個表達式:
expression="#{myVar.handler[assignments].assign}"
 
注意,jBPM的Web應用頁面也使用這種EL。
如:<h:commandButton action="#{taskBean.save}" value="Save"/>
Save是方法名。也可以跟屬性名。、
<h2><h:outputText value="#{taskBean.taskInstance.name}" /></h2>   
JSP的EL 語言 只能通過建立表達式 ${exp1} 來進行調用。
 
The basics of this expression language can be found in the J2EE tutorial .
The jPDL expression language is similar to the JSF expression language. Meaning that jPDL EL is based on JSP EL, but it uses #{...} notation and that it includes support for method binding.
jPDL表達式語言類似於JSF表達式語言。這意味着,jPDL EL基於JSP EL。但它使用#{ }符號,包括對方法綁定的支持。
Depending on the context, the process variables or task instance variables can be used as starting variables along with the following implicit objects:
依靠上下文,業務程序變量和任務變量連同下面的對象能夠被用作EL表達式的開始變量:   也就是說可以直接在EL表達式#{…}中使用!
  • taskInstance (org.jbpm.taskmgmt.exe.TaskInstance)任務實例
  • processInstance (org.jbpm.graph.exe.ProcessInstance)業務程序實例
  • processDefinition (org.jbpm.graph.def.ProcessDefinition)業務程序定義
  • token (org.jbpm.graph.exe.Token)執行路徑
  • taskMgmtInstance (org.jbpm.taskmgmt.exe.TaskMgmtInstance)任務管理實例
  • contextInstance (org.jbpm.context.exe.ContextInstance)上下文實例
This feature becomes really powerfull in a JBoss SEAM environment. Because of the integration between jBPM and JBoss SEAM , all of your backed beans, EJB's and other one-kind-of-stuff becomes available right inside of your process definition. Thanks Gavin ! Absolutely awsome ! :-)
這些特性是Jboss SEAM這個IOC容器提供的。因爲jBPM和Jboss SEAM的綜合,所有你的後臺JavaBean類,EJB和其他類能夠正確地被你的業務程序定義中使用。
我可以使用Spring容器。通過把Spring容器對象引用放到業務程序實例的臨時變量中,在被委派處理類中調用Spring管理的類!
16.4. jPDL xml schema
jPDL的XML模式
The jPDL schema is the schema used in the file processdefinition.xml in the process archive.
16.4.1. Validation確認
When parsing a jPDL XML document, jBPM will validate your document against the jPDL schema when two conditions are met: first, the schema has to be referenced in the XML document like this
要執行xsd驗證,需要2個條件:
1,指定xmlns
<process-definition xmlns="urn:jbpm.org:jpdl-3.1">

 ...

</process-definition>

And second, the xerces parser has to be on the classpath.
2,xerces的jar包放在classpath中。
The jPDL schema can be found in ${jbpm.home}/src/java.jbpm/org/jbpm/jpdl/xml/jpdl-3.1.xsd or at http://jbpm.org/jpdl-3.1.xsd .
jpdl-3.1.xsd
<?xml version="1.0" encoding="UTF-8"?>
 
<xs:schema xmlns=          "urn:jbpm.org:jpdl-3.1"
           targetNamespace="urn:jbpm.org:jpdl-3.1"
           xmlns:xs="http://www.w3.org/2001/XMLSchema"
           elementFormDefault="qualified">
 
 <!-- PROCESS-DEFINITION -->
 <!-- ################## -->
 <xs:element name="process-definition">
    <xs:complexType>
      <xs:choice minOccurs="0" maxOccurs="unbounded">
        <xs:element ref="swimlane" />
        <xs:element ref="start-state" />
        <xs:group   ref="node-elements"/>
        <xs:group   ref="action-elements" />
        <xs:element ref="event" />
        <xs:element ref="exception-handler" />
        <xs:element ref="task" />
      </xs:choice>
      <xs:attribute name="name" type="xs:string" use="required" />
    </xs:complexType>
 </xs:element>
 
 <!-- SWIMLANE -->
 <!-- ######## -->
 <xs:element name="swimlane">
    <xs:complexType>
      <xs:sequence minOccurs="0" maxOccurs="1">
        <xs:element ref="assignment"/>
      </xs:sequence>
      <xs:attribute name="name" type="xs:string" use="required" />
    </xs:complexType>
 </xs:element>
 
 <!-- NODES -->
 <!-- ##### -->
 <xs:element name="start-state">
    <xs:complexType>
      <xs:choice minOccurs="0" maxOccurs="unbounded">
        <xs:element ref="task"/>
        <xs:element ref="transition"/>
        <xs:element ref="event"/>
        <xs:element ref="exception-handler"/>
      </xs:choice>
      <xs:attribute name="name" type="xs:string"/>
    </xs:complexType>
 </xs:element>
 
 <xs:element name="end-state">
    <xs:complexType>
      <xs:choice minOccurs="0" maxOccurs="unbounded">
        <xs:element ref="event"/>
        <xs:element ref="exception-handler"/>
      </xs:choice>
      <xs:attribute name="name" type="xs:string" use="required"/>
    </xs:complexType>
 </xs:element>
 
 <xs:element name="decision">
    <xs:complexType>
      <xs:choice minOccurs="0" maxOccurs="unbounded">
        <xs:element name="handler" type="delegation" />
        <xs:element ref="event"/>
        <xs:element ref="exception-handler"/>
        <xs:element name="transition">
          <xs:complexType>
            <xs:choice minOccurs="0" maxOccurs="unbounded">
              <xs:element name="condition">
                <xs:complexType mixed="true">
                  <xs:sequence minOccurs="0" maxOccurs="unbounded">
                    <xs:any processContents="lax" minOccurs="0" maxOccurs="unbounded" />
                  </xs:sequence>
                  <xs:attribute name="expression" type="xs:string" />
                </xs:complexType>
              </xs:element>
              <xs:group ref="action-elements"/>
              <xs:element ref="exception-handler"/>
            </xs:choice>
            <xs:attribute name="to" type="xs:string" use="required" />
            <xs:attribute name="name" type="xs:string" />
          </xs:complexType>
        </xs:element>
      </xs:choice>
      <xs:attribute name="name" type="xs:string" use="required"/>
      <xs:attribute name="expression" type="xs:string" />
      <xs:attribute name="async" type="xs:string" default="false" />
    </xs:complexType>
 </xs:element>
 
 <xs:element name="fork">
    <xs:complexType>
      <xs:choice minOccurs="0" maxOccurs="unbounded">
        <xs:element ref="script" />
        <xs:group ref="node-content-elements" />
      </xs:choice>
      <xs:attribute name="name" type="xs:string" use="required"/>
      <xs:attribute name="async" type="xs:string" default="false" />
    </xs:complexType>
 </xs:element>
 
 <xs:element name="join">
    <xs:complexType>
      <xs:choice minOccurs="0" maxOccurs="unbounded">
        <xs:group ref="node-content-elements" />
      </xs:choice>
      <xs:attribute name="name" type="xs:string" use="required"/>
      <xs:attribute name="async" type="xs:string" default="false" />
    </xs:complexType>
 </xs:element>
 
 <xs:element name="node">
    <xs:complexType>
      <xs:sequence>
        <xs:choice minOccurs="0">
          <xs:group ref="action-elements" />
        </xs:choice>
        <xs:choice minOccurs="0" maxOccurs="unbounded">
          <xs:group ref="node-content-elements" />
        </xs:choice>
      </xs:sequence>
      <xs:attribute name="name" type="xs:string" use="required"/>
      <xs:attribute name="async" type="xs:string" default="false" />
    </xs:complexType>
 </xs:element>
 
 <xs:element name="process-state">
    <xs:complexType>
      <xs:choice minOccurs="0" maxOccurs="unbounded">
        <xs:element name="sub-process">
         <xs:complexType>
            <xs:attribute name="name" type="xs:string" use="required" />
            <xs:attribute name="version" type="xs:integer" />
          </xs:complexType>
        </xs:element>
        <xs:element ref="variable" />
        <xs:group ref="node-content-elements" />
      </xs:choice>
      <xs:attribute name="name" type="xs:string" use="required"/>
      <xs:attribute name="async" type="xs:string" default="false" />
    </xs:complexType>
 </xs:element>
 
 <xs:element name="state">
    <xs:complexType>
      <xs:choice minOccurs="0" maxOccurs="unbounded">
        <xs:group ref="node-content-elements"/>
      </xs:choice>
      <xs:attribute name="name" type="xs:string" use="required"/>
      <xs:attribute name="async" type="xs:string" default="false" />
    </xs:complexType>
 </xs:element>
 
 <xs:element name="super-state">
    <xs:complexType>
      <xs:choice minOccurs="0" maxOccurs="unbounded">
        <xs:group ref="node-elements"/>
        <xs:group ref="node-content-elements"/>
      </xs:choice>
      <xs:attribute name="name" type="xs:string" use="required"/>
      <xs:attribute name="async" type="xs:string" default="false" />
    </xs:complexType>
 </xs:element>
 
 <xs:element name="task-node">
    <xs:complexType>
      <xs:choice minOccurs="0" maxOccurs="unbounded">
        <xs:element ref="task" />
        <xs:group ref="node-content-elements" />
      </xs:choice>
      <xs:attribute name="name" type="xs:string" use="required"/>
      <xs:attribute name="create-tasks" type="booleanType" default="true" />
      <xs:attribute name="end-tasks" type="booleanType" default="false" />
      <xs:attribute name="signal" default="last">
        <xs:simpleType>
          <xs:restriction base="xs:string">
            <xs:enumeration value="unsynchronized"/>
            <xs:enumeration value="never"/>
            <xs:enumeration value="first"/>
            <xs:enumeration value="first-wait"/>
            <xs:enumeration value="last"/>
            <xs:enumeration value="last-wait"/>
          </xs:restriction>
        </xs:simpleType>
      </xs:attribute>
      <xs:attribute name="async" type="xs:string" default="false" />
    </xs:complexType>
 </xs:element>
 
 <!-- TRANSITION -->
 <!-- ########## -->
 <xs:element name="transition">
    <xs:complexType>
      <xs:choice minOccurs="0" maxOccurs="unbounded">
        <xs:group ref="action-elements"/>
        <xs:element ref="exception-handler" />
      </xs:choice>
      <xs:attribute name="to" type="xs:string" use="required" />
      <xs:attribute name="name" type="xs:string" />
    </xs:complexType>
 </xs:element>
 
 <!-- ACTIONS -->
 <!-- ####### -->
 <xs:element name="action">
    <xs:complexType mixed="true">
      <xs:sequence>
        <xs:any processContents="lax" minOccurs="0" maxOccurs="unbounded" />
      </xs:sequence>
      <xs:attribute name="class" type="xs:string" />
      <xs:attribute name="config-type" default="field">
        <xs:simpleType>
          <xs:restriction base="xs:string">
            <xs:enumeration value="field"/>
            <xs:enumeration value="bean"/>
            <xs:enumeration value="constructor"/>
            <xs:enumeration value="configuration-property"/>
          </xs:restriction>
        </xs:simpleType>
      </xs:attribute>
      <xs:attribute name="name" type="xs:string" />
      <xs:attribute name="ref-name" type="xs:string" />
      <xs:attribute name="accept-propagated-events" type="booleanType" default="true" />
      <xs:attribute name="expression" type="xs:string" />
      <xs:attribute name="async" type="xs:string" />
    </xs:complexType>
 </xs:element>
 
 <xs:element name="cancel-timer">
    <xs:complexType>
      <xs:attribute name="name" type="xs:string" use="required" />
    </xs:complexType>
 </xs:element>
 
 <xs:element name="create-timer">
    <xs:complexType>
      <xs:choice>
        <xs:element ref="action"/>
        <xs:element ref="script"/>
      </xs:choice>
      <xs:attribute name="duedate" type="xs:string" use="required" />
      <xs:attribute name="name" type="xs:string" />
      <xs:attribute name="repeat" type="xs:string" />
      <xs:attribute name="transition" type="xs:string" />
    </xs:complexType>
 </xs:element>
 
 <xs:element name="script">
    <xs:complexType mixed="true">
      <xs:sequence>
        <xs:any processContents="lax" minOccurs="0" maxOccurs="unbounded" />
      </xs:sequence>
      <xs:attribute name="name" type="xs:string" />
      <xs:attribute name="accept-propagated-events" type="booleanType" default="true" />
    </xs:complexType>
 </xs:element>
 
 <!-- EVENT -->
 <!-- ##### -->
 <xs:element name="event">
    <xs:complexType>
      <xs:choice minOccurs="0" maxOccurs="unbounded">
        <xs:group ref="action-elements"/>
      </xs:choice>
      <xs:attribute name="type" use="required">
        <xs:simpleType>
          <xs:union>
            <xs:simpleType>
              <xs:restriction base="xs:string"/>
            </xs:simpleType>
            <xs:simpleType>
              <xs:restriction base="xs:string">
                <xs:enumeration value="node-enter"/>
                <xs:enumeration value="node-leave"/>
                <xs:enumeration value="process-start"/>
                <xs:enumeration value="process-end"/>
                <xs:enumeration value="task-create"/>
                <xs:enumeration value="task-assign"/>
                <xs:enumeration value="task-start"/>
                <xs:enumeration value="task-end"/>
                <xs:enumeration value="before-signal"/>
                <xs:enumeration value="after-signal"/>
                <xs:enumeration value="superstate-enter"/>
                <xs:enumeration value="superstate-leave"/>
                <xs:enumeration value="timer-create"/>
                <xs:enumeration value="subprocess-created"/>
                <xs:enumeration value="subprocess-end"/>
              </xs:restriction>
            </xs:simpleType>
          </xs:union>
        </xs:simpleType>
      </xs:attribute>
    </xs:complexType>
 </xs:element>
 
 <!-- EXCEPTION-HANDLER -->
 <!-- ################# -->
 <xs:element name="exception-handler">
    <xs:complexType>
      <xs:choice minOccurs="1" maxOccurs="unbounded">
        <xs:element ref="action"/>
        <xs:element ref="script"/>
      </xs:choice>
      <xs:attribute name="exception-class" type="xs:string"/>
    </xs:complexType>
 </xs:element>
 
 <!-- TASK -->
 <!-- #### -->
 <xs:element name="task">
    <xs:complexType>
      <xs:choice minOccurs="0" maxOccurs="unbounded">
        <xs:element ref="assignment"/>
        <xs:element ref="controller"/>
        <xs:element ref="event"/>
        <xs:element ref="timer"/>
      </xs:choice>
      <xs:attribute name="name" type="xs:string" />
      <xs:attribute name="blocking" type="booleanType" default="false"/>
      <xs:attribute name="signalling" type="booleanType" default="true"/>
      <xs:attribute name="description" type="xs:string" />
      <xs:attribute name="duedate" type="xs:string" />
      <xs:attribute name="swimlane" type="xs:string" />
      <xs:attribute name="priority" type="priorityType" default="normal" />
    </xs:complexType>
 </xs:element>
 
 <xs:element name="controller" type="delegation" />
 
 <xs:element name="assignment">
    <xs:complexType>
      <xs:complexContent>
        <xs:extension base="delegation">
          <xs:attribute name="expression" type="xs:string" />
          <xs:attribute name="actor-id" type="xs:string" />
          <xs:attribute name="pooled-actors" type="xs:string" />
        </xs:extension>
      </xs:complexContent>
    </xs:complexType>
 </xs:element>
 
 <!-- TIMER -->
 <!-- ##### -->
 <xs:element name="timer">
    <xs:complexType>
      <xs:choice>
        <xs:element ref="action"/>
        <xs:element ref="script"/>
      </xs:choice>
      <xs:attribute name="duedate" type="xs:string" use="required" />
      <xs:attribute name="name" type="xs:string" />
      <xs:attribute name="repeat" type="xs:string" />
      <xs:attribute name="transition" type="xs:string" />
    </xs:complexType>
 </xs:element>
 
 <xs:element name="variable">
    <xs:complexType>
      <xs:sequence>
        <xs:any processContents="lax" minOccurs="0" maxOccurs="unbounded" />
      </xs:sequence>
      <xs:attribute name="name" type="xs:string" use="required"/>
      <xs:attribute name="access" type="xs:string" default="read,write"/>
      <xs:attribute name="mapped-name" type="xs:string" />
    </xs:complexType>
 </xs:element>
 
 <!-- TYPES AND GROUPS -->
 <!-- ################ -->
 <xs:complexType name="delegation" mixed="true">
    <xs:sequence>
      <xs:any processContents="lax" minOccurs="0" maxOccurs="unbounded" />
    </xs:sequence>
    <xs:attribute name="class" type="xs:string" />
    <xs:attribute name="config-type" default="field">
      <xs:simpleType>
        <xs:restriction base="xs:string">
          <xs:enumeration value="field"/>
          <xs:enumeration value="bean"/>
          <xs:enumeration value="constructor"/>
          <xs:enumeration value="configuration-property"/>
        </xs:restriction>
      </xs:simpleType>
    </xs:attribute>
 </xs:complexType>
 
 <xs:simpleType name="configType">
    <xs:restriction base="xs:string">
      <xs:enumeration value="field"/>
      <xs:enumeration value="bean"/>
      <xs:enumeration value="constructor"/>
      <xs:enumeration value="configuration-property"/>
    </xs:restriction>
 </xs:simpleType>
 
 <xs:simpleType name="booleanType">
    <xs:restriction base="xs:string">
      <xs:enumeration value="yes"/>
      <xs:enumeration value="no"/>
      <xs:enumeration value="true"/>
      <xs:enumeration value="false"/>
      <xs:enumeration value="on"/>
      <xs:enumeration value="off"/>
    </xs:restriction>
 </xs:simpleType>
 
 <xs:simpleType name="priorityType">
    <xs:union>
      <xs:simpleType>
        <xs:restriction base="xs:string">
          <xs:enumeration value="highest"/>
          <xs:enumeration value="high"/>
          <xs:enumeration value="normal"/>
          <xs:enumeration value="low"/>
          <xs:enumeration value="lowest"/>
        </xs:restriction>
      </xs:simpleType>
      <xs:simpleType>
        <xs:restriction base="xs:int"/>
      </xs:simpleType>
    </xs:union>
 </xs:simpleType>
 
 <xs:group name="node-elements">
    <xs:choice>
      <xs:element ref="node"/>
      <xs:element ref="state"/>
      <xs:element ref="task-node"/>
      <xs:element ref="super-state"/>
      <xs:element ref="process-state"/>
      <xs:element ref="fork"/>
      <xs:element ref="join"/>
      <xs:element ref="decision"/>
      <xs:element ref="end-state"/>
    </xs:choice>
 </xs:group>
 
 <xs:group name="action-elements">
    <xs:choice>
      <xs:element ref="action"/>
      <xs:element ref="script"/>
      <xs:element ref="create-timer"/>
      <xs:element ref="cancel-timer"/>
    </xs:choice>
 </xs:group>
 
 <xs:group name="node-content-elements">
    <xs:choice>
      <xs:element ref="event"/>
      <xs:element ref="exception-handler"/>
      <xs:element ref="timer"/>
      <xs:element ref="transition"/>
    </xs:choice>
 </xs:group>
</xs:schema>
 
16.4.2. process-definition業務程序定義(根節點)
Table 16.1. 
Name
屬性,子元素是等價的
Type
Multiplicity
Description
name
Attribute
屬性
Optional 可以無名,版本-1
the name of the process
業務程序定義的名字
swimlane 泳道
泳道,表示業務程序的角色,用在任務分派中。
Element 元素
[0..*]
0 個或多個
the swimlanes used in this process. The swimlanes represent process roles and they are used for task assignments.
 
element
[0..1]
0 個或1個
the start state of the process. Note that a process without a start-state is valid 有效的, but cannot be executed.但不能執行
element
[0..*]
任意
the nodes of the process definition. Note that a process without nodes is valid, but cannot be executed. 注意:一個業務程序沒有節點是正確的,但不能被執行。
event 事件
process-start 業務程序實例開始
process-end 業務程序實例結束
< event type = " process-start " >
      < action name = "action1" ></ action >
   </ event >
Element 元素
[0..*]
多個
the process events that serve as a container for actions
是動作的容器。
這些是全局定義的動作,腳本,創建定時器,取消定時器。它們必須有名字。可以被事件或轉向所引用—通過名字。
element
[0..*]
global defined actions that can be referenced from events and transitions. Note that these actions must specify a name in order to be referenced.
 
task 任務
全局定義的任務,能夠被在Action等中使用。
element
[0..*]
global defined tasks that can be used in e.g. actions.
exception-handler 異常處理器
一個異常處理器列表,用於處理所有在這個業務程序定義中被委派類拋出的異常。
element
[0..*]
a list of exception handlers that applies to all exceptions thrown by delegation classes thrown in this process definition.
16.4.3 . node 節點
Table 16.2. 
Name
Type
Multiplicity
Description
一個定製的Action,代表這個節點的行爲。
element
1
a custom action that represents the behaviour for this node
公共節點元素
 
 
16.4.4 . common node elements 公共節點元素
Table 16.3. 
Name
Type
Multiplicity
Description
Name 節點名
attribute
required
the name of the node
Async 異步
attribute
{ true | false }, false is the default
If set to true, this node will be executed asynchronously. See also Chapter 13, Asynchronous continuations
transition 轉向
每一個離開轉向,離開一個節點,都必須有一個明確的名字。只有一個離開轉向,可以沒有名字。第一個指定的轉向是默認執行的轉向。
element
[0..*]
the leaving transitions. Each transition leaving a node *must* have a distinct name. A maximum of one of the leaving transitions is allowed to have no name. The first transition that is specifed is called the default transition. The default transition is taken when the node is left without specifying a transition.
event 事件
支持事件類型:進入節點,離開節點
element
[0..*]
supported event types: {node-enter|node-leave}
element
[0..*]
a list of exception handlers that applies to all exceptions thrown by delegation classes thrown in this process node.
timer 定時器
監控這個節點的執行
element
[0..*]
specifies a timer that monitors the duration of an execution in this node.
16.4.5 . start-state 開始狀態
Table 16.4.
1,task 例子
< process-definition
  xmlns = ""  name = "holidayrequest" >
   < swimlane name = "initiator" ></ swimlane >
   < swimlane name = "holidayManager" ></ swimlane >
 
   < start-state name = "enter request" >
// 這個任務1,捕獲業務程序的發起者。
//2 ,在業務程序變量上創建並填寫數據。
//3 ,在界面上,這個任務應該是一個表單。
//4 ,不能回到開始狀態;也不能離開結束狀態。這是規則!
      < task name = "request entry" swimlane = "initiator" >
         < controller >
             < variable name = "start date" access = "read,write,required" ></ variable >
            < variable name = "duration" access = "read,write,required" ></ variable >
         </ controller >
      </ task >
      < transition name = "" to = "evaluate request" ></ transition >
   </ start-state >  
Name
Type
Multiplicity
Description
name
attribute
optional
the name of the node
task 任務
這個任務開始一個新的業務程序的實例,或者捕獲業務程序的發起者。
element
[0..1]
0 或1個任務。
有特殊的用途。
the task to start a new instance for this process or to capture the process initiator. See Section 11.7, “Swimlane in start task”
event 事件
開始狀態只有節點離開事件,沒有節點進入事件。因爲不能進入開始狀態。
element
[0..*]
supported event types: {node-leave}
transition 轉向
每一個離開轉向必須有一個目標節點的名字
element
[0..*]
the leaving transitions. Each transition leaving a node *must* have a distinct name.
異常處理器
它們能夠處理所有這個節點中的委派類拋出的異常
element
[0..*]
a list of exception handlers that applies to all exceptions thrown by delegation classes thrown in this process node.
16.4.6 . end-state
Table 16.5. 
Name
Type
Multiplicity
Description
name
attribute
required
the name of the end-state
event 事件
只有節點進入事件可用,因爲無法離開。
element
[0..*]
supported event types: {node-enter}
處理這個節點中所有的Java處理類拋出的異常。
element
[0..*]
a list of exception handlers that applies to all exceptions thrown by delegation classes thrown in this process node.
16.4.7 . state 等待狀態
Table 16.6. 
Name
Type
Multiplicity
Description
 
 
16.4.8 . task-node 任務節點
任務,也類似於條件。 只是任務是用戶參與的。條件是自動的。條件有true,false。任務有完成、未完成。
Table 16.7. 
Name
Type
Multiplicity
Description
Signal 信號
默認是last。就是全部任務完成後,執行默認轉向
Attribute 屬性
optional
{unsynchronized 異 步|never從不|first第一個任務|first-wait|last全部任務|last-wait}, default is last. signal specifies the effect of task completion on the process execution continuation.
create-tasks
創建任務實例
默認是true。在執行任務節點時,創建任務節點的所有任務。也可以設爲false。這樣,你可以在運行時決定創建哪些任務實例。
此時,你可以在node-enter事件的處理ActionHandler中創建任務。當然,你也必須把create-tasks=”false”
attribute
optional
{yes|no|true|false}, default is true. can be set to false when a runtime calculation has to determine which of the tasks have to be created. in that case, add an action on node-enter, create the tasks in the action and set create-tasks to false.
end-tasks 結束任務實例
默認false。如果設爲true,離開該節點時,如果任務還沒有結束,就關掉所有沒關掉的任務實例。
attribute
optional
{yes|no|true|false}, default is false. In case remove-tasks is set to true, on node-leave, all the tasks that are still open are ended.
task 任務
當業務程序實例的執行進入該節點時,這些任務的實例會被創建
element
[0..*] 多個
the tasks that should be created when execution arrives in this task node.
 
 
16.4.9 . process-state 業務程序實例狀態
這個節點代表一個業務程序。執行到這裏以後,通過在process-state 實例上配置子業務程序實例。就會先執行子業務程序實例,子業務程序實例執行完之後,纔會繼續執行父業務程序實例。
Table 16.8. 
Name
Type
Multiplicity
多樣性
Description 描述
子業務程序,指定這個節點代表的子業務程序的定義(這樣就不用在運行時指定實例了)
element
1
the sub process that is associated with this node
variable 變量
指定數據從父業務程序實例的RootToken到子業務程序的RootToken中,這會從子業務程序實例的生命週期。最後子業務程序實例結束時,會把變量傳回並覆蓋父業務程序的變量
element
[0..*]
specifies how data should be copied from the super process to the sub process at the start and from the sub process to the super process upon completion of the sub process.
 
 
16.4.10 . super-state 節點組
超級節點是節點組。用來包括其他子節點。僅僅是一個容器。進入這個節點組,實際會進入它內部的第一個節點。內部當然不能有start-state。
Table 16.9. 
Name
Type
Multiplicity
Description
element
[0..*]
the nodes of the superstate. superstates can be nested.
 
 
16.4.11 . fork 分支
業務程序的執行分爲多路並行。僅僅是標記
Table 16.10. 
Name
Type
Multiplicity
Description
 
 
16.4.12 . join 聯接
業務程序的執行在這裏合併。僅僅是標記。Fork-join必須成對使用。
Table 16.11. 
Name
Type
Multiplicity
Description
 
 
16.4.13 . decision 決定
根據各個transition轉向的條件,決定執行哪一個轉向。是遇到第一個true的轉向就執行。
如果沒有條件是真的轉向,那麼就會執行默認轉向(第一個)!
    所以decision和Node一樣,是即時狀態,不會停下來讓參與者決定。
public interface DecisionHandler extends Serializable {
 
 String decide(ExecutionContext executionContext) throws Exception;
返回值,是離開轉向的String類型名字!
也就是說,決定
}
進入Decision節點的execute方法之後,
1 ,首先看有沒有指定handler。如果有,就得到DecisionHandler返回的轉向名。執行該transition。
2 ,看有沒有EL決定表達式.如有,執行返回的轉向。
3,計算每一個transition帶的EL條件表達式。直到有一個轉向爲true。就執行該轉向!
Table 16.12. 
Name
Type
Multiplicity 多樣性
Description
handler 處理器
只需要一個就夠了。因爲它返回決定採用的transition的名字
(2中用法:
1 ,指定DecisionHandler的實現類
2 ,EL表達式)
element
either a 'handler' element or conditions on the transitions should be specified
轉向們應該指定一個處理器或者若干個條件
the name of a org.jbpm.jpdl.Def.DecisionHandler implementation
轉向
decision 的轉向能夠使用條件。Decision將使用第一個條件=true的轉向。沒有條件的轉向是true。
element
[0..*] 多個
the leaving transitions. The leaving transitions of a decision can be extended with a condition. The decision will look for the first transition for which the condition evaluates to true. A transition without a condition is considered to evaluate to true (to model the 'otherwise' branch). See the condition element
 
 
16.4.14 . event 事件
Table 16.13. 
Name
Type
Multiplicity
Description
Type 類型(事件的類型)
 
attribute
required
the event type that is expressed relative to the element on which the event is placed
響應這個事件的動作類型:ActionHandler,腳本(BeanShell腳本,不是條件的EL表達式),創建定時器,取消定時器
element
[0..*]
the list of actions that should be executed on this event
16.4.15 . transition 轉向
Table 16.14. 
Name
Type
Multiplicity
Description
Name 轉向的名字
注意:每一個轉向必須有一個目標名字。
attribute
Optional
可選
the name of the transition. Note that each transition leaving a node *must* have a distinct name.
To 目標節點的名字
目標節點的等級名。節點的名字根據節點的作用域而來。類似於目錄結構的命名規則。
如:
<state name="preparation">

    <transition to="phase one/invite murphy"/>



 </state>

 <super-state name="phase one">

    <state name="invite murphy"/>



 </super-state>

或:
<super-state name="phase one">

    <state name="preparation">



      <transition to="../phase two/invite murphy"/>



    </state>



 </super-state>

 <super-state name="phase two">

    <state name="invite murphy"/>



 </super-state>

 
attribute
required
the hierarchical name of the destination node. For more information about hierarchical names, see Section 9.6.3, “Hierarchical names”
在執行這個轉向時執行的動作。因爲transition不像Node那樣本身有execute方法,必須通過動作來執行操作。
element
[0..*]
多個
the actions to be executed upon taking this transition. Note that the actions of a transition do not need to be put in an event (because there is only one)
element
[0..*]
a list of exception handlers that applies to all exceptions thrown by delegation classes thrown in this process node.
16.4.16 . action 動作
Table 16.15. 
Name
Type
Multiplicity
Description
Name 名字
有名字的動作,可以被在業務程序定義中尋找。
attribute
Optional
可選
the name of the action. When actions are given names, they can be looked up from the process definition. This can be useful for runtime actions and declaring actions only once.
Class 全類名
(action需要3者之一:全類名class,引用名ref-name,表達式)
attibute
either, a ref-name or an expression
the fully qualified class name of the class that implements the org.jbpm.graph.def.ActionHandler interface.
ref-name 引用名
引用的動作的名字(讓被引用的action處理)
attibute
either this or class
the name of the referenced action. The content of this action is not processed further if a referenced action is specified.
Expression 表達式
類EL表達式指定方法
attibute
either this, a class or a ref-name
A jPDL expression that resolves to a method. See also Section 16.3, “Expressions”
accept-propagated-events 接受傳播事件
默認true。如果爲false,那麼action將僅僅在事件激發這個Action時執行。(事件會從低層次向高層次傳遞,直到process-definition。)同一個事件不會再被上層的action處理。即,事件在這個Action被銷燬!
attribute
optional
{yes|no|true|false}. Default is yes|true. If set to false, the action will only be executed on events that were fired on this action's element. for more information, see Section 9.5.4, “Event propagation”
config-type 配置類型
指定ActionHandler的實現類的對象應該怎樣生成。其中的內容元素應該怎樣用到action對象中。
attribute
optional
{ field | bean | constructor | configuration-property }. Specifies how the action-object should be constructed and how the content of this element should be used as configuration information for that action-object.
Async 異步
默認false。即,動作將在執行線程中同步執行。如果設爲true,將發送執行這個action的消息到命令執行器,命令執行器將在一個獨立的事務中同時/異步執行這個action。(處於業務程序實例主執行線程之外的線程中)
attibute
{true|false}
Default is false, which means that the action is executed in the thread of the execution. If set to true, a message will be sent to the command executor and that component will execute the action asynchonously in a separate transaction.
 動作的內容應該作爲你的ActionHandler實現類的配置信息。傳遞數據給ActionHandler實現類的對象。這允許你通過配置重用對象和組裝對象。
{content}
Optional
可選
the content of the action can be used as configuration information for your custom action implementations. This allows the creation of reusable delegation classes. For more about delegation configuration, see Section 16.2.3, “Configuration of delegations” .
16.4.17 . script 腳本(BeanShell)
Table 16.16. 
Name
Type
Multiplicity
Description
Name 腳本類型的動作的名字
有名字的腳本,可被查找。
(action的ref-name)
attribute
optional
the name of the script-action. When actions are given names, they can be looked up from the process definition. This can be useful for runtime actions and declaring actions only once.
accept-propagated-events
接受傳播事件
attribute
optional [0..*]
{yes|no|true|false}. Default is yes|true. If set to false, the action will only be executed on events that were fired on this action's element. for more information, see Section 9.5.4, “Event propagation”
expression 表達式
beanshell 腳本。
如果沒有指定variable腳本變量,那麼你可以在表達式中使用當前Token(根Token,有fork-join,就有多條子token)的所有變量。也能夠直接作爲script的文本內容寫表達式。不需要作爲expression元素指定表達式
element
[0..1]
0 或1個
the beanshell script. If you don't specify variable elements, you can write the expression as the content of the script element (omitting the expression element tag).
variable 腳本變量
如果不指定腳本變量,那麼就會把當前Token上的所有變量都引進來,可以被表達式使用!如果指定了變量,那麼在表達式中只能使用當前指定的這幾個變量。
element
[0..*]
多個
in variable for the script. If no in variables are specified, all the variables of the current token will be loaded into the script evaluation. Use the in variables if you want to limit the number of variables loaded into the script evaluation.
16.4.18 . expression 表達式(beanshell腳本)
Table 16.17. 
Name
Type
Multiplicity
Description
 
{content}
 
a bean shell script.
16.4.19 . variable 變量
當前token的變量
< task name = "WriteNews" >
         < controller >
            < variable name = "infoId" access = "read,write,required" ></ variable >
            < variable name = "infoTitle" access = "read,write,required" ></ variable >
            < variable name = "infoContent" ></ variable >
            < variable name = "infoWriterId" ></ variable >
            < variable name = "infoWritedTime" ></ variable >
         </ controller >
         < assignment class = "com.withub.cms.jbpm.assignmenthandler.WriteNewsAssignmentHandler" ></ assignment >
      </ task >
Table 16.18. 
Name
Type
Multiplicity
Description
Name 名字
業務程序變量(實際在各個token上,用當前token的)的名字
attribute
required
the process variable name
Access 訪問權
默認是:read,write。使用,分割。
read,write,required
attribute
optional
default is read,write. It is a comma separated list of access specifiers. The only access specifiers used so far are read, write and required.
mapped-name 映射名
默認使用變量名。這指定變量名的一個別名。別名的意思,依賴於 variable 元素 用在哪裏。如果在script內,這是beanshell腳本變量的名字。任務的控制器內,這是任務參數的標籤。如果在process-state內,這是子業務程序實例內的變量名。
attribute
optional
this defaults to the variable name. it specifies a name to which the variable name is mapped. the meaning of the mapped-name is dependent on the context in which this element is used. for a script, this will be the script-variable-name. for a task controller, this will be the label of the task form parameter and for a process-state, this will be the variable name used in the sub-process.
16.4.20 . handler 處理器
用於decision,
1,DecisionHandler
2,和DecisionHandler的作用一樣。用EL表達式算出應該執行哪一個轉向。
Table 16.19. 
Name
Type
Multiplicity
Description
Expression
jPDL 的EL表達式
返回的結果使用toString轉換爲一個String。應該是一個transition的名字。
attibute
either this or a class
A jPDL expression. The returned result is transformed to a string with the toString() method. The resulting string should match one of the leaving transitions. See also Section 16.3, “Expressions” .
Class 類名
如果使用DecisionHandler而不是EL表達式。
attibute
either this or ref-name
the fully qualified class name of the class that implements the org.jbpm.graph.node.DecisionHandler interface.
config-type 配置類型
(和ActionHandler中一樣)
attribute
optional
{ field | bean | constructor | configuration-property }. Specifies how the action-object should be constructed and how the content of this element should be used as configuration information for that action-object.
 
{content}
optional
the content of the handler can be used as configuration information for your custom handler implementations. This allows the creation of reusable delegation classes. For more about delegation configuration, see Section 16.2.3, “Configuration of delegations” .
16.4.21 . timer 定時器
< task swimlane = "salesman" >
      < timer duedate = "20 seconds" repeat = "10 seconds" >
        < action class = "org.jbpm.websale.RemindActor" >
          < swimlaneName > salesman </ swimlaneName >
        </ action >
      </ timer >
      < controller >
        < variable name = "item" access = "read" />
        < variable name = "quantity" access = "read" />
        < variable name = "address" access = "read" />
        < variable name = "comment" />
      </ controller >     </ task >
Table 16.20. 
Name
Type
Multiplicity
Description
Name 定時器的名字
如果不定義,就用所屬節點的名字。
注意:每個定時器應該有唯一的名字。
attribute
optional
the name of the timer. If no name is specified, the name of the enclosing node is taken. Note that every timer should have a unique name.
Duedate 期間(定時器啓動到首次執行的時間)
指定創建定時器和執行定時器之間的時間間隔。
 
attribute
required
the duration (optionally expressed in business hours) that specifies the time period between the creation of the timer and the execution of the timer. See Section 14.1, “Duration” for the syntax.
Repeat 重複(重複執行的間隔)
定時器執行之後,指定離開節點之前,定時器重複執行多少時間。
如果指定”yes””true”,則重複的間隔和啓動定時期到執行的間隔duedate一樣。
attribute
optional
{duration | 'yes' | 'true'}after a timer has been executed on the duedate, 'repeat' optionally specifies duration between repeating timer executions until the node is left. If yes or true is specified, the same duration as for the due date is taken for the repeat. See Section 14.1, “Duration” for the syntax.
Transition 轉向
激發定時器事件或者執行action之後,執行指定名字的轉向。
attribute
optional
a transition-name to be taken when the timer executes, after firing the timer event and executing the action (if any).
cancel-event 取消(定時器)(任務)事件
僅用於任務中的定時器。它指定哪個事件發生時,定時器應該被取消。默認是task-end事件。即,定時器所屬的任務結束時,任務內的定時器會取消。
但你也能指定爲task-assign,task-start。能夠使用,給定多個取消定時器事件。
attribute
optional
this attribute is only to be used in timers of tasks. it specifies the event on which the timer should be cancelled. by default, this is the task-end event, but it can be set to e.g. task-assign or task-start. The cancel-event types can be combined by specifying them in a comma separated list in the attribute.
只有一個定時器激發的動作
element
[0..1]
0 或1個
an action that should be executed when this timer fires
16.4.22 . create-timer 創建定時器
Table 16.21. 
Name
Type
Multiplicity
Description
Name 定時器的名字
attribute
optional
the name of the timer. The name can be used for cancelling the timer with a cancel-timer action.
Duedate 延期時間
創建定時器和執行定時器的時間間隔
attribute
required
the duration (optionally expressed in business hours) that specifies the the time period between the creation of the timer and the execution of the timer. See Section 14.1, “Duration” for the syntax.
Repeat 重複執行週期
如:yew/true,和延期時間相同。直到定時器取消(默認是離開該節點)
attribute
optional
{duration | 'yes' | 'true'}after a timer has been executed on the duedate, 'repeat' optionally specifies duration between repeating timer executions until the node is left. If yes of true is specified, the same duration as for the due date is taken for the repeat. See Section 14.1, “Duration” for the syntax.
Transition 轉向
定時器事件激發或者執行了定時器的動作之後,執行的轉向
attribute
optional
a transition-name to be taken when the timer executes, after firing the the timer event and executing the action (if any).
16.4.23 . cancel-timer 取消定時器
Table 16.22. 
Name
Type
Multiplicity
Description
Name 被取消的定時器的名字
attribute
optional
the name of the timer to be cancelled.
16.4.24 . task 任務
Table 16.23. 
Name
Type
Multiplicity
Description
Name 任務名字
attribute
optional
the name of the task. Named tasks can be referenced and looked up via the TaskMgmtDefinition
Blocking 鐵板一塊?
默認false。如果爲true,那麼任務完成之後,才能離開節點。False,允許用戶通過signal繼續執行和離開節點。
attribute
optional
{yes|no|true|false}, default is false. If blocking is set to true, the node cannot be left when the task is not finished. If set to false (default) a signal on the token is allowed to continue execution and leave the node. The default is set to false, because blocking is normally forced by the user interface.
Signalling 有信號功能
默認true,task能夠通過end(transition)離開任務節點。
attribute
optional
{yes|no|true|false}, default is true. If signalling is set to false, this task will never have the capability of trigering the continuation of the token.
Duedate 延遲時間(任務執行的的延遲時間)
attribute
optional
is a duration expressed in absolute or business hours as explained in Chapter 14, Business calendar
Swimlane 泳道
指向一個泳道的名字。如果一個泳道指定在任務上,那麼任務分派assignment將會被忽略!
(泳道也有 assignment 任務分派
attribute
optional
reference to a swimlane . If a swimlane is specified on a task, the assignment is ignored.
Priority 優先權
attribute
optional
one of {highest, high, normal, low, lowest}. alternatively, any integer number can be specified for the priority. FYI: (highest=1, lowest=5)
assignment 任務分派
使用EL表達式或AssignmentHandler來分配任務。優先級低於swimlane
element
optional
describes a delegation that will assign the task to an actor when the task is created.
event 事件
task-assign 任務分派事件,我們已經在TaskInstance中增加了previousActorId屬性。表示原來的參與者
element
[0..*]
supported event types: {task-create|task-start|task-assign|task-end}. Especially for the task-assign we have added a non-persisted property previousActorId to the TaskInstance
element
[0..*]
a list of exception handlers that applies to all exceptions thrown by delegation classes thrown in this process node.
element
[0..*]
specifies a timer that monitors the duration of an execution in this task. special for task timers, the cancel-event can be specified. by default the cancel-event is task-end, but it can be customized to e.g. task-assign or task-start.
controller 控制器
指定業務程序變量怎樣傳進任務變量。任務變量從GUI中由用戶指定值。
element
[0..1]
specifies how the process variables are transformed into task form parameters. the task form paramaters are used by the user interface to render a task form to the user.
16.4.25 . swimlane 泳道
Swimlane泳道,僅僅是assignment 任務分派的一個代表。
一般放在頂層,供任務去引用!
< process-definition name = "websale"
                    xmlns = "urn:jbpm.org:jpdl-3.1" >
 
  <!-- SWIMLANES (= process roles) -->
// 如果沒有指定 assignment ,應該是任意人都可以!
  < swimlane name = "buyer" />
 
  < swimlane name = "salesman" >
    < assignment expression = "user(ernie)" />
  </ swimlane >
 
  < swimlane name = "accountant" >
    < assignment expression = "user(bert)" />
  </ swimlane >
 
  < swimlane name = "shipper" >
    < assignment expression = "user(grover)" />
  </ swimlane >
Table 16.24. 
Name
Type
Multiplicity
Description
Name 名字
attribute
required
the name of the swimlane. Swimlanes can be referenced and looked up via the TaskMgmtDefinition
assignment 任務分配
指定這個泳道的任務分配器。它會在泳道的任務實例第一次被創建時執行。
element
[1..1]
必須且只有一個(但也有不指定的例子。應該是指所有人都可以)
specifies a the assignment of this swimlane. the assignment will be performed when the first task instance is created in this swimlane.
16.4.26 . assignment (任務)分派
jBPM身份組件表達式(jBPM identity component expressions)
Table 16.25. 
Name
Type
Multiplicity
Description
Expression
表達式
由於歷史原因,它不是一個jPDL版EL表達式。相反,它是jBPM的身份組建的一個分配表達式。注意:這個實現依賴於jbpm身份組件。如果你不使用jBPM的身份組件,那麼就不能使用它!
attribute
optional
For historical reasons, this attribute expression does not refer to the jPDL expression , but instead, it is an assignment expression for the jBPM identity component. For more information on how to write jBPM identity component expressions, see Section 11.11.2, “Assignment expressions” . Note that this implementation has a dependency on the jbpm identity component.
actor-id
參與者id
這是一個beanshell表達式。屬性或方法返回一個String
 
attribute
optional
An actorId. Can be used in conjunction with pooled-actors. The actor-id is resolved as an expression . So you can refer to a fixed actorId like this actor-id="bobthebuilder". Or you can refer to a property or method that returns a String like this: actor-id="myVar.actorId", which will invoke the getActorId method on the task instance variable "myVar".
pooled-actors
參與者池。也是beanshell表達式。屬性或方法返回一個String[],集合,或者,分割的參與者池的列表
attribute
optional
A comma separated list of actorIds. Can be used in conjunction with actor-id. A fixed set of pooled actors can be specified like this: pooled-actors="chicagobulls, pointersisters". The pooled-actors will be resolved as an expression . So you can also refer to a property or method that has to return, a String[], a Collection or a comma separated list of pooled actors.
Class 全類名
attribute
optional
the fully qualified classname of an implementation of org.jbpm.taskmgmt.def.AssignmentHandler
config-type 配置類型
attribute
optional
{ field | bean | constructor | configuration-property }. Specifies how the assignment-handler-object should be constructed and how the content of this element should be used as configuration information for that assignment-handler-object.
 
{content}
optional
the content of the assignment-element can be used as configuration information for your AssignmentHandler implementations. This allows the creation of reusable delegation classes. for more about delegation configuration, see Section 16.2.3, “Configuration of delegations” .
16.4.27 . controller 控制器
public interface TaskControllerHandler extends Serializable {
// 初始化任務實例變量
提取業務程序變量的所有信息,初始化任務實例變量
  void initializeTaskVariables(TaskInstance taskInstance, ContextInstance contextInstance, Token token);
 // 提交任務實例變量
當任務完成時,被調用!
  void submitTaskVariables(TaskInstance taskInstance, ContextInstance contextInstance, Token token);
 
}
< controller >
            < variable name = "infoId" access = "read" ></ variable >
            < variable name = "infoTitle" access = "read" ></ variable >
            < variable name = "infoContent" access = "read" ></ variable >
            < variable name = "infoWriterId" access = "read" ></ variable >
            < variable name = "infoWritedTime" access = "read" ></ variable >
            < variable name = "checkInfo" ></ variable >
            < variable name = "passed" access = "read,write,required" ></ variable >
            < variable name = "infoCheckerId" access = "read,write,required" ></ variable >
         </ controller >
Table 16.26. 
Name
Type
Multiplicity
Description
Class 全類名
attribute
Optional
可選
the fully qualified classname of an implementation of org.jbpm.taskmgmt.def.TaskControllerHandler
config-type 配置類型
attribute
optional
{ field | bean | constructor | configuration-property }. Specifies how the assignment-handler-object should be constructed and how the content of this element should be used as configuration information for that assignment-handler-object.
 
{content}
 
either the content of the controller is the configuration of the specified task controller handler (if the class attribute is specified. if no task controller handler is specified, the content must be a list of variable elements.
variable 任務變量
如果沒有指定class屬性,controller元素的內容必須是一些任務變量。Task中將可以使用它們。
element
[0..*]
in case no task controller handler is specified by the class attribute, the content of the controller element must be a list of variables.
16.4.28 . sub-process 子業務程序
Process-state中指定指向的子業務程序定義
Table 16.27. 
Name
Type
Multiplicity
Description
Name 子業務程序定義的名字
attribute
required
the name of the sub process. To know how you can test subprocesses, see Section 18.3, “Testing sub processes”
Version 版本
默認爲最新版
attribute
optional
the version of the sub process. If no version is specified, the latest version of the given process will be taken.
16.4.29 . condition 條件
Decision節點的transition的條件,爲true,就執行該transition。
Table 16.28. 
Name
Type
Multiplicity
Description
 
{content} or attribute expression
內容,或者屬性EL表達式。
條件元素的內容是jPDL的EL表達式,返回true/false。
Decision 將執行第一個表達式值爲true的轉向(次序依照processdefinition.xml中出現的先後順序)。如果沒有條件是真的轉向,那麼就會執行默認轉向(第一個)
required
The contents of the condition element is a jPDL expression that should evaluate to a boolean. A decision takes the first transition (as ordered in the processdefinition.xml) for which the expression resolves to true. If none of the conditions resolve to true, the default leaving transition (== the first one) will be taken.
16.4.30 . exception-handler 異常處理器
Table 16.29. 
Name
Type
Multiplicity
Description
exception-class
異常類
指定要處理的可拋出(異常)類的全類名。如果不指定,那麼就可以處理所有節點中ActionHandler等拋出的異常。
attribute
Optional
可選
specifies the fully qualified name of the java throwable class that should match this exception handler. If this attribute is not specified, it matches all exceptions (java.lang.Throwable).
action 動作
當異常處理器處理異常時,執行的動作。
element
[1..*]
1 或多
a list of actions to be executed when an exception is being handled by this exception handler.
 
發佈了62 篇原創文章 · 獲贊 2 · 訪問量 5992
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章