Modifying the Mediation Task Data

The execute method of the mediation task runtime class has MediationExchange and the task input as its arguments. The mediation exchange holds the mediation message and the exchange variable as a generic Uxmal node N. Mediation Properties are held as strings.

The mediation message and properties constitute mediation task data.

As message data. or any data including exchange variables and contributed data. is based on generics, use XML API that is data model agnostic to process message data. For data manipulation you must use gXML. TIBCO gXML is an XML API that is based on generics and is data model agnostic.

This sample code shows processing message data:

public class HelloWorldRT<I, U, N extends I, A extends I, S, T, X> extendsTask<I, U, N, A, S, T, X> 

{
   public void init() throws TaskLifeCycleFault {  }
   
   public void destroy() throws TaskLifeCycleFault {  }

   public N execute(final N input, final Exchange<N> exchange)
   throws TaskFault 
   {

   final GxProcessingContext<I, U, N, A, S, T, X> pcx =    exchange.getXMLProcessingContext();

   final GxDocumentSerializerFactory<N, S> sf = new 
   DocumentSerializerFactory<I, U, N, A, S, T, X>(pcx);

   // Configure for "pretty" printing.
   sf.setIndent(Boolean.TRUE);
   sf.setMethod(new QName("xml"));
   sf.setOmitXmlDeclaration(false);

   final StringWriter sw = new StringWriter();
   final GxDocumentSerializer<N> serializer = sf.newDocumentSerializer(sw);

   if(input != null){ serializer.serialize(input); }else{ serializer.serialize   (exchange.getMessageData()); }

   Logger logger = LoggerFactory.getLogger(HelloWorldRT.class);
   logger.info(sw.toString());
   return exchange.getMessageData();
   }
}