com.sap.aii.mapping.api

Interface StreamTransformation


Deprecated. As of SAP NetWeaver NEW YORK, replaced by AbstractTransformation. Nevertheless this interface is still supported. So it is not necessary to change existing mappings that use this deprecated interface.

public interface StreamTransformation

Each XI Java mapping program must implement this interface. Since SAP NetWeaver NEW YORK AbstractTransformation should be used instead. The implementing class needs a default constructor. For each message a new instance is created with the default constructor. Afterwards setParameter(java.util.Map) is called before execute(InputStream, OutputStream) is called.

Example The following example shows how the MAPPING_TRACE and RECEIVER_NAME parameters are set and evaluated in a Java mapping program:

 import java.io.InputStream;
 import java.io.OutputStream;
 import java.util.Map;
 import java.util.HashMap;
 import com.sap.aii.mapping.api.AbstractTrace;
 import com.sap.aii.mapping.api.StreamTransformation;
 import com.sap.aii.mapping.api.StreamTransformationConstants;
 
 public class JavaMapping implements StreamTransformation {
 
   private Map param = null;
 
   private AbstractTrace trace = null;
 
   public void setParameter(Map param) {
     this.param = param;
   }
 
   public void execute(InputStream in, OutputStream out) throws StreamTransformationException {
     // ...
     trace = (AbstractTrace) param.get(StreamTransformationConstants.MAPPING_TRACE);
     trace.addInfo("...");
 
     // ...
     String receiverName = (String) param.get(StreamTransformationConstants.RECEIVER_NAME);
 
     // ...  
   }
 }
 

It is possible that different instances of the implementing class are executed in parallel in different Threads. Take care about this when using static fields or static methods. Java mapping programs are not permitted to be stateful. It is not permitted to perform actions such as writing data to a database table during a Java mapping. The Integration Server cannot track such side effects. Therefore, if an attempt is made to resend a message that has not been received by the receiver, the data may inadvertently be written to the database twice in a Java mapping. Note also that you cannot call java.lang.System.exit() or java.lang.System.setProperties() within a Java mapping and that you cannot use a ClassLoader in the classes of an imported archive. For reading files from an imported Archive getClass().getResourceAsStream(String name) can be used.


Method Summary
 void execute(InputStream in, OutputStream out)
          Deprecated. Is called from the rumtime after executing setParameter(java.util.Map).
 void setParameter(Map param)
          Deprecated. Is called from the rumtime after executing the default constructor and before calling execute(InputStream, OutputStream).
 

Method Detail

setParameter

void setParameter(Map param)
Deprecated. 
Is called from the rumtime after executing the default constructor and before calling execute(InputStream, OutputStream). A java.util.Map is passed that contains an AbstractTrace, values of the message header and since SAP NetWeaver '04 SPS 14 a DynamicConfiguration. As a key for reading values fromthe java.util.Map param the constants in StreamTransformationConstants can be used.

Example:
(AbstractTrace)param.get(StreamTransformationConstants.MAPPING_TRACE);

Parameters:
param - java.util.Map, containing an AbstractTrace, values of the MessageHeader and since SAP NetWeaver '04 SPS 14 a DynamicConfiguration.

execute

void execute(InputStream in,
             OutputStream out)
             throws StreamTransformationException
Deprecated. 
Is called from the rumtime after executing setParameter(java.util.Map). This method contains an java.io.InputStream for the source document and an java.io.OutputStream for the target document as parameters. These streams are usually XML documents. The target document must be written in the passed java.io.OutputStream out. For parsing XML document javax.xml.parsers.SAXParser or javax.xml.parsers.DocumentBuilder can be used. During converting bytes to java.lang.String or java.lang.String to bytes take care about the encoding.
A StreamTransformationException indicates a problem . The message than gets an error state in the pipeline.

Parameters:
in - source document
out - target document to fill
Throws:
StreamTransformationException - indicates a problem during execution of the mapping program
See Also:
SAXParser, DocumentBuilder
Access Rights

This class can be accessed from:


SC DC Public Part ACH
[sap.com] SAP_XIAF [sap.com] com.sap.aii.mapping.lib.facade api BC-XI


Copyright 2014 SAP AG Complete Copyright Notice