JBoss.orgCommunity Documentation

Chapter 17.  jBPM Process Definition Language

17.1. Process Archive
17.1.1. Deploying a Process Archive
17.1.2. Process Versioning
17.1.3. Changing Deployed Process Definitions
17.1.4. Migrating Process Instances
17.2. Delegation
17.2.1. jBPM Class Loader
17.2.2. Process Class Loader
17.2.3. Configuring Delegations
17.3. Expressions
17.4. jPDL XML Schema
17.4.1. Validation
17.4.2. process-definition
17.4.3. node
17.4.4. common node elements
17.4.5. start-state
17.4.6. end-state
17.4.7. state
17.4.8. task-node
17.4.9. process-state
17.4.10. super-state
17.4.11. fork
17.4.12. join
17.4.13. decision
17.4.14. mail
17.4.15. event
17.4.16. transition
17.4.17. action
17.4.18. script
17.4.19. expression
17.4.20. variable
17.4.21. handler
17.4.22. timer
17.4.23. create-timer
17.4.24. cancel-timer
17.4.25. task
17.4.26. mail
17.4.27. swimlane
17.4.28. assignment
17.4.29. controller
17.4.30. sub-process
17.4.31. condition
17.4.32. exception-handler

The jBPM Process Definition Language (jPDL) is the notation to define business processes recognized by the jBPM framework and expressed as an XML schema. Process definitions often require support files in addition to the jPDL document. All these files are packaged into a process archive for deployment.

The process archive is just a ZIP archive with a specific content layout. The central file in the process archive is called processdefinition.xml This file defines the business process in the jPDL notation and provides information about automated actions and human tasks. The process archive also contains other files related to the process, such as action handler classes and user interface task forms.

One can deploy a process archive in any of three different ways:

  • via the Process Designer Tool

  • with an ant task

  • programatically

To deploy a process archive with the Process Designer Tool, right-click on the process archive folder and select the Deploy process archive option.

The jBPM application server integration modules include the gpd-deployer web application, which has a servlet to upload process archives, called GPD Deployer Servlet. This servlet is capable of receiving process archives and deploying them to the configured database.

To deploy a process archive with an ant task, define and call the task as follows.


<target name="deploy-process">
  <taskdef name="deployproc" classname="org.jbpm.ant.DeployProcessTask">
    <classpath location="jbpm-jpdl.jar" />
  </taskdef> 
  <deployproc process="build/myprocess.par" />
</target>

To deploy more process archives at once, use nested fileset elements. Here are the DeployProcessTask attributes.


To deploy process archives programmatically, use one of the parseXXX methods of the org.jbpm.graph.def.ProcessDefinition class.

Process instances always execute on the same process definition as that in which they were started. However, the jBPM allows multiple process definitions of the same name to co-exist in the database. Typically, a process instance is 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 definitions.

If the process includes references to Java classes, these can be made available to the jBPM runtime environment in one of two ways:

When a process archive is deployed, a process definition is created in the jBPM database. Version process definitions on the basis of their names. When a named process archive is deployed, the deployer assigns it a version number. It does so by searching for the highest number assigned to a process definition of the same name and then adds one to that value. (Unnamed process definitions will always be versioned as -1.)

Use the delegation mechanism to include custom code in process executions.

Delegation classes contain user code that is called from within a process execution, the most common example being an action. In the case of action, an implementation of the ActionHandler interface can be called on an event in the process. Delegations are specified in the processdefinition.xml file. One can supply any of these three pieces of data when specifying a delegation:

  1. the class name (required): this is the delegation class' fully-qualified name.

  2. configuration type (optional): this specifies the way in which to instantiate and configure the delegation object. By default, the constructor is used and the configuration information is ignored.

  3. configuration (optional): this is the configuration of the delegation object, which must be in the format required by the configuration type.

Here are descriptions of every type of configuration:

This is the default configuration type. The config-type field first instantiates an object of the delegation class and then set values in those object fields specified in the configuration. The configuration is stored in an XML file. In this file, the element names have to correspond to the class' field names. The element's content text is put in the corresponding field. If both necessary and possible to do, the element's content text is converted to the field type.

