Using a Simple Java Invoke Activity

The Java Invoke activity can invoke a Java method from a class that resides in the same application module, a shared module or an eclipse Plug-in project.

Prerequisites

The project must be configured with Java nature. For more information, see "Adding Java Nature to a Project" in the TIBCO BusinessWorks™ Container Edition Bindings and Palette Reference guide.

Procedure

  1. In the Project Explorer view, expand the application module project and right-click the Java source folder, src (default), and select New > Class.
  2. In the New Java Class wizard, specify the package name and name of the Java class, and click Finish to create the Java class in the specified package. For example, type com.tibco.myjavapackage for the package name and HelloWorld for the class name.
  3. Add one or more methods to the class. For example, add a static method, sayHello, which echoes a message "Hello World!" when invoked.
    public static String sayHello(String input){
    } 
    Note: You can invoke static or non-static methods using Java Invoke activity. For more information about Java Invoke activity, see the TIBCO BusinessWorks™ Container Edition Bindings and Palettes Reference guide.
  4. Add the implementation for the methods. For example, add the following implementation code to the sayHello method as shown:
    public static String sayHello(String input){
    	return "Hello " + input;
    } 
    After implementing Java methods, you can proceed to design the process in the Process Editor.
  5. Open the process in the Process Editor where you want to invoke the Java method and add a Java Invoke activity from Java Palette. Add transitions to the activity as required.
  6. Configure the Java Invoke activity from the Properties view of the activity as described.
    • Click Browse in front of the Class Name field. In the Class Selection dialog, type the first few letters of the class name to search for the class you want to access. From the list of matching items, select the class you want to access. For example, select HelloWorld. Click OK.
    • From the drop-down list, select the method you want to invoke. For example, select sayHello.
    • If the method requires input parameters, provide the values for the input parameters from the Input tab of Java Invoke activity. For example, in the sayHello method, add the string "World!" to the input parameter.
  7. Complete configuring your process and map the inputs for the activities as required. Then save the process. You can run or debug the application module in TIBCO Business Studio™ for BusinessWorks™ and verify the output of the Java Invoke activity.