If you checked out Milestone 1, you might have noticed that the data type transformations were simply Java classes which implemented our Transformer<F,T> contract.  This route works great for quick conversions, silly examples (natch), or sophisticated mappings which require tight control over the transformation behavior.  Most transformation use cases will likely benefit from purpose-built transformers which handle generalized mapping tasks and can be configured for specific transformations.   The first example of this in SwitchYard is the Smooks Transformer.

 

Smooks transforms can be added to a SwitchYard application by adding a <transform.smooks> declaration in switchyard.xml.

 

<transforms>

   <transform.smooks type="JAVA2XML"

      from="java:org.switchyard.quickstarts.transform.smooks.OrderAck"

      to="{urn:switchyard-quickstarts:transform-smooks:1.0}submitOrderResponse"

      config="/smooks/OrderAck_XML.xml"/>

</transforms>

 

The above should look very familiar if you checked out the configuration generated from m1app.  Just like a Java-based transformation, you specify the from and to types for the transform instance.  The config parameter points to a Smooks transformation definition, which gives you the full power of Smooks to transform Java, XML, EDI, CSV, and loads more.

 

We have added a new quickstart, transform-smooks, to our quickstarts repository if you want to see this in action.