uCosminexus Service Platform, Basic Development Guide
(1) Preparations before defining invoke Java activities
Before defining invoke Java activities, you must make the following preparations:
- Creating an HCSCTE project
- The Java class to be specified in the Invoke Java Activity dialog box is saved in the src directory of the HCSCTE project. Therefore, you must create an HCSCTE project beforehand.
- For details about how to create an HCSCTE project, see 3.1 Managing a Project.
- Creating a Java class
- Create a Java class to be used by invoke Java activities. For details about the interface of the Java class to be used, see 5.6.5(2) Interface of the Java class to be used.
- Note
- Java classes are shared by all HCSC components within a repository. Therefore, if you modify an existing Java class, HCSC components of the pre-modification class might be mixed with HCSC components of the post-modification class. If a Java class is changed, repackage the business process that defines the invoke Java activity for invoking the changed Java class.
Note that even if an invoke Java activity is deleted, the Java classes used by the invoke Java activity are not deleted. Therefore, separately delete any Java classes that are no longer required.
- Resources that are allocated when a Java class is called remain allocated even after processing finishes. For this reason, if a high load is applied to the entire system, OutOfMemoryError might occur due to insufficient Java heap or Perm heap memory. To prevent this problem, you need to implement the processing for releasing resources when OutOfMemoryError occurs, and error processing such as rollback.
- A Java class that implements a dedicated interface (jp.co.Hitachi.soft.csc.bp.receiver.ejb.CustomClassInterface) must not be included in the container extension library. Java classes are automatically added to the EAR file when business processes are packaged.
- Adding a library
- To add a library to an EAR file created by packaging business processes, copy the library to the lib directory of the HCSCTE project beforehand.
- The library copied to the lib directory is automatically added to the EAR file when business processes are packaged.
- Do not register a directory or a library with any of the following names in the lib directory:
- csbdef.jar
- cscbp_ejb.jar
- csbjava.jar
- Note
- Do not delete links to the src directory or lib directory in the HCSCTE project.
(2) Interface of the Java class to be used
The Java class to be invoked by an invoke Java activity must implement the following interface:
package jp.co.Hitachi.soft.csc.bp.receiver.ejb;
public interface CustomClassInterface {
public Object invoke(
String processName,
int version,
String activityName,
Object inputData
) throws CSBUserException,CSBSystemException;
}
|
The content of the Java class is explained below.
- Arguments
Dummy argument name |
Explanation |
processName |
Business process name |
version |
Business process version |
activityName |
Activity name |
inputData |
Variable specified in Variable for argument in the Invoke Java Activity dialog box |
- Return value
- The return value is assigned to the variable specified in Variable for return value in the Invoke Java Activity dialog box.
- Exception
- Processing differs depending on whether the exception to be thrown is CSBUserException or CSBSystemException.
- When CSBUserException is thrown
- If fault handling is specified for the invoke Java activity, the activity defined for fault handling in the fault connection is executed when CSBUserException is thrown.
- If fault handling is not specified for the invoke Java activity, processing continues assuming that invokeJavaFault occurred.
- The interface for CSBUserException is shown below.
package jp.co.Hitachi.soft.csc.bp;
public class CSBUserException extends Exception {
public CSBUserException() { super(); }
public CSBUserException(String message) { super(message); }
}
|
- When CSBSystemException is thrown
- When CSBSystemException is thrown, the processing is halted assuming that a system exception occurred. In this case, if the process execution status has been set to persistence, rollback is executed.
- The interface for CSBSystemException is shown as follows:
package jp.co.Hitachi.soft.csc.bp;
public class CSBSystemException extends Exception {
public CSBSystemException() { super(); }
public CSBSystemException(String message) { super(message); }
public CSBSystemException(String message, Throwable cause) {
super(message, cause);
}
public CSBSystemException(Throwable cause) { super(cause); }
}
|
- If an exception other than CSBUserException or CSBSystemException occurs, the processing is halted. In this case, if the process execution status has been set to persistence, rollback is executed.
- Note:
- The following table lists the variable types to be specified in Variable for argument and Variable for return value in the Invoke Java Activity dialog box, as well as their correspondence to the argument and return value types for this interface:
Variable types specified in "Variable for argument" and "Variable for return value" |
Argument and return value types |
boolean |
java.lang.Boolean |
numeric |
java.lang.Double |
string |
java.lang.String |
XML |
byte[] |
non-XML |
byte[] |
any |
byte[] |
If a type other than those listed above is specified, an error (KDEC20030-E) occurs.
- The interface of the Java class used is included in cscbp_ejb.jar. Therefore, for compilation, you must add cscbp_ejb.jar to the Classpath.
- A Java program uses the default constructor to generate an instance every time it is invoked. Therefore, you cannot hold data in instances.
(3) Definition procedure
To define an invoke Java activity:
- Deploy an invoke Java activity on the canvas.
For details about how to deploy activities, see 5.4.1 Deploying Activities.
- Use one of the following methods to open the Invoke Java Activity dialog box:
- Double-click an invoke Java activity on the canvas (only if the Java Edit menu is inactive).
- Select and right-click an invoke Java activity on the canvas, and then select Setting.
The Invoke Java Activity dialog box appears.
- Enter the necessary information in the Invoke Java Activity dialog box.
For details about the display and input contents of the Invoke Java Activity dialog box, see 1.4.10 Invoke Java Activity Dialog in the manual uCosminexus Service Platform Reference Guide.
To edit the contents of the variables to be specified in Variable for argument and Variable for return value, click Edit. The List Of Variables And Correlation Sets dialog box appears. In this dialog box, you can edit the contents of the variable. In Variable for argument and Variable for return value, you can specify a variable of the message type (XML, non-XML, or any). For details about the List Of Variables And Correlation Sets dialog box, see 1.4.1 List Of Variables And Correlation Sets Dialog in the manual uCosminexus Service Platform Reference Guide.
- Click OK in the Invoke Java Activity dialog box.
The Invoke Java Activity dialog box closes.
- Double-click an invoke Java activity on the canvas, or right-click it and then select Java Edit.
The Java editor of Eclipse starts.
The Java editor displays the source code of the class specified in the Invoke Java Activity dialog box. If you are editing the class specified in the Invoke Java Activity dialog box for the first time, a source code template is displayed when the Java editor starts.
- Use the Java editor to edit the source code of the Java class invoked by the invoke Java activity.
- Compile the edited source code of the Java class.
- Save the edited source code and compiled class file, and then exit the Java editor.
(4) Notes on definition
- Specify activity names that are unique within a business process (and also within a scope).
- An activity name must be no more than 64 bytes.
- Do not specify any control characters in the input fields of the dialog box.
- A Java class name must be specified.
All Rights Reserved. Copyright (C) 2015, Hitachi, Ltd.