While developing TIBCO BW processes in designer, you can add custom java code using Java Code activity which is available in Java Palette. In this TIBCO Java Code step by step tutorial, you will learn how to add and execute custom java code in TIBCO.
TIBCO Java Code Tutorial Step 1: Create Process with Java Code activity
In this tutorial we will create a simple process which will take age as an input and It will use Java Code to return a status based on the value of the age.
The process will have a Java Code activity between its start and end activity.
In the output editor tab of Start activity, create an integer type element to get age as input as shown below:
Next, we need to add parameters to Java Code activity. For this, in the configuration tab of Java Code activity, add Input and Output parameters as shown below:
Next we move to Code tab of Java Code activity. If you click on the option of Full Class, you will see that getter and setter methods for the parameters are automatically created. These getter and setter methods are executed by the engine before invoke method.
The code changes that we need to perform should be inside the invoke method. In our example case, I am simply checking the age and if age is above 18, status is set as Valid otherwise its value will be invalid. Code written inside invoke method is shown below:
After making changes to invoke method body, we need to compile the class using compile button. As you can see below, code has compiled successfully:
Now we are done with the process implementation. Let’s move forward with the testing of process.
Step 2: Test Java Code in TIBCO Designer Process
Validate the process and once it has validated successfully, load the process in designer tester. You will be asked to provide age input value. Provide some integer value to this field in the similar way as shown below:
As we gave 45 as age input, you can see in the below screenshot that Java Code has run successfully and we have got “valid” in the status field as output:
This tutorial is awesome… Thanks a lots for the effort you have put!!!
Pingback: How to Call Java Class Methods in TIBCO By Adding JAR File: Step By Step Tutorial | Tibco Guide