Tutorial & Interface
Using Java Call-Outs
This interface and related tutorial demonstrate the use of the Data Mapper in Route configurations to transform between XML Formats. In this particular exercise, an existing Route (from “Data Mapping – Using Tabular Mappings”) is modified to transform a “PeopleA” XML format to the “PeopleF” XML format, which makes use of a Java method call-out to generate a unique ID.
In this tutorial, we’ll cover using the “Java Call-Out” feature of the Data Mapper to invoke Java methods. This tutorial expands on concepts covered in “Data Mapping Using Functions,” so users are expected to be familiar with that content.
This Interface demonstrates how to use the eiConsole to separate a single data stream into multiple data streams each based on a subset of the original stream’s contents for independent handling and processing.
Transaction splitting may be used when:
- An incoming transaction contains multiple data payloads
- An incoming transaction needs to have different components processed separately
How to Use This Example
Download the INTERFACE file and save it to your local disk.
Open the eiConsole, click on the File drop-down menu and select Import Working Directory/Route/Format. Highlight the name of the file to import and press the Import Selected button. The imported Interface will appear in your current Working Directory.
Next, follow the tutorial and walk through it step-by-step.
Creating & Configuring a New Route
Start by creating and configuring a new Route similar to the prior tutorials. Add a new Format named “PeopleA XML to PeopleF XML” on the Target Transform, and uncheck “Use Direct Relay”:
Click “New” to open the Data Mapper. Load “PeopleA.xml” for the Source and “PeopleF.xml” for the target:
Repeat the mapping exercise from the previous tutorial, or copy the XSLT using the “XSLT View” tab:
For this tutorial, we’ll really just be making a single modification. The “SSN” field represents an identifier for a given Person. Rather than using this value, suppose we wanted to use a GUID instead. While you could conceivably do this in standard XSLT, the means of accomplishing this are probably well outside reasonable time constraints. For facilitating operations of this nature, calling out to the library of Java classes and methods is usually a better use of time.
Select the Custom tab, then the Uncategorized sub-tab. You should see “Java Extension” as an option:
Drag & Drop this item onto the “SSN” field in the mapping panel. This will raise a dialog querying you for a Java call string and the number of arguments:
For our call string, provide:
for Java Class Name: java.util.UUID
for Java Method Call: randomUUID
You do not need an ending set of parentheses, as the arguments count will provide them automatically. After making this change, save and test the transformation result. You should see a UUID / GUID in the SSN field:
You can use this mechanism to call any Java class or method available in the eiConsole and eiPlatform. This includes the standard Java runtime classes as well as quite a few commonly used libraries. Java call-outs are used for date formatting, database look-ups, saving and loading of files, and other utility functions.