Author: buildbot
Date: Sun Oct 11 23:19:22 2015
New Revision: 968549

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 23:19:22 2015
@@ -132,7 +132,89 @@ from("direct:inPojoAgeView").m
 ]]></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[{&quot;age&quot;:30, 
&quot;weight&quot;: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 &amp; 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">
+</div></div><h3 
id="JacksonXML-Include/ExcludefieldsusingthejsonViewattributewithJacksonXMLDataFormat">Include/Exclude
 fields using the&#160;<code>jsonView</code>&#160;attribute 
with&#160;<code>JacksonXML</code>DataFormat</h3><p><strong>Available as of 
Camel 2.12</strong></p><p>As an example of using this attribute you can instead 
of:</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[JacksonXMLDataFormat ageViewFormat = new 
JacksonXMLDataFormat(TestPojoView.class, Views.Age.class);
+from(&quot;direct:inPojoAgeView&quot;).
+  marshal(ageViewFormat);
+]]></script>
+</div></div><p>Directly specify your&#160;<a shape="rect" 
class="external-link" href="http://wiki.fasterxml.com/JacksonJsonViews"; 
rel="nofollow">JSON view</a>&#160;inside the Java DSL as:</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[from(&quot;direct:inPojoAgeView&quot;).
+  marshal().jacksonxml(TestPojoView.class, Views.Age.class);
+]]></script>
+</div></div><p>And the same in XML DSL:</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[&lt;from 
uri=&quot;direct:inPojoAgeView&quot;/&gt;
+  &lt;marshal&gt;
+    &lt;jacksonxml 
unmarshalTypeName=&quot;org.apache.camel.component.jacksonxml.TestPojoView&quot;
 jsonView=&quot;org.apache.camel.component.jacksonxml.Views$Age&quot;/&gt;
+  &lt;/marshal&gt;
+]]></script>
+</div></div><h3 id="JacksonXML-Settingserializationincludeoption">Setting 
serialization include option</h3><p>If you want to marshal a pojo to XML, and 
the pojo has some fields with null values. And you want to skip these null 
values, then you need to set either an annotation on the pojo,&#160;</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[@JsonInclude(Include.NON_NULL)
+public class MyPojo {
+   ...
+}]]></script>
+</div></div><p>But this requires you to include that annotation in your pojo 
source code. You can also configure the Camel JacksonXMLDataFormat to set the 
include option, as shown below:</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[JacksonXMLDataFormat format = new 
JacksonXMLDataFormat();
+format.setInclude(&quot;NON_NULL&quot;);]]></script>
+</div></div><p>Or from XML DSL you configure this as</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[    &lt;dataFormats&gt;
+      &lt;jacksonxml id=&quot;json&quot; include=&quot;NOT_NULL&quot;/&gt;
+    &lt;/dataFormats&gt;]]></script>
+</div></div><h3 
id="JacksonXML-UnmarshallingfromXMLtoPOJOwithdynamicclassname">Unmarshalling 
from XML to POJO with dynamic class name</h3><p>If you use jackson to unmarshal 
json to POJO, then you can now specify a header in the message that indicate 
which class name to unmarshal to.<br clear="none"><span>The header has 
key&#160;</span><code>CamelJacksonUnmarshalType</code><span>&#160;if that 
header is present in the message, then Jackson will use that as FQN for the 
POJO class to unmarshal the XML payload 
as.</span></p><p><span>&#160;</span><span>For JMS end users there is the 
JMSType header from the JMS spec that indicates that also. To enable support 
for JMSType you would need to turn that on, on the jackson data format as 
shown:</span></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[JacksonDataFormat format = new 
JacksonDataFormat();
+format.setAllowJmsType(true);]]></script>
+</div></div><p>Or from XML DSL you configure this as</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[    &lt;dataFormats&gt;
+      &lt;jacksonxml id=&quot;json&quot; allowJmsType=&quot;true&quot;/&gt;
+    &lt;/dataFormats&gt;]]></script>
+</div></div><h3 
id="JacksonXML-UnmarshallingfromjsontoList&lt;Map&gt;orList&lt;pojo&gt;">Unmarshalling
 from json to List&lt;Map&gt; or List&lt;pojo&gt;</h3><p>If you are using 
