Author: buildbot
Date: Sun Oct 11 22:19:10 2015
New Revision: 968545
Log:
Production update by buildbot for camel
Modified:
websites/production/camel/content/cache/main.pageCache
websites/production/camel/content/jackson-xml.html
Modified: websites/production/camel/content/cache/main.pageCache
==============================================================================
Binary files - no diff available.
Modified: websites/production/camel/content/jackson-xml.html
==============================================================================
--- websites/production/camel/content/jackson-xml.html (original)
+++ websites/production/camel/content/jackson-xml.html Sun Oct 11 22:19:10 2015
@@ -41,6 +41,7 @@
<script src='//camel.apache.org/styles/highlighter/scripts/shCore.js'
type='text/javascript'></script>
<script src='//camel.apache.org/styles/highlighter/scripts/shBrushJava.js'
type='text/javascript'></script>
<script src='//camel.apache.org/styles/highlighter/scripts/shBrushXml.js'
type='text/javascript'></script>
+ <script src='//camel.apache.org/styles/highlighter/scripts/shBrushPlain.js'
type='text/javascript'></script>
<script type="text/javascript">
SyntaxHighlighter.defaults['toolbar'] = false;
@@ -90,6 +91,47 @@
unmarshal().jacksonxml().
to("mqseries:Another.Queue");
]]></script>
+</div></div><h4 id="JacksonXML-UsingJacksonXMLinSpringDSL">Using Jackson XML
in Spring DSL</h4><p>When using <a shape="rect"
href="data-format.html">Data Format</a> in Spring DSL you need to declare
the data formats first. This is done in
the <strong>DataFormats</strong> XML tag.</p><div class="code panel
pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
+<script class="brush: xml; gutter: false; theme: Default"
type="syntaxhighlighter"><![CDATA[ <dataFormats>
+ <!-- here we define a Xml data format with the id jack and that
it should use the TestPojo as the class type when
+ doing unmarshal. The unmarshalTypeName is optional, if not
provided Camel will use a Map as the type -->
+ <jacksonxml id="jack"
unmarshalTypeName="org.apache.camel.component.jacksonxml.TestPojo"/>
+ </dataFormats>
+]]></script>
+</div></div><p>And then you can refer to this id in the route:</p><div
class="code panel pdl" style="border-width: 1px;"><div class="codeContent
panelContent pdl">
+<script class="brush: xml; gutter: false; theme: Default"
type="syntaxhighlighter"><![CDATA[ <route>
+ <from uri="direct:back"/>
+ <unmarshal ref="jack"/>
+ <to uri="mock:reverse"/>
+ </route>
+]]></script>
+</div></div><h3 id="JacksonXML-ExcludingPOJOfieldsfrommarshalling">Excluding
POJO fields from marshalling</h3><p>When marshalling a POJO to JSON you might
want to exclude certain fields from the JSON output. With Jackson you can
use <a shape="rect" class="external-link"
href="http://wiki.fasterxml.com/JacksonJsonViews" rel="nofollow">JSON
views</a> to accomplish this. First create one or more marker
classes.</p><div class="code panel pdl" style="border-width: 1px;"><div
class="codeContent panelContent pdl">
+<script class="brush: java; gutter: false; theme: Default"
type="syntaxhighlighter"><![CDATA[
+public class Views {
+
+ static class Age {
+ }
+
+ static class Weight {
+ }
+}
+]]></script>
+</div></div>Use the marker classes with
the <code>@JsonView</code> annotation to include/exclude certain
fields. The annotation also works on getters.<div class="code panel pdl"
style="border-width: 1px;"><div class="codeContent panelContent pdl">
+<script class="brush: java; gutter: false; theme: Default"
type="syntaxhighlighter"><![CDATA[
+@JsonView(Views.Age.class)
+private int age = 30;
+
+private int height = 190;
+
+@JsonView(Views.Weight.class)
+private int weight = 70;
+]]></script>
+</div></div>Finally use the
Camel <code>JacksonXMLDataFormat</code> to marshall the above POJO to
XML.<div class="code panel pdl" style="border-width: 1px;"><div
class="codeContent panelContent pdl">
+<script class="brush: java; gutter: false; theme: Default"
type="syntaxhighlighter"><![CDATA[
+from("direct:inPojoAgeView").marshal().jacksonxml(TestPojoView.class,
Views.Age.class);
+]]></script>
+</div></div>Note that the weight field is missing in the resulting JSON:<div
class="code panel pdl" style="border-width: 1px;"><div class="codeContent
panelContent pdl">
+<script class="brush: java; gutter: false; theme: Default"
type="syntaxhighlighter"><![CDATA[{"age":30,
"weight":70}]]></script>
</div></div><h3 id="JacksonXML-Dependencies">Dependencies</h3><p>To use
Jackson XML in your camel routes you need to add the dependency on
<strong>camel-jacksonxml</strong> which implements this data format.</p><p>If
you use maven you could just add the following to your pom.xml, substituting
the version number for the latest & greatest release (see <a shape="rect"
href="download.html">the download page for the latest versions</a>).</p><div
class="code panel pdl" style="border-width: 1px;"><div class="codeContent
panelContent pdl">
<script class="brush: xml; gutter: false; theme: Default"
type="syntaxhighlighter"><![CDATA[<dependency>
<groupId>org.apache.camel</groupId>