mercury worlds

Coding Java Programs for EBI External API Actions

| Comments

In Extol Business Integrator (EBI), coding requirements for External API Actions (implemented via Java programs) are different from a Business Process task Run Java Program. The Run Java Program task can execute any method from a class or JAR file with any parameter combination. In contrast, External API Actions have specific parameter requirements.

Java structure for External API Actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
import com.extol.engines.StateTableInstructionState;
import com.extol.engines.MethodMessages;

public class MyClassApi implements Serializable {

  public static synchronized void execute(Object[] parms, StateTableInstructionState stis, MethodMessages mm) {
      // parameters passed in Object[] parms - these map to EBI
      String parm1 = (String) parms[1];
      String parm2 = (String) parms[2];

      ...

      // method body

      ...

      parms[0] = someReturnValue; // return value
  }

  // empty main method...
  public static void main(String[] args) {
  }

  // or use as testing, call from command line...
  public static void main(String[] args) {

      // Exerciser program.
      Object[] parms = new Object[3];
      
      // parms[0] receives the output, nextSequence
      parms[1] = "my parm 1";
      parms[2] = "my parm 2";
      
      try {
          execute(parms, null, null);
          System.out.println("Output: '" + parms[0] + "'");
      }
      catch (Exception e) {
          System.out.println(e.toString());
          e.printStackTrace();
      }
  }
}

The two import lines are required for communications between EBI and the Java program when used as an External API Action.

The class definition should implement Serializable.

Extol discourages the use of the main() method. Other coding examples I’ve seen use execute() as the method name. Obviously, if you have multiple methods in your class/JAR file, they will have different names.

When defining the External API Action in EBI, your mapped parameters correspond to the Object[] parms parameter. By Extol convention, if there is a (single) return value, it is passed in parms[0].

I use the main() method to call from Eclipse or the command line for testing, and set up the parameters the same way as they are expected to be used in EBI.

It is recommended (at least for EBI 2.4, as of this writing) that return values be type String. When used in an EBI transformation ruleset, output type of Integer cannot be mapped to a corresponding middle tree variable, resulting in a type mismatch error message.

Update 5 Nov 2009: If an External API Action definition is changed, any rule sets referencing it must be updated. Open the ruleset and select Tools, Refresh Action Lists. Then validate, compile, and save the rule set. The reason for this is because the ruleset is compiled into a Java class, and any external API actions are integrated at compile-time.

This article was originally published on 2 Nov 2009.

Comments