These are the supported type conversions:

  • string is trimmed but not converted.

  • primitive types such as int, long, float, double, ...

  • the basic wrapper classes for the primitive types.

  • lists, sets and collections. In these cases, each element of the xml-content is considered an element of the collection and is parsed recursively, applying the conversions. If the element types differ from java.lang.String indicate this by specifying a type attribute with the fully-qualified type name. For example, this code injects an ArrayList of strings into numbers field:

    
    <numbers>
      <element>one</element>
      <element>two</element>
      <element>three</element>
    </numbers>

    One can convert the text in the elements to any object that has a string constructor. To use a type other than a string, specify the element-type in the field (numbers in this case).

    Here is 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>
  • In this case, each of the field elements is expected to have one key and one value sub-element. Parse both of these by using the conversion rules recursively. As with collections, it will be assumed that a conversion to java.lang.String is intended if one does not specify a type attribute.

  • org.dom4j.Element

  • for any other type, the string constructor is used.

Look at this 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 for that class:


...
<action class="org.test.MyAction">
  <city>Atlanta</city>
  <rounds>5</rounds>
</action>
...

There is limited support for a JSP/JSF EL-like expression language. In actions, assignments and decision conditions, one can write this kind of expression: expression="#{myVar.handler[assignments].assign}"

The jPDL and JSF expression languages are similar. jPDL EL is based on JSF EL but, in contrast to the latter, it employs #{...} notation and includes support for method-binding.

Depending on the context, the process and task instance variables can be used as starting variables, as can the the following implicit objects:

  • 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 powerful when used in a JBoss SEAM environment (http://www.jboss.com/products/seam). Because of the integration between the jBPM and SEAM, every backed bean, Enterprise Java Bean and so forth becomes accessible from within one's process definition.

The jPDL schema is the schema used in the process archive's processdefinition.xml file.

Table 17.17. Action Schema

NameTypeMultiplicityDescription
nameattributeoptionalThis is 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.
classattibuteeither, a ref-name or an expressionThis is the fully-qualified class name of the class that implements the org.jbpm.graph.def.ActionHandler interface.
ref-nameattibuteeither this or classThis is the name of the referenced action. The content of this action is not processed further if a referenced action is specified.
expressionattibuteeither this, a class or a ref-nameThis is a jPDL expression that resolves to a method. See also Section 17.3, “ Expressions ”
accept-propagated-eventsattributeoptionalThe options are {yes|no|true|false}. The 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, read Section 9.5.3, “ Passing On Events ”
config-typeattributeoptionalThe options are {field|bean|constructor|configuration-property}. This 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.
asyncattribute{true|false} 'async="true" is only supported in action when it is triggered in an event. The default value 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 asynchronously in a separate transaction.
 {content}optionalThe action's content can be used as the configuration information for custom action implementations. This allows one to create reusable delegation classes. For more about delegation configuration, read Section 17.2.3, “ Configuring Delegations ”.

Table 17.25. Task Schema

NameTypeMultiplicityDescription
nameattributeoptionalthe name of the task. Named tasks can be referenced and looked up via the TaskMgmtDefinition
descriptionattribute or element textoptionalA description of the task.
blockingattributeoptional{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.
signallingattributeoptional{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.
duedateattributeoptionalis a duration expressed in absolute or business hours as explained in Chapter 14, Business Calendar
swimlaneattributeoptionalreference to a swimlane. If a swimlane is specified on a task, the assignment is ignored.
priorityattributeoptionalone of {highest, high, normal, low, lowest}, with a default of normal. Alternatively, any integer number can be specified for the priority. For example: (highest=1, lowest=5)
notifyattributeoptional{yes|no|true|false}, default is false. If notify is set to true, a mail action will be fired when the task is assigned. See Section 15.1.3, “ "Task Assigned" Email ”
assignmentelementoptionaldescribes a delegation that will assign the task to an actor when the task is created.
eventelement[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
exception-handlerelement[0..*]a list of exception handlers that applies to all exceptions thrown by delegation classes thrown in this process node.
timerelement[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.
reminderelement[0..*]specifies a reminder, or "notification timer" that will send a notification e-mail. See Section 15.1.4, “ "Task Reminder" Email ”
controllerelement[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.

Table 17.28. Assignment Schema

NameTypeMultiplicityDescription
expressionattributeoptionalFor 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-idattributeoptionalAn 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-actorsattributeoptionalA 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.
classattributeoptionalthe fully qualified classname of an implementation of org.jbpm.taskmgmt.def.AssignmentHandler
config-typeattributeoptional{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}optionalthe 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 17.2.3, “ Configuring Delegations ”.