Java Custom Function

Shared Configuration

The Java Custom Function resource allows you to create custom functions to use when mapping data in an activity’s input tab. These functions are also displayed when using the XPath Editor to build an XPath expression.

To create a custom function, you must write the function as a method of a Java class and compile the code into a Java class file. You then load that class file into the project using this resource.

When the class is loaded using this resource, ActiveMatrix BusinessWorks inspects the contents of the class and only the class methods that meet the following restrictions are made available in XPath:

  • Only methods declared as public and static are loaded.

  • The input parameters and return values must be of one of the types described in Datatypes allows for Java custom functions.

  • The return value of the function cannot be void.

  • The method cannot be a constructor.

  • The method cannot explicitly throw an exception. Runtime exceptions are allowed, however.

  • Method names cannot be overloaded in a class or any imported classes in a single Java Custom Function resource. You can load methods of the same name into separate classes in separate Java Custom Function resources and use the Prefix field to differentiate between the methods.

  • If you make references to any imported class files, these classes must be available in the classpath configured for ActiveMatrix BusinessWorks. The easiest way to make the imported classes available is to place them in the TIBCO/bw/2.0/lib directory.

  • Inner classes are not supported.

Tip: ActiveMatrix BusinessWorks provides detailed online help for each XPath function. To provide online help for Java Custom Functions, create a two-dimensional array named HELP_STRINGS in your class. The element containing a string matching the function name is used as the help for that function. For an example of creating the HELP_STRINGS arraySee Example Java Function.

Datatypes allows for Java custom functions

Type of Data

Datatypes Allowed for Input Parameters and Return Types

Strings and Characters

String

char

Boolean

Boolean

boolean

Numbers

int

float

double

short

long

Integer

Float

Double

Short

Long

Warning: Static variables are not supported in Java custom functions. Do not write custom functions that use static variables.

If there are different classes that have methods with the same names, the Prefix field allows you to specify a prefix for qualifying which method you want to use in an XPath function. For more information, see the description of the Prefix field below.

For more information about building XPath expressions and using the XPath editor, see TIBCO ActiveMatrix BusinessWorks™ Process Design.