Skip to content

About Transformer Development

Transformers make it possible to transform data between different formats to adapt it to the current needs. Read more about transformers here.

Transformer Types

Transformers can be divided based on their implementation:

  • Xsl Transformers
    Transformation is performed by a stylesheet engine (XALAN) and transformation rules are defined in an XSLT file. XSL transformers can only work on XML data.
  • Java Transformers
    Transformation is performed by a Java class implementing a given interface. Transformer can be available as a single transformer Java class or a jar library containing the actual transformer class.
    There are two types of Java transformers:
    • String Transformers
      Implement interface ifs.fnd.connect.xml.Transformer. This type can be used for transformation of any type of text document.
    • Binary Transformers
      Implement interface ifs.fnd.connect.xml.BinaryTransformer. This type can be used for transformation of binary data, e.g. digital signing of PDF documents.

How to develop a Transformer

Transformers can be developed in several ways. XSL transformers can be developed using different types of third party tools that allow creation of XSL or XSLT files.

Java transformers, both text and binary, can also be developed using an arbitrary tool for Java development. Simply create a new Java class implementing one of the interfaces: ifs.fnd.connect.xml.Transformer or ifs.fnd.connect.xml.BinaryTransformer. Both interfaces are located in the IFS Connect framework, so you have to include the ifs-fnd-connect.jar(can be downloaded from here) library to you Java project. You may also need to include libraries ifs-fnd-base.jar and/or ifs-fnd-common.jar with JSF specific classes that IFS Connect may require. Of course, you have to include all the jar libraries that your transformer may require.

Note that the transformer class has to be located in the default package, i.e. do not put it in any specific Java package:

import ifs.fnd.base.IfsException;  
import ifs.fnd.connect.xml.Transformer;  

public class MyStringTransformer implements Transformer {  

   @Override  
   public void init() throws IfsException {  
   }  

   @Override  
   public String transform(String str) throws IfsException {  
      return str;  
   }  
}

Both interfaces require you to implement two functions:

  • init() - called only once when the class is loaded from the database into memory.
  • transform() - called to transform the actual data. Note that the framework will create new instance of the class each time this method is about to be invoked.

The only difference between the two mentioned interfaces is the signature of the transform() method. For the Transformer interface the method takes a String as argument and returns a String (the example above), while for the BinaryTransformer it takes byte array as argument and returns byte array:

@Override  
   public byte[] transform(byte[] data) throws IfsException {  
      return data;  
   }

Your Java transformer can be compiled to a single class file or build to a jar library. The first option is useful if everything your transformer needs for performing the transformation can be encapsulated within one single Java class and does not rely on any third-party code that is not available during run-time (you can still use framework classes and third-party libraries supplied with IFS Cloud).

But if your transformer needs other third-party libraries or the code cannot be kept within a single class, you will need to create a jar file. The file has to include all other classes together with any third-party ones. The jar file has to include a manifest file MANIFEST.MF located in subfolder META-INF with an attribute with name Transformer-class defining the class implementing one of the transformer interfaces.

Examples

There two complete NetBeans example projects available that you can use when creating your own Java transformer: