Code review

This page shows the features of the Business Process Choreographer (BPC) API, which are being used to work with business processes. To view the source code, click the links in the particular sections. For a more comprehensive discussion of the BPC API refer to the Information center. The Javadoc of the BPC is provided with WebSphere Process Server.

API Enterprise Java Beans

Business Process Choreographer comes with a stateless session EJB that represents its public API. Basically, there are two ways to access the EJB:

  1. If you want to access your business process from a client which runs on the same Java Virtual Machine as your process, you can use the local session bean.
    This bean is called LocalBusinessFlowManager.
  2. If you want to access your business process from a client which doesn't run on the same Java Virtual Machine, you have to use the remote session bean.
    This bean is called BusinessFlowManager.

The sample client applications use the remote session bean.
Click the link to see the source code that accesses the BusinessFlowManager: ApiHelper.java.

To make the API calls visible to the server log file, the auxiliary class MyTrace is used.
Click the link to see the source code that implements this auxiliary class: MyTrace.java.

Starting a long-running process

The sample client applications initiate the order approval process, which is a long-running process. The sample performs the following steps:

Click the link to see the source code that initiates the order approval process: StartOrderApprovalProcess.java.

Running a microflow

This sample shows how you can use the Enterprise Java Beans (EJB) interface to run non-interruptible processes. Running a microflow, you have to differentiate whether the microflow has one or more start activities. If there is one start activity, you can use the call() method and pass the process template name as parameter. If there are multiple start activities, you can determine a start activity using the getStartActivities() method and use it in the call() method. The sample shows both cases.

The sample also contains the code to query the process template of microflows.

Click the link to see the source code that initiates the microflow: RunMicroProcess.java.

Claim and complete a staff activity

This sample shows how you retrieve the order approval process' staff activities that are in state ready, so that you can claim them to work on it. Furthermore, it shows how you can create the output message and how you complete your work on the activity.

The two steps, query() for staff activities in state ready and claim(), can also be combined by calling claim() with a where clause and an order clause as input parameters. This prevents users to claim a staff activity that has been claimed by another user in parallel.

Click the link to see the source code that claims and completes an activity: ClaimAndComplete.java.
Note: an instance of the 'OrderApprovalProcess' should be started before running this sample application.

Click the link to see the source code that claims an activity using a where clause and an order clause: ClaimNext.java.
Note: an instance of the 'OrderApprovalProcess' should be started before running this sample application.

Administrative tasks on a staff activity

There are several administrative tasks that can be performed on staff activities.

The process administrator can cancel the claim of an activity that is claimed by someone else. This situation might occur, for example, when an activity must be completed but the owner of the activity, i.e. the user who has claimed it, is absent.

Click the link to see the source code that cancels the claim of an activity: CancelClaim.java.
Note: an instance of the 'OrderApprovalProcess' should be started before running this sample application.

If an activity template of a staff activity specifies to stop the activity on errors, and if an error is encountered inside a staff activity and the corresponding fault is not caught on the enclosing scope, then the activity is put into the stopped state. In this situation, the process administrator can force the completion of the activity calling forceComplete(). He can also force the repetition of such an activity calling forceRetry().

Click the link to see the source code that forces the completion of a stopped activity: ForceComplete.java.

Click the link to see the source code that forces the repetition of a stopped activity: ForceRetry.java.

Administrative tasks on a process instance

There are several administrative tasks that can be performed on process instances.

This sample does the following:

Click the link to see the source code that executes these steps: AdministerProcesses.java.
Note: an instance of the 'OrderApprovalProcess' should be started before running this sample application.

Managing stored queries

A stored query is a query that is stored in the database and is identified by a name. Although the query definitions are stored in the database, items contained in the stored query, such as the where clause, are assembled dynamically when they are queried. All stored queries are publicly accessible. You can have stored queries for business process objects, task objects, or a combination of these two object types.

This sample does the following:

Click the link to see the source code that performs these steps: HandleStoredQueries.java.
Note: an instance of the 'OrderApprovalProcess' should be started before running this sample application.

Managing work items

A work item represents the assignment of an object to a user or group of users for a particular reason. The object is typically a staff activity instance, a process instance, or a human task. The reasons are derived from the role that the user has for an activity or task.

This sample shows how to create a work item, transfer a work item and delete a work item.

Click the link to see the source code that performs these steps: HandleWorkItems.java.
Note: an instance of the 'OrderApprovalProcess' should be started before running this sample application.

Handling of custom properties

Custom properties allow a user to add additional properties to activities, process instances or tasks.

This sample shows how to set custom properties for a process instance, retrieve them and use them in queries.

Click the link to see the source code that performs these steps: HandleCustomProperties.java.
Note: an instance of the 'OrderApprovalProcess' should be started before running this sample application.