Copyright © Cloud Software Group, Inc. All Rights Reserved
Copyright © Cloud Software Group, Inc. All Rights Reserved


Chapter 7 Java Palette : Java Code

Java Code
Activity
You can add custom code to your process definition with the Java Code activity. This activity allows you to write standard Java code that can manipulate any of the process data or perform any action you choose.
The Java Code activity automatically creates an invoke() method in which you place the code you want to execute. This method is called when the engine processes the Java Code activity.
When you specify input and output parameters for the Java Code activity, get/set method code is automatically generated for the activity. You can use the get/set methods in your Java code, and you can display the code for the get/set methods when you select the Full Class radio button on the Code tab.
Use Edit>Preferences>Other to specify the Java editor you want to use to edit source code.
See Common Features of Java Code and Java Method for more information about features available in the Java Code activity.
Configuration
The Configuration tab has the following fields.
Code
You can choose to display the full Java class or display only the invoke() method body of the class. Choose the appropriate option at the top of the Code tab for the code you want to display.
The code tab has the following fields/buttons.
Specify the code you want to execute in the automatically generated invoke() method. The get/set methods for the input and output parameters are automatically generated and displayed when you choose the Full Class option above the code window.
After compilation, the source and compiled java code are placed into the lib/palettes/javaCode directory in the TIBCO ActiveMatrix BusinessWorks installation directory.
Use Edit>Preferences>Other to specify the Java editor you want to use to edit source code.
Note: On MS Windows platforms, a temporary file is created to hold the Java code when you edit your code with this button. This file is located in either C:\temp or C:\tmp or your working directory. If your working directory contains a space (for example C:\Documents and Settings\...), there may be problems opening the temporary file. Make certain either the C:\temp or C:\tmp directory exists to avoid this issue.
Compiling Java Code
You can compile each Java Code activity individually with the Compile button on the Code tab, or you can compile all Java Code activities in your project at once with the Tools > Java Code > Compile All Code menu item.
When you use the Compile All Code menu item, the Compile All Code dialog appears. Figure 13 illustrates this dialog.
Figure 13 Compile All Code dialog
All process definitions containing Java Code activities that do not compile successfully are listed in the Activities area. Each Java Code activity is listed under the process definition in which it is located. You can select any Java Code activity in the Activities area to display the compilation errors for that activity.
The dialog has the following buttons:
Passing Java Objects Between Java Code Activities
You may create instances of Java objects in your Java code or by using the Java Method or XML To Java activities. You can pass these Java objects using an output parameter to another activity later in the process definition. The Java Code activity receiving a Java object accepts the object into an input parameter and you must map the output Java object to the input object of the receiving Java Code object.
Figure 14 illustrates two Java code activities. The CreateObject activity creates a Java object and passes a reference to the object in the output parameter named out_object. The UseObject activity defines an input parameter named in_object of type ObjectReference and maps the CreateObject activity’s output object reference to its input parameter of type ObjectReference.
Figure 14 Passing objects between Java Code activities
The UseObject activity can invoke methods on the input object as it would for any other object. For example, if you want to call a method named getInteger() that returns an integer, you would use the following code in the UseObject activity:
 
MyClass myObject = (MyClass) in_object;
int var = 0;
if (myObject != null) {
   var = myObject.getInteger();
}
Input
See TIBCO ActiveMatrix BusinessWorks Process Design for more information about mapping and transforming input data.
The input for the activity is the following.
Output
The output for the activity is the following.
Error Output
The Error Output tab lists the exceptions that can be thrown by the Java Code activity. Because the activity can return any Java exception, all potential exceptions cannot be listed here. However, the error schema for all errors is the same. The following describes the schema for exceptions returned by the Java Code activity.
The TIBCO ActiveMatrix BusinessWorks error message. See TIBCO ActiveMatrix BusinessWorks Error Codes for more information.
The TIBCO ActiveMatrix BusinessWorks error code. See TIBCO ActiveMatrix BusinessWorks Error Codes for more information.

Copyright © Cloud Software Group, Inc. All Rights Reserved
Copyright © Cloud Software Group, Inc. All Rights Reserved