Integrating Plain Java Classes and Session Beans

Both Plain Java applications and Session Bean applications are designed to execute Java code:

In both cases this method to be executed is called completion method.

As already explained for Workflow Data, all IN data mappings are executed before the completion method and all OUT data mappings are executed after the completion method. For data mappings it is possible to use all getter and setter methods in the sense of section Java Style Data Types on the underlying object. This object will be the same for the whole life time of activity instance execution. Especially, it is guaranteed that for a stateful Session Bean application all data mappings and the completion method will operate on the same Session Bean instance.

Plain Java Applications

Plain Java applications allow to instantiate any Java class with at least one public constructor and execute a method on it. To achieve this, at modeling time you have to specify

These settings are accessed in Plain Java application types in the Process Workbench.

Creating a Plain Java Application

To specify a plain Java application in the Process Workbench:

  1. In the diagram toolbar palette select Applications > Plain Java Application
  2. Open the application properties dialog with a double-click.
  3. In the details panel, choose the correct values for the implementation class, the constructor and the completion method. Note that for accomplishing this step it is necessary to have the implementation class in the class path of the Process Workbench.

Please refer to chapter Specifying Applications for general questions on working with applications in the Process Workbench.

Specifying a Plain Java Application
Figure: Specifying a Plain Java Application

Detailed information on integrating Java applications can be found in the System Integration part.

Parameters as Access Points

The constructor parameters will be exposed as IN access points named x InitParam n where x is the first letter of the parameter's class name and n is a consecutive number, starting with 1.

The completion method parameters will be exposed as IN access points named x Param n where x is the first letter of the class name and n is a consecutive number, starting with 1. The return value of the completion method, if any, will be exposed as an OUT access point returnValue.

Let's consider a Java class ProcessInvoice used in a plain Java application with the following constructor and completion method chosen:

public class ProcessInvoice
{
    public ProcessInvoice(Invoice invoice, java.util.Date receivingDate)...
    public Invoice addItem(InvoiceItem item)...

This will result in the following access points for constructor parameters and completion method parameters:

When connecting a data to an application activity, the data mapping is created automatically. Please refer to the section Automatic Completion of Data Mappings of the chapter Specifying Data Mappings for detailed information on the preset of parameters for automatic completed data mappings.

Configuring Retry Mechanism

The configurable retry mechanism provides the facility to retry the operation in case the target service is temporarily unavailable.

For more information, please refer to Retry Mechanism of Non-interactive Applications section of the Applications chapter.

For example, you have added a synchronous application to the model. In the Property page of the application, you can enable the retry, specify number of retries and time between retries. However, note that maximum 10 retries and 60 seconds between two retries are allowed. So, the application will retry for the defined number of times with a pause of the defined number of seconds, until it has success. If the application still fails after the defined number, it will no longer retry.


Session Bean Applications

Session Bean applications allow to instantiate a stateful or stateless Session Bean and execute a method on it. To achieve this, at modeling time you have to specify

The create method parameters will be exposed as IN access points named x InitParam n where x is the first letter of the class name and n is a consecutive number, starting with 1.

The completion method parameters will be exposed as IN access points named x Param n where x is the first letter of the class name and n is a consecutive number, starting with 1. The return value of the completion method, if any, will be exposed as an OUT access point returnValue. Let's consider a Session Bean ProcessInvoice used in a Session Bean application with the following create method and completion method chosen:

public interface ProcessInvoiceHome extends EJBHome
{
  ProcessInvoice create (Invoice invoice, java.util.Date receivingDate);
...
public interface ProcessInvoice extends EJBObject
{
  Invoice addItem(InvoiceItem item);

This will result in the following access points for create method parameters and completion method parameters:

These settings are accessed in Session Bean application types in the Process Workbench.

Creating a Session Bean Application

To specify a Session Bean application in the Process Workbench:

  1. In the diagram toolbar palette select Applications > Session Bean Application
  2. Open the application properties dialog with a double-click.
  3. Select the EJB mode (EJB 2.x or EJB 3.x).
  4. Enter the properties according to the EJB mode as explained in the following sections.

Please refer to the section System Integration for detailed information on integrating session beans.

EJB 2.x

Choose the property values for:

Note that for accomplishing this step it is necessary to have the home interface and remote interface classes in the class path of the Process Workbench.

Local Binding

To test a local class as a mock Session Bean, check the Local Binding check box. There has to be an implementation of the home interface.

Specifying Session Beans
Figure: Specifying EJB 2.x Session Beans

EJB 3.x

The property page for EJB 3.x contains the Eclipse class browser entry Bean Class to enter the bean class.

Fill in the values for the following entries:

Specifying EJB 3.x Session Beans
Figure: Specifying EJB 3.x Session Beans

Session Bean Class

Arbitrary classes can be selected. If the selected class does not satisfy the EJB 3.0 beans requirements, an error status is displayed.

Business Interface

A combo box for the Business Interface is provided with:

Once an appropriate bean class has been selected, the combo box is populated accordingly, applying the rules regarding business interfaces of EJB 3.0 session beans:

Instead of entering the business interface via browsing of bean classes, it can be entered directly or via browsing.

JNDI Path

The JNDI path can be entered if it cannot be derived from the bean class properties.

Completion and Initialization Method

A combo box for the selection of the Completion Method is provided as well as a combo box for the Initialization Method. Both methods will be invoked at runtime.

Configuring Retry Mechanism

The configurable retry mechanism provides the facility to retry the operation in case the target service is temporarily unavailable.

For more information, please refer to Retry Mechanism of Non-interactive Applications section of the Applications chapter.

For example, you have added an application to the model. In the Property page of the application, you can enable the retry, specify number of retries and time between retries. However, note that maximum 10 retries and 60 seconds between two retries are allowed. So, the application will retry for the defined number of times with a pause of the defined number of seconds, until it has success. If the application still fails after the defined number, it will no longer retry.