Monday, September 27, 2010

Custom XStream driver configuration added to Camel XStream data format

Apache Camel provides support for XStream data transformation. However until now it was very difficult to provide XML pull parser driver different then default XppDriver. Few days ago I created patch for Apache Camel XStream data format (with help from Willem Jiang with hacking Spring DSL for it). My improvment has been submitted to the Camel codebase. It should be included in Camel 2.5 .

Now you can pass reference of the HierarchicalStreamDriver instance directly in the Spring DSL with driverRef attribute:

<bean id="jsonDriver" 
class="com.thoughtworks.xstream.io.json.JsonHierarchicalStreamDriver"/>

<camelContext id="camel" xmlns="http://camel.apache.org/schema/spring">
  <dataFormats>
    <xstream id="xstream" driverRef="jsonDriver"/>            
  </dataFormats>

  <route>
    <from uri="direct:start"/>
    <marshal ref="xstream"/>
    <to uri="mock:result"/>
    </route>
</camelContext>

No comments:

Post a Comment