JBoss.orgCommunity Documentation

jBPM Tools Reference Guide

Olga Chikvina

Svetlana Mukhina

Version: 4.3.0.trunk


1. Introduction
1.1. Preface
1.2. Feature list
1.3. Other relevant resources on the topic
2. Tasks
2.1. JBoss jBPM Runtime Installation
2.2. A Guided Tour of JBoss jBPM GPD
2.2.1. Creating a jBPM Project
2.2.2. Creating an Empty Process Definition
2.3. Actions : The JBoss jBPM Integration Mechanism
2.3.1. Creating a Hello World Action
2.3.2. Integrating the Hello World Action
2.3.3. Integration Points
2.4. Quick Howto Guide
2.4.1. Change the Default Core jBPM Installation
2.4.2. Configuring Task Nodes
3. Reference
3.1. Wizards
3.1.1. Process Project Wizard
3.1.2. New JBPM Action Wizard
3.2. The views
3.2.1. The Outline View
3.2.2. The Overview
3.2.3. The Properties View
3.2.4. The jBPM Graphical Process Designer editor.

This guide demonstrates the use of JBoss jBPM in the creation of a process definition.

JBoss jBPM is a workflow that enables the creation and automation business processes. The table below lists the main features of JBoss jBPM.


This chapter describes how to execute JBoss jBPM (business process management).

The jBPM plugin (jBPM Designer) is already included in JBoss Tools. To run it the jBPM runtime needs to be downloaded (jbpm-jpdl-3.2.3 currently), and the directory where you extracted the runtime to needs to be specified, either when you create a jBPM project or through the jBPM preference pages.

Note:

Try to avoid using spaces in the names of installation folders. It can cause problems with Sun based VMs.

Select WindowPreferencesJBoss jBPMRuntime Locations. Here you can add, edit and remove JBoss jBPM installation locations. Click the Add button. In the subsequent dialog box enter a name for a newly added jBPM runtime and point to the correct location of this package on your file system. Click the OK button twice to save the changes.


Now that a runtime has been installed, some of the powerful features of the jBPM can be demonstrated.

This chapter will present a step-by-step walk-through demonstrating how to create and configure a simple process. First, let's try to organize a new jBPM project.

A wizard for creating a jBPM project is included in the GPD plugin. We have opted to create a project based on a template already containing a number of advanced artifacts that we will ignore for this section. In the future we will elaborate this wizard and offer the possibility to create an empty jBPM project as well as projects based on templates taken from the jBPM tutorial.

Now when the project is set up, we can use a Creation wizard to create an empty process definition. Bring up the New wizard by selecting FileNewOther.... The wizard opens on the Select Wizard page.


Selecting the JBoss jBPM category, then the jBPM Process Definition item and clicking on the Next button brings us to the Create Process Definition page.


We choose hello as the name of the process archive file. Click on the Finish button to end the wizard and open the process definition editor.


You can see in the Package Explorer that creating a process definition involves creating an XML file called [process name].jpdl.xml, which contains the process definition information. A JPG file called [process name].jpg will also be automatically generated when changes are saved to the process.

This chapter will demonstrate how to integrate with JBoss jBPM. The standard mechanism to implement this is to wrap the functionality you want to integrate in a class that implements the ActionHandler interface. In order to demonstrate it let's specify a simple Hello World action for our process.

Each Hello World process should integrate one or more Hello World actions, so this is what we will be doing. We can integrate custom code at different points in the process definition. To do this we have to specify an action handler, represented by an implementation of the ActionHandler interface, and attach this piece of code to a particular event. These events are amongst others, going over a transition, leaving or entering nodes, after and before signaling.

To make things a little bit more concrete, let's create a new class called HelloActionHandler. For that firstly we will create a new package com.jbay.action in the src/main/java folder of our project. Then, we should call New Class Creation wizard as usual selecting NewClass from the context menu.


Notice that two first gaps have been filled automatically. Here, instead of the Package option, the Enclose type option can be selected to define the type in which the new class should be created will be enclosed.

In our case, we leave everything as it is, just type HelloActionHandler as a name of new class and add org.jbpm.graph.ActionHendler interface as it is shown in the picture above.

Thus, our HelloActionHandler implements the ActionHandler interface, including the execute method as shown in the next figure. Here, we add a variable named greeting to the collection of process variables and put a message in it: "Hello from ActionHandler".


Now, as we have HelloActionHandler class defined, let's explore how we can handle it.

The main purpose of this chapter is to provide you with the steps required to associate our Hello World action with a particular event and test the validity of our actions as well.

