Java Invoke

Java Invoke is a synchronous activity that can be used to invoke a Java class method. You can construct an instance of the specified Java class, if you invoke the constructor for the class.

General

The General tab has the following fields.

Field Literal Value/Module Property Description
Name None The name to be displayed as the label for the activity in the process.
Java Global Instance Yes Specify the resource in this field to execute methods on shared Java objects created by Java Global Instance resources.

For more information about the shared Java objects created by Java Global Instance resources, see Java Global Instance.

This disables the options on the Advanced tab. In the drop-down list in the Method field, you can select the method to execute.

Note: If the configuration of the Java Global Instance resource changes, select and view any Java Invoke activities in your process that reference the Java Global Instance to automatically propagate the changes. An exception is raised if you attempt to test your process before refreshing the reference to the Java Global Instance. You may need to manually update the mappings of any input or output, if you select a new method with a different signature in the Java Global Instance resource.
MultiOutput None Select this check box to specify multiple parameters in the Java invoke method.
Class Name None The declared Java class whose method you want to execute. Use the Browse A Class button to select the class, or use the Java Global Instance field to specify a shared Java object.
Note: To log steps in appnode log, from the custom java code, add the jar file rg.slf4j(1.8.0) to Import Packages under Module dependencies and in the java code add the below code
import org.slf4j.*;
.
.
.
Logger logger = LoggerFactory.getLogger("mylogger");
logger.info("my logger");
Under appnode, add the logger part in the logback.xml file
<logger name="mylogger">
<level value="INFO"/>
</logger>
Method None The method in the selected Java class you want to execute.

You can use the drop-down list to select a different method in the selected Java class, if required.

Parameters None The parameters for the Java Invoke activity. This element is available when the MultiOutput check box is selected.

This element contains a list of input and output parameters that are required for the Java invoke. This element is not available when the selected method has no parameters.

Each Input and Output parameter has the following fields.

  • Field Type: It can be either In or Out.
  • Field Name: The name of the parameter. When creating a new parameter, provide the name of the parameter. The setter/getter methods get automatically generated for the same, or select the options from the drop-down list of the names of class member variables that have setter/getter methods.
  • Type: The datatype of the parameter. The default is string. Specify one of the supplied Java primitive types, or specify Object Reference when accepting a Java object from another Java activity as input.
  • Occurrence: Specify whether the parameter is Required, Optional, or Repeating.
  • Click to add the input parameter.
  • Click to add the output parameter.
  • Click to delete the parameter.

Description

Provide a short description for the activity.

Advanced

The Advanced tab has the following fields.

Field Literal Value/Module Property Description
Instantiate the referenced class None This field controls one of the following:
  • The referenced class must be constructed when the activity is executed,
  • An object reference must be supplied in the activity’s input schema.

Select this check box, if you want to construct the referenced class using the default constructor when the activity executes. In this case, the referenced class is not included in the activity’s input schema.

Do not select this check box, if you want to provide an object reference for the class name specified on the General tab. The object must be created and contained in the output schema of a previously executed activity.

In this case, the referenced class is included in the activity’s input schema.

This check box is not available when MultiOutput on the General tab is selected.

Cache the object None This option is available only when the Instantiate the referenced class check box is selected.

Select this check box to specify that all instances of this Java Invoke activity share the instance of the instantiated referenced class. A cached referenced object is kept in the memory until the process engine terminates.

Not selecting this check box leads to each instance of this Java Invoke activity creating its own copy of the referenced class.

Invoke Cleanup Method None This check box is available only when the Cache the object check box is selected.

When selected, you can invoke a method on the cached object before the object is released from memory, when the process engine terminates. You can perform cleanup activities, such as closing connections, updating database tables, and so on.

Select this check box to display the Cleanup Method field.

Cleanup Method None This field is available only when the Invoke Cleanup Method check box is selected.

Using this field you can specify the name of the method to invoke, before the cached class in memory is released.

The selected method cannot contain any parameters, therefore only methods with no parameters are listed in this field. Any values returned by the selected method are ignored, but exceptions raised by the selected method are sent to the log.

Input

The following is the input for the activity.

Input Item Datatype Description
Parameters varies This element contains a list of input parameters that are required for the Java invoke Method selected on the General tab.

This element is not available when the selected method has no parameters.

Output

The following is the output of the activity.

Output Item Datatype Description
MethodReturnValue varies The Output tab has the return value specified for the Java invoke Method selected on the General tab.

This element is not available for methods that return void.

Parameters varies The Output tab lists all output parameters specified on the General tab.

Selecting MultiOutput on the General tab makes this output item available.

Fault

The Fault tab lists the exceptions generated by this activity. Selecting a method to invoke lists the exceptions generated by the method.

In theJava Invoke activity:

  • If MultiOutput is selected, the Fault tab generates the InvocationException exception with error schema element as msg,msgCode,methodName,exceptionClassName,exceptionMessage.
  • If MultiOutput is not selected, the Fault tab displays the exceptions generated by the method selected in it with error schema elements as: 1:Java exception Object 2:exceptionClassName 3:exceptionMessage
  • If MultiOutput is not selected and method does not generate any exception, again the Fault tab shows InvocationException with error schema element as msg, msgCode, methodName, exceptionClassName, and exceptionMessage.
Error Schema Element Datatype Description
msg string The error message. For more information, see Error Codes.
msgCode string The error code. For more information, see Error Codes.
methodName string The name of the Java method that raised the exception.
exceptionClassName string The exception class name.

The value of this element is obtained by calling the <exception>.getClass().getName() method.

exceptionMessage string The exception message.

The value of this element is obtained by calling the <exception>.getMessage() method.