Adding Custom Java Functions

Using TIBCO BusinessEventsyou can define custom functions and expose them as catalog functions. By exporting the project containing the custom Java catalog functions to a project library, the custom Java functions can be used in other projects.

Procedure

  1. Define a simple Java class under the JavaSrc folder. For example, MyFunction.java.
  2. To expose Java methods as functions, declare them as public static variables:
    public static int sum(int a, int b) 
          									{
                          int x = a+b;
                										return x;
         									 }
    
  3. The annotation @BE Package is a class level annotation: add the class-level annotation @BEPackage before any classes are declared.
    @BEPackage(catalog = "arithmeticOperations", category = "arithmetic.operations", synopsis = "Performs few arithemtic operations")
  4. The annotation @BEFunction defines the synopsis, signature, parameters, return types, descriptions, examples and other relevant information about the function. The information provided in the annotation is displayed in the tooltip for the catalog function.
    @BEFunction(name = "SummationTest", 
    			description="Adds two given numbers", 
    			signature="int sum(int a, int b)",
    			       freturn = @com.tibco.be.model.functions.FunctionParamDescriptor(name = "", type = "int", desc = "Returns the summation of a and b."),
    			params = {
    			@com.tibco.be.model.functions.FunctionParamDescriptor(name = "a", type = "int", desc = "First arg"),
    			@com.tibco.be.model.functions.FunctionParamDescriptor(name = "b", type = "int", desc = "Arg two")
    			},
    			fndomain = {ACTION, CONDITION, QUERY, BUI}, version="1.0",see="",cautions="none", example=" ")
    					
    				
  5. Save the file.
    Once you add and save the annotations, the custom Java functions are available in the Catalog Functions view.