This example shows you how to create a sample Java library and adapt it to a MapForce Function File (.mff) that can be imported as a MapForce library.
|Note:||Adapting a Java library to .mff format is just one of the ways to import Java libraries in MapForce. A simpler alternative is to import Java .class files directly, see Example: Import Custom Java Class.|
The configuration process consists of the following steps:
1.Create a new Java project in your preferred development environment (for example, Eclipse).
2.Add to the project a new package called com.mylib which consists of a class called Greetings. In the code listing below, notice that the SayHello function has been defined as public static.
3.Optionally, if your project needs support for special schema types such as date, time, and duration, import the com.altova.types package. To obtain this package, generate Java code from a mapping without custom functions.
4.Compile your custom library to a class file, and add it to the Java classpath.
5.Using an XML editor, create a new .mff file and validate it against the ..\Program Files\MapForceLibraries\mff.xsd schema. Make sure that all references under implementation language="java" point to the correct Java members created previously. Also, the line function name="SayHello" must refer to the function name exactly as it was defined in Java, see also Configuring the .mff File.
<?xml version="1.0" encoding="UTF-8"?>
You have now finished creating a custom Java library and the .mff file which adapts it to MapForce. The custom .mff file can now be imported as a library into MapForce, see Importing .mff Libraries.