You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by bu...@apache.org on 2014/04/09 22:24:48 UTC
svn commit: r905613 [3/3] - in /websites/production/camel/content:
book-dataformat-appendix.html book-in-one-page.html cache/main.pageCache
xstream.html
Modified: websites/production/camel/content/xstream.html
==============================================================================
--- websites/production/camel/content/xstream.html (original)
+++ websites/production/camel/content/xstream.html Wed Apr 9 20:24:47 2014
@@ -100,6 +100,16 @@ from("activemq:My.Queue").
marshal().xstream().
to("mqseries:Another.Queue");
]]></script>
+</div></div><p>If you would like to configure the <code>XStream</code> instance used by the Camel for the message transformation, you can simply pass a reference to that instance on the DSL level.</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
+<script class="theme: Default; brush: java; gutter: false" type="syntaxhighlighter"><![CDATA[XStream xStream = new XStream();
+xStream.aliasField("money", PurchaseOrder.class, "cash");
+
+...
+
+from("direct:marshal").
+ marshal(new XStreamDataFormat(xStream)).
+ to("mock:marshaled");
+]]></script>
</div></div><h3 id="XStream-XMLInputFactoryandXMLOutputFactory">XMLInputFactory and XMLOutputFactory</h3><p><a shape="rect" class="external-link" href="http://xstream.codehaus.org/" rel="nofollow">The XStream library</a> uses the <code>javax.xml.stream.XMLInputFactory</code> and <code>javax.xml.stream.XMLOutputFactory</code>, you can control which implementation of this factory should be used.</p><p>The Factory is discovered using this algorithm:<br clear="none"> 1. Use the <code>javax.xml.stream.XMLInputFactory</code> , <code>javax.xml.stream.XMLOutputFactory</code> system property.<br clear="none"> 2. Use the <code>lib/xml.stream.properties</code> file in the <code>JRE_HOME</code> directory.<br clear="none"> 3. Use the Services API, if available, to determine the classname by looking in the <code>META-INF/services/javax.xml.stream.XMLInputFactory</code>, <code>META-INF/services/javax.xml.stream.XMLOutputFactory</code> files in jars available to the JRE.<br clear="none"> 4. Use the
platform default XMLInputFactory,XMLOutputFactory instance.</p><h3 id="XStream-HowtosettheXMLencodinginXstreamDataFormat?">How to set the XML encoding in Xstream DataFormat?</h3><p>From Camel 2.2.0, you can set the encoding of XML in Xstream DataFormat by setting the Exchange's property with the key <code>Exchange.CHARSET_NAME</code>, or setting the encoding property on Xstream from DSL or Spring config.</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
<script class="theme: Default; brush: java; gutter: false" type="syntaxhighlighter"><![CDATA[from("activemq:My.Queue").
marshal().xstream("UTF-8").