The convedo Tech Talk Blog

Using Java methods in a business process model

Written by Sascha Cutura | 21 July 2015

While you are implementing a process, you will use the message map to work with the data of the process. 

All message map data is stored in XML. While in the message map assignments you can apply XPath and XPath expressions to manipulate the data of the XML elements.

These expressions follow the standard syntax as defined for XPath expressions. With these expressions you can use mathematical, string, date and time functions. You can find these described in the online documentation of the OpenText Process Suite platform (hereafter OTPS) in the topic: Rule Engine Function Library.

In the OTPS with these XPATH expressions you are able to include any kind of Java method call if for example, you need a calculation, conversion, or other kind of programmed functionality that is not available through the regular XPath functions.

Using a Java Method in XPath expressions

You are developing on an OTPS platform development server. Refer to the installation guide on the requirements of the Process Suite platform for the appropriate version of the JDK (Java Development Kit) that must be installed on the server.

You need to have the source class file(s) available for the methods that you want to include in your XPath expressions. First, you need to create the relevant development and deployment folder structure to accommodate the different files for the uploaded java class source file(s) and the compiled java archive file:

  1.      Java source folder: in the project, create a folder called JavaSources.
  2.      Java archive folder: in the project, create a folder OTPSInstallDir.
  3.      Set the start point of qualified name on the install directory folder.
  4.      Create a deployment path in this folder similar to: domain name\company name\application name

                 - For example:  com\convedo\usejava

These are the preparatory steps.

Note that by a default installation the OTPSInstallDir will point to: C, D or other drive:\Programs\OpenText\Cordys\defaultInst or /opt/OpenText/Cordys/defaultInst (Linux).

Upload and deploy your Java method

Upload any source file(s) that you have in the Java sources folder you created before. If you wish, you can upload multiple class files. In the deployment folder of the OTPS installation directory (usejava), create a Java Archive document pointing to the Java sources folder:

When you publish the jar file this will automatically compile the Java source files into the java archive and publish the file at the file system of the OTPS server. Next, you need to determine the runtime class path of the jar file as this must be associated with the Business Process Management (BPM) service container to be able to execute the given java method. The class path consists of the installation directory of OTPS and the deployement path of the jar file, this will be similar to: C:\Programs\OpenText\Cordys\defaultInst\com\convedo\usejava\temputils.jar or /opt/OpenText/Cordys/defaultInst/com/convedo/userjava/temputils.jar (Linux).

Open the properties of the BPM service container and at the tab page JRE Configuration, enter the class path in the Classpath field. Save and restart the service container. 

Now you can write an XPath expression in the message map of your process to call a java method in XPATH, to refer to the method, you refer to the package name and with the package the name of the method, in our example this reference is: com.convedo.usejava.examples.TempUtils.Celsius2Fahrenheit(input a float value).

Download a copy of the "UseJava" workspace to find the example mentioned above:

 

 

 

 

 

Don't miss out on future blog posts! Subscribe to email updates today!