In order to validate our code we will first create a Unit Test that proves the behavior we want to achieve by adding the ActionHandler to the process. So we implement another test.

First we need to create a new Junit Test Case by selecting FileNewOtherJUnitJunit Test Case. Give it a name of HelloTest, place it in the com.jbay package, and click the Finish button.


Populate the new class with the following code:

package com.jbay;

import org.jbpm.graph.def.ProcessDefinition;
import org.jbpm.graph.exe.ProcessInstance;

import junit.framework.TestCase;

public class HelloTest extends TestCase
{
	public void testActionhandler() throws Exception {
		
		ProcessDefinition definition = 
			ProcessDefinition.parseXmlResource("hello.jpdl.xml");
		
		ProcessInstance instance = new ProcessInstance(definition);
		assertNull("The greeting variable should not exist",
				instance.getContextInstance().getVariable("greeting"));
		
		instance.signal();
		assertEquals("The greeting variable is created",
				instance.getContextInstance().getVariable("greeting"),
				"Hello from ActionHandler");
	}
}				


We assert that no variable called greeting exist. Then we give the process a signal to move it to the action state. We want to associate the execution of the action with the event of going over the transition from the start state to the action state. So after the signal, the process should be in the action state as in the previous scenario. But moreover, the greeting variable should exist and contain the string "Hello from ActionHandler". That is what we assert in the last lines of the test method.

Running the tests now results in a failure. The point is that we did not associate the action with any particular event in the process definition, so the process variable did not get set.


Let's do something about it and add an action to the first transition of our sample process. To do this you can use the Actions tab in the Properties Editor that is under the graphical canvas. Bring up the popup menu of the action element container and chose New Action as it's shown on the figure below. The other way to add an action to the transition is simply to use the dropdown menu that is available under the action icon in the right upper corner of the Properties View.


After adding the action a tabbed view with three pages will appear.


The first of these three pages allows you to give the Action a name. The last page contains some advanced attributes such as whether the Action is asynchronous. The Details page is the most important. It allows to choose and configure the actual action handler implementation.


Clicking on the Search... button brings us to a Choose Class dialog.


We choose our previously created HelloActionHandler class and click the OK button. After selecting the action handler for the action, we can run the test and observe it gives us a green light.


There we are. The above objective has been achieved.

The different integration points in a process definition are thoroughly documented in the JBoss jBPM User Guide. Instance nodes can contain many action elements. Each of these will appear in the Action element list of the Actions tab. But each Action also has a properties view of itself. You can navigate to this view by selecting the added Action in the outline view.

This chapter contains additional information related to the JBoss jBPM.

Here, we'll examine how you can configure the Task nodes in jBPM jPDL GPD.

You can add Tasks to Task nodes and then configure them in a similar manner Actions are configured. Let's consider the process definition similar to the previous one that contains three nodes: Start state, Task node and End state. The Properties view for the selected Task node includes several tabs.


We should choose the Task tab and then bring up the context menu or click the button in the top right corner of the view to add a Task to our Task node.


Every added Task has its own configuration possibilities. You can access them through the Properties view as well.


The General page is a place where you can specify the name of a Task and its description. For instance, let it be approve oder with appropriate description that you can see in the figure below.


Now, look at Details page. First, you should specify the due date that is a mandatory property for the Task. The due date is the date on which the task should be accomplished. Here you can also set a Task priority as well as signaling, notifying or blocking. The Blocking attribute indicates that the process will not be able to continue if this task is still unaccomplished. The Generate Form... button is for creating a simple task form that can be rendered by the jBPM console.


For our example, we specify the due date as 2 business days, choose the high priority and also check the Signaling and Notify attributes. It means that the Task should be accomplished in 2 business days and the assignee will be notified by email when the task is assigned. To specify how the Task should be assigned switch on to the Assignment page.


On the Reminder page you can specify whether the assignee will be reminded of the task that awaits him.


In our case, the assignee will be reminded by email after two business hours and continue to get reminding every business hour after that.

In the next figure you can see our configuring generated into XML.


We hope, our guide will help you to get started with the jPDL process language and jBPM workflow on the whole. Besides, for additional information you are welcome on JBoss forum.

Here, it will be explained how to work with views and editors provided by JBDS.

The views are used to represent and navigate through the resources you are currently working on. One of the advantages of all the views is that they immediately reflect all modifications made in the current active file. Let's explore the views that the jPDL perspective provides in more detail.


As you can see in the picture above, the jPDL perspective contains a complete set of functionality that's necessary for working on the jBPM project.

The jBPM GPD editor includes four modes: Diagram, Deployment, Design and Source, which are available as switchable tabs at the bottom of the editor.