Jackson to unmarshal XML to a list of map/pojo, you can now specify this by 
setting&#160;<code>useList="true"</code>&#160;or use 
the&#160;<code>org.apache.camel.component.jacksonxml.ListJacksonXMLDataFormat</code>.
 For example with Java you can do as shown below:</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[JacksonXMLDataFormat format = new 
ListJacksonXMLDataFormat();
+// or
+JacksonXMLDataFormat format = new JacksonXMLDataFormat();
+format.useList();
+// and you can specify the pojo class type also
+format.setUnmarshalType(MyPojo.class);]]></script>
+</div></div><p>And if you use XML DSL then you configure to use list 
using&#160;<code>useList</code>&#160;attribute as shown below:</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[    &lt;dataFormats&gt;
+      &lt;jacksonxml id=&quot;jack&quot; useList=&quot;true&quot;/&gt;
+    &lt;/dataFormats&gt;]]></script>
+</div></div><p>And you can specify the pojo type also</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[    &lt;dataFormats&gt;
+      &lt;jacksonxml id=&quot;jack&quot; useList=&quot;true&quot; 
unmarshalTypeName=&quot;com.foo.MyPojo&quot;/&gt;
+    &lt;/dataFormats&gt;]]></script>
+</div></div><h3 id="JacksonXML-UsingcustomJacksonmodules">Using custom Jackson 
modules</h3><p><strong>Available as of Camel 2.15</strong></p><p>You can use 
custom Jackson modules by specifying the class names of those using the 
moduleClassNames option as shown below.</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[    &lt;dataFormats&gt;
+      &lt;jacksonxml id=&quot;jack&quot; useList=&quot;true&quot; 
unmarshalTypeName=&quot;com.foo.MyPojo&quot; 
moduleClassNames=&quot;com.foo.MyModule,com.foo.MyOtherModule&quot;/&gt;
+    &lt;/dataFormats&gt;]]></script>
+</div></div><p>When using&#160;moduleClassNames then the custom jackson 
modules are not configured, by created using default constructor and used 
as-is. If a custom module needs any custom configuration, then an instance of 
the module can be created and configured, and then use modulesRefs to refer to 
the module as shown below:</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[    &lt;bean id=&quot;myJacksonModule&quot; 
class=&quot;com.foo.MyModule&quot;&gt;
+      ... // configure the module as you want
+    &lt;/bean&gt;
+ 
+    &lt;dataFormats&gt;
+      &lt;jacksonxml id=&quot;json&quot; useList=&quot;true&quot; 
unmarshalTypeName=&quot;com.foo.MyPojo&quot; 
moduleRefs=&quot;myJacksonModule&quot;/&gt;
+    &lt;/dataFormats&gt;]]></script>
+</div></div><p>&#160;Multiple modules can be specified separated by comma, 
such as moduleRefs="myJacksonModule,myOtherModule"</p><h3 
id="JacksonXML-EnablingordisablefeaturesusingJackson">Enabling or disable 
features using Jackson</h3><p>Jackson has a number of features you can enable 
or disable, which its ObjectMapper uses. For example to disable failing on 
unknown properties when marshalling, you can configure this using the 
disableFeatures:</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[ &lt;dataFormats&gt;
+      &lt;jacksonxml id=&quot;json&quot; 
unmarshalTypeName=&quot;com.foo.MyPojo&quot; 
disableFeatures=&quot;FAIL_ON_UNKNOWN_PROPERTIES&quot;/&gt;
+ &lt;/dataFormats&gt;]]></script>
+</div></div><p>You can disable multiple features by separating the values 
using comma. The values for the features must be the name of the enums from 
Jackson from the following enum 
classes</p><ul><li>com.fasterxml.jackson.databind.SerializationFeature</li><li>com.fasterxml.jackson.databind.DeserializationFeature</li><li>com.fasterxml.jackson.databind.MapperFeature</li></ul><p>To
 enable a feature use the enableFeatures options instead.</p><p>From Java code 
you can use the type safe methods from camel-jackson module:</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[JacksonDataFormat df = new 
JacksonDataFormat(MyPojo.class);
+df.disableFeature(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES);
+df.disableFeature(DeserializationFeature.FAIL_ON_NULL_FOR_PRIMITIVES);]]></script>
+</div></div><h3 id="JacksonXML-ConvertingMapstoPOJOusingJackson">Converting 
Maps to POJO using 
Jackson</h3><p>Jackson&#160;<code>ObjectMapper</code>&#160;can be used to 
convert maps to POJO objects. Jackson component comes with the data converter 
that can be used to convert&#160;<code>java.util.Map</code>&#160;instance to 
non-String, non-primitive and non-Number objects.</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[Map&lt;String, Object&gt; invoiceData = new 
HashMap&lt;String, Object&gt;();
+invoiceData.put(&quot;netValue&quot;, 500);
+producerTemplate.sendBody(&quot;direct:mapToInvoice&quot;, invoiceData);
+...
+// Later in the processor
+Invoice invoice = exchange.getIn().getBody(Invoice.class);]]></script>
+</div></div><p>If there is a 
single&#160;<code>ObjectMapper</code>&#160;instance available in the Camel 
registry, it will used by the converter to perform the conversion. Otherwise 
the default mapper will be used. &#160;</p><h3 
id="JacksonXML-FormattedXMLmarshalling(pretty-printing)">Formatted XML 
marshalling (pretty-printing)</h3><p>Using 
the&#160;<code>prettyPrint</code>&#160;option&#160;one can output a well 
formatted JSON while marshalling:</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[ &lt;dataFormats&gt;
+      &lt;jacksonxml id=&quot;jack&quot; prettyPrint=&quot;true&quot;/&gt;
+ &lt;/dataFormats&gt;]]></script>
+</div></div><p><span>And in Java DSL:</span></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[from(&quot;direct:inPretty&quot;).marshal().jacksonxml(true);]]></script>
+</div></div><p><span>Please note that as of Camel 2.16 there are 5 different 
overloaded&#160;<code>jacksonxml()</code>&#160;DSL methods which support 
the&#160;<code>prettyPrint</code>&#160;option in combination with other 
settings 
for&#160;<code>unmarshalType</code>,&#160;<code>jsonView</code>&#160;etc.&#160;</span></p><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 &amp; 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[&lt;dependency&gt;
   &lt;groupId&gt;org.apache.camel&lt;/groupId&gt;
   &lt;artifactId&gt;camel-jacksonxml&lt;/artifactId&gt;


Reply via email to