Modified: websites/production/camel/content/hawtdb.html
==============================================================================
--- websites/production/camel/content/hawtdb.html (original)
+++ websites/production/camel/content/hawtdb.html Fri Aug 25 09:20:43 2017
@@ -36,17 +36,6 @@
<![endif]-->
- <link href='//camel.apache.org/styles/highlighter/styles/shCoreCamel.css'
rel='stylesheet' type='text/css' />
- <link href='//camel.apache.org/styles/highlighter/styles/shThemeCamel.css'
rel='stylesheet' type='text/css' />
- <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;
- SyntaxHighlighter.all();
- </script>
<title>
Apache Camel: HawtDB
@@ -91,13 +80,13 @@
<p><a shape="rect" class="external-link" href="http://hawtdb.fusesource.org/"
rel="nofollow">HawtDB</a> is a very lightweight and embedable key value
database. It allows together with Camel to provide persistent support for
various Camel features such as <a shape="rect"
href="aggregator2.html">Aggregator</a>. </p>
-<div class="confluence-information-macro
confluence-information-macro-information"><p class="title">Deprecated</p><span
class="aui-icon aui-icon-small aui-iconfont-info
confluence-information-macro-icon"></span><div
class="confluence-information-macro-body">
+<parameter ac:name="title">Deprecated</parameter><rich-text-body>
<p>The <a shape="rect" class="external-link"
href="http://hawtdb.fusesource.org/" rel="nofollow">HawtDB</a> project is
being deprecated and replaced by <a shape="rect" class="external-link"
href="https://code.google.com/p/leveldb/" rel="nofollow">leveldb</a> as the
lightweight and embedable key value database. To make using leveldb easy there
is a <a shape="rect" class="external-link"
href="https://github.com/fusesource/leveldbjni" rel="nofollow">leveldbjni</a>
project for that. The Apache ActiveMQ project is planning on using leveldb as
their primary file based message store in the future, to replace kahadb.</p>
-<p>There os a <a shape="rect" href="leveldb.html">camel-leveldb</a> component
we recommend to use instead of this.</p></div></div>
+<p>There os a <a shape="rect" href="leveldb.html">camel-leveldb</a> component
we recommend to use instead of this.</p></rich-text-body>
-<div class="confluence-information-macro
confluence-information-macro-warning"><p class="title">Issue with HawtDB 1.4 or
older</p><span class="aui-icon aui-icon-small aui-iconfont-error
confluence-information-macro-icon"></span><div
class="confluence-information-macro-body">
-<p>There is a bug in HawtDB 1.4 or older which means the filestore will not
free unused space. That means the file keeps growing. This has been fixed in
HawtDB 1.5 which is shipped with Camel 2.5 onwards.</p></div></div>
+<parameter ac:name="title">Issue with HawtDB 1.4 or
older</parameter><rich-text-body>
+<p>There is a bug in HawtDB 1.4 or older which means the filestore will not
free unused space. That means the file keeps growing. This has been fixed in
HawtDB 1.5 which is shipped with Camel 2.5 onwards.</p></rich-text-body>
<p>Current features it provides:</p>
@@ -133,56 +122,12 @@
<h4 id="HawtDB-UsingHawtDBAggregationRepositoryinJavaDSL">Using
HawtDBAggregationRepository in Java DSL</h4>
<p>In this example we want to persist aggregated messages in the
<code>target/data/hawtdb.dat</code> file.</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 void configure() throws Exception {
- // create the hawtdb repo
- HawtDBAggregationRepository repo = new
HawtDBAggregationRepository("repo1",
"target/data/hawtdb.dat");
-
- // here is the Camel route where we aggregate
- from("direct:start")
- .aggregate(header("id"), new MyAggregationStrategy())
- // use our created hawtdb repo as aggregation repository
- .completionSize(5).aggregationRepository(repo)
- .to("mock:aggregated");
-}
-]]></script>
-</div></div>
+<plain-text-body>{snippet:id=e1|lang=java|url=camel/trunk/components/camel-hawtdb/src/test/java/org/apache/camel/component/hawtdb/HawtDBAggregateTest.java}</plain-text-body>
<h4 id="HawtDB-UsingHawtDBAggregationRepositoryinSpringXML">Using
HawtDBAggregationRepository in Spring XML</h4>
<p>The same example but using Spring XML instead:</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[
-
-<!-- a persistent aggregation repository using camel-hawtdb -->
-<bean id="repo"
class="org.apache.camel.component.hawtdb.HawtDBAggregationRepository">
- <!-- store the repo in the hawtdb.dat file -->
- <property name="persistentFileName"
value="target/data/hawtdb.dat"/>
- <!-- and use repo2 as the repository name -->
- <property name="repositoryName" value="repo2"/>
-</bean>
-
-<!-- aggregate the messages using this strategy -->
-<bean id="myAggregatorStrategy"
class="org.apache.camel.component.hawtdb.HawtDBSpringAggregateTest$MyAggregationStrategy"/>
-
-<!-- this is the camel routes -->
-<camelContext id="camel"
xmlns="http://camel.apache.org/schema/spring">
-
- <route>
- <from uri="direct:start"/>
- <!-- aggregate using our strategy and hawtdb repo, and complete
when we have 5 messages aggregated -->
- <aggregate strategyRef="myAggregatorStrategy"
aggregationRepositoryRef="repo" completionSize="5">
- <!-- correlate by header with the key id -->
-
<correlationExpression><header>id</header></correlationExpression>
- <!-- send aggregated messages to the mock endpoint -->
- <to uri="mock:aggregated"/>
- </aggregate>
- </route>
-
-</camelContext>
-]]></script>
-</div></div>
+<plain-text-body>{snippet:id=e1|lang=xml|url=camel/trunk/components/camel-hawtdb/src/test/resources/org/apache/camel/component/hawtdb/HawtDBSpringAggregateTest.xml}</plain-text-body>
<h3 id="HawtDB-Dependencies">Dependencies</h3>
@@ -190,19 +135,16 @@ public void configure() throws Exception
<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[
+<parameter ac:name="">xml</parameter><plain-text-body>
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-hawtdb</artifactId>
<version>2.3.0</version>
</dependency>
-]]></script>
-</div></div>
+</plain-text-body>
-<h3 id="HawtDB-SeeAlso">See Also</h3>
-<ul><li><a shape="rect" href="configuring-camel.html">Configuring
Camel</a></li><li><a shape="rect"
href="component.html">Component</a></li><li><a shape="rect"
href="endpoint.html">Endpoint</a></li><li><a shape="rect"
href="getting-started.html">Getting Started</a></li></ul>
+<parameter ac:name=""><a shape="rect" href="endpoint-see-also.html">Endpoint
See Also</a></parameter>
<ul class="alternate"><li><a shape="rect"
href="aggregator2.html">Aggregator</a></li><li><a shape="rect"
href="components.html">Components</a></li></ul></div>
</td>
<td valign="top">
Modified: websites/production/camel/content/jasypt.html
==============================================================================
--- websites/production/camel/content/jasypt.html (original)
+++ websites/production/camel/content/jasypt.html Fri Aug 25 09:20:43 2017
@@ -36,17 +36,6 @@
<![endif]-->
- <link href='//camel.apache.org/styles/highlighter/styles/shCoreCamel.css'
rel='stylesheet' type='text/css' />
- <link href='//camel.apache.org/styles/highlighter/styles/shThemeCamel.css'
rel='stylesheet' type='text/css' />
- <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;
- SyntaxHighlighter.all();
- </script>
<title>
Apache Camel: Jasypt
@@ -86,176 +75,115 @@
<tbody>
<tr>
<td valign="top" width="100%">
-<div class="wiki-content maincontent"><h2 id="Jasypt-Jasyptcomponent">Jasypt
component</h2><p><strong>Available as of Camel 2.5</strong></p><p><a
shape="rect" class="external-link" href="http://www.jasypt.org/"
rel="nofollow">Jasypt</a> is a simplified encryption library which makes
encryption and decryption easy. Camel integrates with Jasypt to allow sensitive
information in <a shape="rect" href="properties.html">Properties</a> files to
be encrypted. By dropping <strong><code>camel-jasypt</code></strong> on the
classpath those encrypted values will automatically be decrypted on-the-fly by
Camel. This ensures that human eyes can't easily spot sensitive information
such as usernames and passwords.</p><p>Maven users will need to add the
following dependency to their <code>pom.xml</code> for this component:</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>
+<div class="wiki-content maincontent"><h2 id="Jasypt-Jasyptcomponent">Jasypt
component</h2><p><strong>Available as of Camel 2.5</strong></p><p><a
shape="rect" class="external-link" href="http://www.jasypt.org/"
rel="nofollow">Jasypt</a> is a simplified encryption library which makes
encryption and decryption easy. Camel integrates with Jasypt to allow sensitive
information in <a shape="rect" href="properties.html">Properties</a> files to
be encrypted. By dropping <strong><code>camel-jasypt</code></strong> on the
classpath those encrypted values will automatically be decrypted on-the-fly by
Camel. This ensures that human eyes can't easily spot sensitive information
such as usernames and passwords.</p><p>Maven users will need to add the
following dependency to their <code>pom.xml</code> for this
component:</p><parameter
ac:name="">xml</parameter><plain-text-body><dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-jasypt</artifactId>
<version>x.x.x</version>
<!-- use the same version as your Camel core version -->
</dependency>
-]]></script>
-</div></div><h3 id="Jasypt-Tooling">Tooling</h3><p>The <a shape="rect"
href="jasypt.html">Jasypt</a> component provides a little command line tooling
to encrypt or decrypt values.</p><p>The console output the syntax and which
options it provides:</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[Apache Camel Jasypt takes the following
options
+</plain-text-body><h3 id="Jasypt-Tooling">Tooling</h3><p>The <a shape="rect"
href="jasypt.html">Jasypt</a> component provides a little command line tooling
to encrypt or decrypt values.</p><p>The console output the syntax and which
options it provides:</p><plain-text-body>Apache Camel Jasypt takes the
following options
-h or -help = Displays the help screen
-c or -command <command> = Command either encrypt or decrypt
-p or -password <password> = Password to use
-i or -input <input> = Text to encrypt or decrypt
-a or -algorithm <algorithm> = Optional algorithm to use
-]]></script>
-</div></div><p>For example to encrypt the value <code>tiger</code> you run
with the following parameters. In the apache camel kit, you cd into the lib
folder and run the following java cmd, where <em><CAMEL_HOME></em> is
where you have downloaded and extract the Camel distribution.</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[$ cd <CAMEL_HOME>/lib
+</plain-text-body><p>For example to encrypt the value <code>tiger</code> you
run with the following parameters. In the apache camel kit, you cd into the lib
folder and run the following java cmd, where <em><CAMEL_HOME></em> is
where you have downloaded and extract the Camel
distribution.</p><plain-text-body>$ cd <CAMEL_HOME>/lib
$ java -jar camel-jasypt-2.5.0.jar -c encrypt -p secret -i tiger
-]]></script>
-</div></div><p>Which outputs the following result</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[Encrypted text: qaEEacuW7BUti8LcMgyjKw==
-]]></script>
-</div></div><p>This means the encrypted representation
<code>qaEEacuW7BUti8LcMgyjKw==</code> can be decrypted back to
<code>tiger</code> if you know the master password which was
<code>secret</code>.<br clear="none"> If you run the tool again then the
encrypted value will return a different result. But decrypting the value will
always return the correct original value.</p><p>So you can test it by running
the tooling using the following parameters:</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[$ cd <CAMEL_HOME>/lib
+</plain-text-body><p>Which outputs the following
result</p><plain-text-body>Encrypted text: qaEEacuW7BUti8LcMgyjKw==
+</plain-text-body><p>This means the encrypted representation
<code>qaEEacuW7BUti8LcMgyjKw==</code> can be decrypted back to
<code>tiger</code> if you know the master password which was
<code>secret</code>.<br clear="none"> If you run the tool again then the
encrypted value will return a different result. But decrypting the value will
always return the correct original value.</p><p>So you can test it by running
the tooling using the following parameters:</p><plain-text-body>$ cd
<CAMEL_HOME>/lib
$ java -jar camel-jasypt-2.5.0.jar -c decrypt -p secret -i
qaEEacuW7BUti8LcMgyjKw==
-]]></script>
-</div></div><p>Which outputs the following result:</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[Decrypted text: tiger
-]]></script>
-</div></div><p>The idea is then to use those encrypted values in your <a
shape="rect" href="properties.html">Properties</a> files. Notice how the
password value is encrypted and the value has the tokens surrounding
<code>ENC(value here)</code></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[
-# refer to a mock endpoint name by that encrypted password
-cool.result=mock:{{cool.password}}
-
-# here is a password which is encrypted
-cool.password=ENC(bsW9uV37gQ0QHFu7KO03Ww==)
-]]></script>
-</div></div><h4 id="Jasypt-ToolingdependenciesforCamel2.5and2.6">Tooling
dependencies for Camel 2.5 and 2.6</h4><p>The tooling requires the following
JARs in the classpath, which has been enlisted in the <code>MANIFEST.MF</code>
file of <code>camel-jasypt</code> with <code>optional/</code> as prefix. Hence
why the java cmd above can pickup the needed JARs from the Apache Distribution
in the <code>optional</code> directory.</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[jasypt-1.6.jar commons-lang-2.4.jar
commons-codec-1.4.jar icu4j-4.0.1.jar
-]]></script>
-</div></div><div class="confluence-information-macro
confluence-information-macro-information"><p class="title">Java 1.5
users</p><span class="aui-icon aui-icon-small aui-iconfont-info
confluence-information-macro-icon"></span><div
class="confluence-information-macro-body"><p>The <code>icu4j-4.0.1.jar</code>
is only needed when running on JDK 1.5.</p><p>This JAR is not distributed by
Apache Camel and you have to download it manually and copy it to the
<code>lib/optional</code> directory of the Camel distribution.<br clear="none">
You can download it from <a shape="rect" class="external-link"
href="http://repo2.maven.org/maven2/com/ibm/icu/icu4j/4.0.1/"
rel="nofollow">Apache Central Maven repo</a>.</p></div></div><h4
id="Jasypt-ToolingdependenciesforCamel2.7orbetter">Tooling dependencies for
Camel 2.7 or better</h4><p>Jasypt 1.7 onwards is now fully standalone so no
additional JARs is needed.</p><h3 id="Jasypt-URIOptions">URI Options</h3><p>The
options below are exclusive for the <a
shape="rect" href="jasypt.html">Jasypt</a> component.</p><div
class="confluenceTableSmall">
+</plain-text-body><p>Which outputs the following
result:</p><plain-text-body>Decrypted text: tiger
+</plain-text-body><p>The idea is then to use those encrypted values in your <a
shape="rect" href="properties.html">Properties</a> files. Notice how the
password value is encrypted and the value has the tokens surrounding
<code>ENC(value
here)</code></p><plain-text-body>{snippet:id=e1|lang=java|url=camel/trunk/components/camel-jasypt/src/test/resources/org/apache/camel/component/jasypt/myproperties.properties}</plain-text-body><h4
id="Jasypt-ToolingdependenciesforCamel2.5and2.6">Tooling dependencies for
Camel 2.5 and 2.6</h4><p>The tooling requires the following JARs in the
classpath, which has been enlisted in the <code>MANIFEST.MF</code> file of
<code>camel-jasypt</code> with <code>optional/</code> as prefix. Hence why the
java cmd above can pickup the needed JARs from the Apache Distribution in the
<code>optional</code> directory.</p><plain-text-body>jasypt-1.6.jar
commons-lang-2.4.jar commons-codec-1.4.jar icu4j-4.0.1.jar
+</plain-text-body><parameter ac:name="title">Java 1.5
users</parameter><rich-text-body><p>The <code>icu4j-4.0.1.jar</code> is only
needed when running on JDK 1.5.</p><p>This JAR is not distributed by Apache
Camel and you have to download it manually and copy it to the
<code>lib/optional</code> directory of the Camel distribution.<br clear="none">
You can download it from <a shape="rect" class="external-link"
href="http://repo2.maven.org/maven2/com/ibm/icu/icu4j/4.0.1/"
rel="nofollow">Apache Central Maven repo</a>.</p></rich-text-body><h4
id="Jasypt-ToolingdependenciesforCamel2.7orbetter">Tooling dependencies for
Camel 2.7 or better</h4><p>Jasypt 1.7 onwards is now fully standalone so no
additional JARs is needed.</p><h3 id="Jasypt-URIOptions">URI Options</h3><p>The
options below are exclusive for the <a shape="rect"
href="jasypt.html">Jasypt</a> component.</p><parameter
ac:name="class">confluenceTableSmall</parameter><rich-text-body>
<div class="table-wrap"><table class="confluenceTable"><tbody><tr><th
colspan="1" rowspan="1" class="confluenceTh"><p> Name </p></th><th colspan="1"
rowspan="1" class="confluenceTh"><p> Default Value </p></th><th colspan="1"
rowspan="1" class="confluenceTh"><p> Type </p></th><th colspan="1" rowspan="1"
class="confluenceTh"><p> Description </p></th></tr><tr><td colspan="1"
rowspan="1" class="confluenceTd"><p> <code>password</code> </p></td><td
colspan="1" rowspan="1" class="confluenceTd"><p> <code>null</code> </p></td><td
colspan="1" rowspan="1" class="confluenceTd"><p> <code>String</code>
</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p> Specifies the
master password to use for decrypting. This option is mandatory. See below for
more details. </p></td></tr><tr><td colspan="1" rowspan="1"
class="confluenceTd"><p> <code>algorithm</code> </p></td><td colspan="1"
rowspan="1" class="confluenceTd"><p> <code>null</code> </p></td><td colspan="1"
rowspan="1" class="confluenceTd">
<p> <code>String</code> </p></td><td colspan="1" rowspan="1"
class="confluenceTd"><p> Name of an optional algorithm to use.
</p></td></tr></tbody></table></div>
-</div>
-
-
-<h3 id="Jasypt-Protectingthemasterpassword">Protecting the master
password</h3><p>The master password used by <a shape="rect"
href="jasypt.html">Jasypt</a> must be provided, so that it's capable of
decrypting the values. However having this master password out in the open may
not be an ideal solution. Therefore you could for example provide it as a JVM
system property or as a OS environment setting. If you decide to do so then the
<code>password</code> option supports prefixes which dictates this.
<code>sysenv:</code> means to lookup the OS system environment with the given
key. <code>sys:</code> means to lookup a JVM system property.</p><p>For example
you could provided the password before you start the application</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[$ export CAMEL_ENCRYPTION_PASSWORD=secret
-]]></script>
-</div></div><p>Then start the application, such as running the start
script.</p><p>When the application is up and running you can unset the
environment</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[$ unset CAMEL_ENCRYPTION_PASSWORD
-]]></script>
-</div></div><p>The <code>password</code> option is then a matter of defining
as follows: <code>password=sysenv:CAMEL_ENCRYPTION_PASSWORD</code>.</p><h3
id="Jasypt-ExamplewithJavaDSL">Example with Java DSL</h3><p>In Java DSL you
need to configure <a shape="rect" href="jasypt.html">Jasypt</a> as a
<code>JasyptPropertiesParser</code> instance and set it on the <a shape="rect"
href="properties.html">Properties</a> component as show 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[
-// create the jasypt properties parser
-JasyptPropertiesParser jasypt = new JasyptPropertiesParser();
-// and set the master password
-jasypt.setPassword("secret");
-
-// create the properties component
-PropertiesComponent pc = new PropertiesComponent();
-pc.setLocation("classpath:org/apache/camel/component/jasypt/myproperties.properties");
-// and use the jasypt properties parser so we can decrypt values
-pc.setPropertiesParser(jasypt);
-
-// add properties component to camel context
-context.addComponent("properties", pc);
-]]></script>
-</div></div><p>The properties file <code>myproperties.properties</code> then
contain the encrypted value, such as shown below. Notice how the password value
is encrypted and the value has the tokens surrounding <code>ENC(value
here)</code></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[
-# refer to a mock endpoint name by that encrypted password
-cool.result=mock:{{cool.password}}
-
-# here is a password which is encrypted
-cool.password=ENC(bsW9uV37gQ0QHFu7KO03Ww==)
-]]></script>
-</div></div><h3 id="Jasypt-ExamplewithSpringXML">Example with Spring
XML</h3><p>In Spring XML you need to configure the
<code>JasyptPropertiesParser</code> which is shown below. Then the Camel <a
shape="rect" href="properties.html">Properties</a> component is told to use
<code>jasypt</code> as the properties parser, which means <a shape="rect"
href="jasypt.html">Jasypt</a> has its chance to decrypt values looked up in the
properties.</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[<!-- define the jasypt properties parser
with the given password to be used -->
-<bean id="jasypt"
class="org.apache.camel.component.jasypt.JasyptPropertiesParser">
- <property name="password" value="secret"/>
+</rich-text-body><h3 id="Jasypt-Protectingthemasterpassword">Protecting the
master password</h3><p>The master password used by <a shape="rect"
href="jasypt.html">Jasypt</a> must be provided, so that it's capable of
decrypting the values. However having this master password out in the open may
not be an ideal solution. Therefore you could for example provide it as a JVM
system property or as a OS environment setting. If you decide to do so then the
<code>password</code> option supports prefixes which dictates this.
<code>sysenv:</code> means to lookup the OS system environment with the given
key. <code>sys:</code> means to lookup a JVM system property.</p><p>For example
you could provided the password before you start the
application</p><plain-text-body>$ export CAMEL_ENCRYPTION_PASSWORD=secret
+</plain-text-body><p>Then start the application, such as running the start
script.</p><p>When the application is up and running you can unset the
environment</p><plain-text-body>$ unset CAMEL_ENCRYPTION_PASSWORD
+</plain-text-body><p>The <code>password</code> option is then a matter of
defining as follows:
<code>password=sysenv:CAMEL_ENCRYPTION_PASSWORD</code>.</p><h3
id="Jasypt-ExamplewithJavaDSL">Example with Java DSL</h3><p>In Java DSL you
need to configure <a shape="rect" href="jasypt.html">Jasypt</a> as a
<code>JasyptPropertiesParser</code> instance and set it on the <a shape="rect"
href="properties.html">Properties</a> component as show
below:</p><plain-text-body>{snippet:id=e1|lang=java|url=camel/trunk/components/camel-jasypt/src/test/java/org/apache/camel/component/jasypt/JasyptPropertiesTest.java}</plain-text-body><p>The
properties file <code>myproperties.properties</code> then contain the
encrypted value, such as shown below. Notice how the password value is
encrypted and the value has the tokens surrounding <code>ENC(value
here)</code></p><plain-text-body>{snippet:id=e1|lang=java|url=camel/trunk/components/camel-jasypt/src/test/resources/org/apache/camel/component/jasypt/mypropert
ies.properties}</plain-text-body><h3 id="Jasypt-ExamplewithSpringXML">Example
with Spring XML</h3><p>In Spring XML you need to configure the
<code>JasyptPropertiesParser</code> which is shown below. Then the Camel <a
shape="rect" href="properties.html">Properties</a> component is told to use
<code>jasypt</code> as the properties parser, which means <a shape="rect"
href="jasypt.html">Jasypt</a> has its chance to decrypt values looked up in the
properties.</p><parameter
ac:name="language">xml</parameter><plain-text-body><!-- define the jasypt
properties parser with the given password to be used -->
+<bean id="jasypt"
class="org.apache.camel.component.jasypt.JasyptPropertiesParser">
+ <property name="password" value="secret"/>
</bean>
<!-- define the camel properties component -->
-<bean id="properties"
class="org.apache.camel.component.properties.PropertiesComponent">
+<bean id="properties"
class="org.apache.camel.component.properties.PropertiesComponent">
<!-- the properties file is in the classpath -->
- <property name="location"
value="classpath:org/apache/camel/component/jasypt/myproperties.properties"/>
+ <property name="location"
value="classpath:org/apache/camel/component/jasypt/myproperties.properties"/>
<!-- and let it leverage the jasypt parser -->
- <property name="propertiesParser" ref="jasypt"/>
+ <property name="propertiesParser" ref="jasypt"/>
</bean>
-]]></script>
-</div></div><p>The <a shape="rect" href="properties.html">Properties</a>
component can also be inlined inside the <code><camelContext></code> tag
which is shown below. Notice how we use the <code>propertiesParserRef</code>
attribute to refer to <a shape="rect" href="jasypt.html">Jasypt</a>.</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[<!-- define the jasypt properties parser
with the given password to be used -->
-<bean id="jasypt"
class="org.apache.camel.component.jasypt.JasyptPropertiesParser">
+</plain-text-body><p>The <a shape="rect" href="properties.html">Properties</a>
component can also be inlined inside the <code><camelContext></code> tag
which is shown below. Notice how we use the <code>propertiesParserRef</code>
attribute to refer to <a shape="rect"
href="jasypt.html">Jasypt</a>.</p><plain-text-body><!-- define the jasypt
properties parser with the given password to be used -->
+<bean id="jasypt"
class="org.apache.camel.component.jasypt.JasyptPropertiesParser">
<!-- password is mandatory, you can prefix it with sysenv: or sys: to
indicate it should use
an OS environment or JVM system property value, so you dont have the
master password defined here -->
- <property name="password" value="secret"/>
+ <property name="password" value="secret"/>
</bean>
-<camelContext xmlns="http://camel.apache.org/schema/spring">
+<camelContext xmlns="http://camel.apache.org/schema/spring">
<!-- define the camel properties placeholder, and let it leverage
jasypt -->
- <propertyPlaceholder id="properties"
-
location="classpath:org/apache/camel/component/jasypt/myproperties.properties"
- propertiesParserRef="jasypt"/>
+ <propertyPlaceholder id="properties"
+
location="classpath:org/apache/camel/component/jasypt/myproperties.properties"
+ propertiesParserRef="jasypt"/>
<route>
- <from uri="direct:start"/>
- <to uri="{{cool.result}}"/>
+ <from uri="direct:start"/>
+ <to uri="{{cool.result}}"/>
</route>
</camelContext>
-]]></script>
-</div></div><h3 id="Jasypt-ExamplewithBlueprintXML">Example with Blueprint
XML</h3><p>In Blueprint XML you need to configure
the <code>JasyptPropertiesParser</code> which is shown below. Then
the Camel <a shape="rect"
href="properties.html">Properties</a> component is told to
use <code>jasypt</code> as the properties parser, which means <a
shape="rect" href="jasypt.html">Jasypt</a> has its chance to decrypt
values looked up in the properties.</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[<blueprint
xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-
xmlns:cm="http://aries.apache.org/blueprint/xmlns/blueprint-cm/v1.0.0"
- xsi:schemaLocation="
- http://www.osgi.org/xmlns/blueprint/v1.0.0
http://www.osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd">
+</plain-text-body><h3 id="Jasypt-ExamplewithBlueprintXML">Example with
Blueprint XML</h3><p>In Blueprint XML you need to configure
the <code>JasyptPropertiesParser</code> which is shown below. Then
the Camel <a shape="rect"
href="properties.html">Properties</a> component is told to
use <code>jasypt</code> as the properties parser, which means <a
shape="rect" href="jasypt.html">Jasypt</a> has its chance to decrypt
values looked up in the properties.</p><parameter
ac:name="language">xml</parameter><plain-text-body><blueprint
xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+
xmlns:cm="http://aries.apache.org/blueprint/xmlns/blueprint-cm/v1.0.0"
+ xsi:schemaLocation="
+ http://www.osgi.org/xmlns/blueprint/v1.0.0
http://www.osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd">
- <cm:property-placeholder id="myblue"
persistent-id="mypersistent">
+ <cm:property-placeholder id="myblue" persistent-id="mypersistent">
<!-- list some properties for this test -->
<cm:default-properties>
- <cm:property name="cool.result"
value="mock:{{cool.password}}"/>
- <cm:property name="cool.password"
value="ENC(bsW9uV37gQ0QHFu7KO03Ww==)"/>
+ <cm:property name="cool.result"
value="mock:{{cool.password}}"/>
+ <cm:property name="cool.password"
value="ENC(bsW9uV37gQ0QHFu7KO03Ww==)"/>
</cm:default-properties>
</cm:property-placeholder>
<!-- define the jasypt properties parser with the given password to be
used -->
- <bean id="jasypt"
class="org.apache.camel.component.jasypt.JasyptPropertiesParser">
- <property name="password" value="secret"/>
+ <bean id="jasypt"
class="org.apache.camel.component.jasypt.JasyptPropertiesParser">
+ <property name="password" value="secret"/>
</bean>
- <camelContext
xmlns="http://camel.apache.org/schema/blueprint">
+ <camelContext xmlns="http://camel.apache.org/schema/blueprint">
<!-- define the camel properties placeholder, and let it leverage
jasypt -->
- <propertyPlaceholder id="properties"
- location="blueprint:myblue"
- propertiesParserRef="jasypt"/>
+ <propertyPlaceholder id="properties"
+ location="blueprint:myblue"
+ propertiesParserRef="jasypt"/>
<route>
- <from uri="direct:start"/>
- <to uri="{{cool.result}}"/>
+ <from uri="direct:start"/>
+ <to uri="{{cool.result}}"/>
</route>
</camelContext>
</blueprint>
-]]></script>
-</div></div><p>The <a shape="rect"
href="properties.html">Properties</a> component can also be inlined inside
the <code><camelContext></code> tag which is shown below.
Notice how we use the <code>propertiesParserRef</code> attribute to
refer to <a shape="rect" href="jasypt.html">Jasypt</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[<blueprint
xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-
xmlns:cm="http://aries.apache.org/blueprint/xmlns/blueprint-cm/v1.0.0"
- xsi:schemaLocation="
- http://www.osgi.org/xmlns/blueprint/v1.0.0
http://www.osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd">
+</plain-text-body><p>The <a shape="rect"
href="properties.html">Properties</a> component can also be inlined inside
the <code><camelContext></code> tag which is shown below.
Notice how we use the <code>propertiesParserRef</code> attribute to
refer to <a shape="rect" href="jasypt.html">Jasypt</a>.</p><parameter
ac:name="language">xml</parameter><plain-text-body><blueprint
xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+
xmlns:cm="http://aries.apache.org/blueprint/xmlns/blueprint-cm/v1.0.0"
+ xsi:schemaLocation="
+ http://www.osgi.org/xmlns/blueprint/v1.0.0
http://www.osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd">
<!-- define the jasypt properties parser with the given password to be
used -->
- <bean id="jasypt"
class="org.apache.camel.component.jasypt.JasyptPropertiesParser">
- <property name="password" value="secret"/>
+ <bean id="jasypt"
class="org.apache.camel.component.jasypt.JasyptPropertiesParser">
+ <property name="password" value="secret"/>
</bean>
- <camelContext
xmlns="http://camel.apache.org/schema/blueprint">
+ <camelContext xmlns="http://camel.apache.org/schema/blueprint">
<!-- define the camel properties placeholder, and let it leverage
jasypt -->
- <propertyPlaceholder id="properties"
-
location="classpath:org/apache/camel/component/jasypt/myproperties.properties"
- propertiesParserRef="jasypt"/>
+ <propertyPlaceholder id="properties"
+
location="classpath:org/apache/camel/component/jasypt/myproperties.properties"
+ propertiesParserRef="jasypt"/>
<route>
- <from uri="direct:start"/>
- <to uri="{{cool.result}}"/>
+ <from uri="direct:start"/>
+ <to uri="{{cool.result}}"/>
</route>
</camelContext>
</blueprint>
-]]></script>
-</div></div><p> </p><h3 id="Jasypt-SeeAlso">See Also</h3><ul
class="alternate"><li><a shape="rect"
href="security.html">Security</a></li><li><a shape="rect"
href="properties.html">Properties</a></li><li><a shape="rect"
class="external-link"
href="http://activemq.apache.org/encrypted-passwords.html">Encrypted passwords
in ActiveMQ</a> - ActiveMQ has a similar feature as this
<code>camel-jasypt</code> component</li></ul></div>
+</plain-text-body><p> </p><h3 id="Jasypt-SeeAlso">See Also</h3><ul
class="alternate"><li><a shape="rect"
href="security.html">Security</a></li><li><a shape="rect"
href="properties.html">Properties</a></li><li><a shape="rect"
class="external-link"
href="http://activemq.apache.org/encrypted-passwords.html">Encrypted passwords
in ActiveMQ</a> - ActiveMQ has a similar feature as this
<code>camel-jasypt</code> component</li></ul></div>
</td>
<td valign="top">
<div class="navigation">
Modified: websites/production/camel/content/jaxb.html
==============================================================================
--- websites/production/camel/content/jaxb.html (original)
+++ websites/production/camel/content/jaxb.html Fri Aug 25 09:20:43 2017
@@ -36,17 +36,6 @@
<![endif]-->
- <link href='//camel.apache.org/styles/highlighter/styles/shCoreCamel.css'
rel='stylesheet' type='text/css' />
- <link href='//camel.apache.org/styles/highlighter/styles/shThemeCamel.css'
rel='stylesheet' type='text/css' />
- <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;
- SyntaxHighlighter.all();
- </script>
<title>
Apache Camel: JAXB
@@ -86,136 +75,45 @@
<tbody>
<tr>
<td valign="top" width="100%">
-<div class="wiki-content maincontent"><h2 id="JAXB-JAXB">JAXB</h2><p>JAXB is a
<a shape="rect" href="data-format.html">Data Format</a> which uses the JAXB2
XML marshalling standard which is included in Java 6 to unmarshal an XML
payload into Java objects or to marshal Java objects into an XML
payload.</p><h3 id="JAXB-UsingtheJavaDSL">Using the Java DSL</h3><p>For example
the following uses a named DataFormat of <em>jaxb</em> which is configured with
a number of Java package names to initialize the <a shape="rect"
class="external-link"
href="http://java.sun.com/javase/6/docs/api/javax/xml/bind/JAXBContext.html"
rel="nofollow">JAXBContext</a>.</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[DataFormat jaxb = new
JaxbDataFormat("com.acme.model");
+<div class="wiki-content maincontent"><h2 id="JAXB-JAXB">JAXB</h2><p>JAXB is a
<a shape="rect" href="data-format.html">Data Format</a> which uses the JAXB2
XML marshalling standard which is included in Java 6 to unmarshal an XML
payload into Java objects or to marshal Java objects into an XML
payload.</p><h3 id="JAXB-UsingtheJavaDSL">Using the Java DSL</h3><p>For example
the following uses a named DataFormat of <em>jaxb</em> which is configured with
a number of Java package names to initialize the <a shape="rect"
class="external-link"
href="http://java.sun.com/javase/6/docs/api/javax/xml/bind/JAXBContext.html"
rel="nofollow">JAXBContext</a>.</p><plain-text-body>DataFormat jaxb = new
JaxbDataFormat("com.acme.model");
-from("activemq:My.Queue").
+from("activemq:My.Queue").
unmarshal(jaxb).
- to("mqseries:Another.Queue");
-]]></script>
-</div></div><p>You can if you prefer use a named reference to a data format
which can then be defined in your <a shape="rect"
href="registry.html">Registry</a> such as via your <a shape="rect"
href="spring.html">Spring</a> XML file. e.g.</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("activemq:My.Queue").
- unmarshal("myJaxbDataType").
- to("mqseries:Another.Queue");
-]]></script>
-</div></div><h3 id="JAXB-UsingSpringXML">Using Spring XML</h3><p>The following
example shows how to use JAXB to unmarshal using <a shape="rect"
href="spring.html">Spring</a> configuring the jaxb data type</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[
-<camelContext id="camel"
xmlns="http://camel.apache.org/schema/spring">
- <route>
- <from uri="direct:start"/>
- <unmarshal>
- <jaxb prettyPrint="true"
contextPath="org.apache.camel.example"/>
- </unmarshal>
- <to uri="mock:result"/>
- </route>
-</camelContext>
-]]></script>
-</div></div>This example shows how to configure the data type just once and
reuse it on multiple routes.<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[
-<camelContext id="camel"
xmlns="http://camel.apache.org/schema/spring">
- <dataFormats>
- <jaxb id="myJaxb" prettyPrint="true"
contextPath="org.apache.camel.example"/>
- </dataFormats>
-
- <route>
- <from uri="direct:start"/>
- <marshal ref="myJaxb"/>
- <to uri="direct:marshalled"/>
- </route>
- <route>
- <from uri="direct:marshalled"/>
- <unmarshal ref="myJaxb"/>
- <to uri="mock:result"/>
- </route>
-
-</camelContext>
-]]></script>
-</div></div><div class="confluence-information-macro
confluence-information-macro-tip"><p class="title">Multiple context
paths</p><span class="aui-icon aui-icon-small aui-iconfont-approve
confluence-information-macro-icon"></span><div
class="confluence-information-macro-body"><p>It is possible to use this data
format with more than one context path. You can specify context path using
<code>:</code> as separator, for example
<code>com.mycompany:com.mycompany2</code>. Note that this is handled by JAXB
implementation and might change if you use different vendor than
RI.</p></div></div><h3 id="JAXB-Partialmarshalling/unmarshalling">Partial
marshalling/unmarshalling</h3><p><strong>This feature is new to Camel
2.2.0.</strong><br clear="none"> JAXB 2 supports marshalling and unmarshalling
XML tree fragments. By default JAXB looks for <code>@XmlRootElement</code>
annotation on given class to operate on whole XML tree. This is useful but not
always - sometimes generated code does not have @X
mlRootElement annotation, sometimes you need unmarshall only part of tree.<br
clear="none"> In that case you can use partial unmarshalling. To enable this
behaviours you need set property <code>partClass</code>. Camel will pass this
class to JAXB's unmarshaler.</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[
-<camelContext id="camel"
xmlns="http://camel.apache.org/schema/spring">
- <route>
- <from uri="direct:marshal"/>
- <marshal>
- <jaxb prettyPrint="false"
contextPath="org.apache.camel.example"
- partClass="org.apache.camel.example.PurchaseOrder"
- fragment="true"
- partNamespace="{http://example.camel.org/apache}po"
/>
- </marshal>
- <to uri="mock:marshal"/>
- </route>
- <route>
- <from uri="direct:unmarshal"/>
- <unmarshal>
- <jaxb prettyPrint="false"
contextPath="org.apache.camel.example"
- partClass="org.apache.camel.example.Partial" />
- </unmarshal>
- <to uri="mock:unmarshal"/>
- </route>
-</camelContext>
-]]></script>
-</div></div>For marshalling you have to add <code>partNamespace</code>
attribute with QName of destination namespace. Example of Spring DSL you can
find above.<h3 id="JAXB-Fragment">Fragment</h3><p><strong>This feature is new
to Camel 2.8.0.</strong><br clear="none"> JaxbDataFormat has new property
fragment which can set the the <code>Marshaller.JAXB_FRAGMENT</code> encoding
property on the JAXB Marshaller. If you don't want the JAXB Marshaller to
generate the XML declaration, you can set this option to be true. The default
value of this property is false.</p><h3
id="JAXB-IgnoringtheNonXMLCharacter">Ignoring the NonXML
Character</h3><p><strong>This feature is new to Camel 2.2.0.</strong><br
clear="none"> JaxbDataFromat supports to ignore the <a shape="rect"
class="external-link"
href="http://www.w3.org/TR/2004/REC-xml-20040204/#NT-Char"
rel="nofollow">NonXML Character</a>, you just need to set the filterNonXmlChars
property to be true, JaxbDataFormat will replace the NonXML characte
r with " " when it is marshaling or unmarshaling the message. You can also do
it by setting the <a shape="rect" href="exchange.html">Exchange</a> property
<code>Exchange.FILTER_NON_XML_CHARS</code>.</p><div class="table-wrap"><table
class="confluenceTable"><tbody><tr><td colspan="1" rowspan="1"
class="confluenceTd"><p> </p></td><th colspan="1" rowspan="1"
class="confluenceTh"><p>JDK 1.5</p></th><th colspan="1" rowspan="1"
class="confluenceTh"><p>JDK 1.6+</p></th></tr><tr><th colspan="1" rowspan="1"
class="confluenceTh"><p>Filtering in use</p></th><td colspan="1" rowspan="1"
class="confluenceTd"><p>StAX API and implementation</p></td><td colspan="1"
rowspan="1" class="confluenceTd"><p>No</p></td></tr><tr><th colspan="1"
rowspan="1" class="confluenceTh"><p>Filtering not in use</p></th><td
colspan="1" rowspan="1" class="confluenceTd"><p>StAX API only</p></td><td
colspan="1" rowspan="1"
class="confluenceTd"><p>No</p></td></tr></tbody></table></div><p>This feature
has been tested wi
th Woodstox 3.2.9 and Sun JDK 1.6 StAX implementation.</p><p><strong>New for
Camel 2.12.1</strong><br clear="none"> JaxbDataFormat now allows you to
customize the XMLStreamWriter used to marshal the stream to XML. Using this
configuration, you can add your own stream writer to completely remove, escape,
or replace non-xml characters.</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[ JaxbDataFormat customWriterFormat = new
JaxbDataFormat("org.apache.camel.foo.bar");
+ to("mqseries:Another.Queue");
+</plain-text-body><p>You can if you prefer use a named reference to a data
format which can then be defined in your <a shape="rect"
href="registry.html">Registry</a> such as via your <a shape="rect"
href="spring.html">Spring</a> XML file.
e.g.</p><plain-text-body>from("activemq:My.Queue").
+ unmarshal("myJaxbDataType").
+ to("mqseries:Another.Queue");
+</plain-text-body><h3 id="JAXB-UsingSpringXML">Using Spring XML</h3><p>The
following example shows how to use JAXB to unmarshal using <a shape="rect"
href="spring.html">Spring</a> configuring the jaxb data
type<plain-text-body>{snippet:id=example|lang=xml|url=camel/trunk/components/camel-jaxb/src/test/resources/org/apache/camel/example/springDataFormat.xml}</plain-text-body>This
example shows how to configure the data type just once and reuse it on
multiple
routes.<plain-text-body>{snippet:id=example|lang=xml|url=camel/trunk/components/camel-jaxb/src/test/resources/org/apache/camel/example/marshalAndUnmarshalWithRef.xml}</plain-text-body></p><parameter
ac:name="title">Multiple context paths</parameter><rich-text-body><p>It is
possible to use this data format with more than one context path. You can
specify context path using <code>:</code> as separator, for example
<code>com.mycompany:com.mycompany2</code>. Note that this is handled by JAXB
implementation and might change if you use
different vendor than RI.</p></rich-text-body><h3
id="JAXB-Partialmarshalling/unmarshalling">Partial
marshalling/unmarshalling</h3><p><strong>This feature is new to Camel
2.2.0.</strong><br clear="none"> JAXB 2 supports marshalling and unmarshalling
XML tree fragments. By default JAXB looks for <code>@XmlRootElement</code>
annotation on given class to operate on whole XML tree. This is useful but not
always - sometimes generated code does not have @XmlRootElement annotation,
sometimes you need unmarshall only part of tree.<br clear="none"> In that case
you can use partial unmarshalling. To enable this behaviours you need set
property <code>partClass</code>. Camel will pass this class to JAXB's
unmarshaler.<plain-text-body>{snippet:id=example|lang=xml|url=camel/trunk/components/camel-jaxb/src/test/resources/org/apache/camel/example/springDataFormatPartial.xml}</plain-text-body>For
marshalling you have to add <code>partNamespace</code> attribute with QName of
destination namespace. E
xample of Spring DSL you can find above.</p><h3
id="JAXB-Fragment">Fragment</h3><p><strong>This feature is new to Camel
2.8.0.</strong><br clear="none"> JaxbDataFormat has new property fragment which
can set the the <code>Marshaller.JAXB_FRAGMENT</code> encoding property on the
JAXB Marshaller. If you don't want the JAXB Marshaller to generate the XML
declaration, you can set this option to be true. The default value of this
property is false.</p><h3 id="JAXB-IgnoringtheNonXMLCharacter">Ignoring the
NonXML Character</h3><p><strong>This feature is new to Camel 2.2.0.</strong><br
clear="none"> JaxbDataFromat supports to ignore the <a shape="rect"
class="external-link"
href="http://www.w3.org/TR/2004/REC-xml-20040204/#NT-Char"
rel="nofollow">NonXML Character</a>, you just need to set the filterNonXmlChars
property to be true, JaxbDataFormat will replace the NonXML character with " "
when it is marshaling or unmarshaling the message. You can also do it by
setting the <a shape="rect" hre
f="exchange.html">Exchange</a> property
<code>Exchange.FILTER_NON_XML_CHARS</code>.</p><div class="table-wrap"><table
class="confluenceTable"><tbody><tr><td colspan="1" rowspan="1"
class="confluenceTd"><p> </p></td><th colspan="1" rowspan="1"
class="confluenceTh"><p>JDK 1.5</p></th><th colspan="1" rowspan="1"
class="confluenceTh"><p>JDK 1.6+</p></th></tr><tr><th colspan="1" rowspan="1"
class="confluenceTh"><p>Filtering in use</p></th><td colspan="1" rowspan="1"
class="confluenceTd"><p>StAX API and implementation</p></td><td colspan="1"
rowspan="1" class="confluenceTd"><p>No</p></td></tr><tr><th colspan="1"
rowspan="1" class="confluenceTh"><p>Filtering not in use</p></th><td
colspan="1" rowspan="1" class="confluenceTd"><p>StAX API only</p></td><td
colspan="1" rowspan="1"
class="confluenceTd"><p>No</p></td></tr></tbody></table></div><p>This feature
has been tested with Woodstox 3.2.9 and Sun JDK 1.6 StAX
implementation.</p><p><strong>New for Camel 2.12.1</strong><br clear="none">
JaxbDataFormat now allows you to customize the XMLStreamWriter used to
marshal the stream to XML. Using this configuration, you can add your own
stream writer to completely remove, escape, or replace non-xml
characters.</p><parameter ac:name="language">java</parameter><plain-text-body>
JaxbDataFormat customWriterFormat = new
JaxbDataFormat("org.apache.camel.foo.bar");
customWriterFormat.setXmlStreamWriterWrapper(new TestXmlStreamWriter());
-]]></script>
-</div></div><p>The following example shows using the Spring DSL and also
enabling Camel's NonXML filtering:</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[<bean
id="testXmlStreamWriterWrapper"
class="org.apache.camel.jaxb.TestXmlStreamWriter"/>
-<jaxb filterNonXmlChars="true"
contextPath="org.apache.camel.foo.bar"
xmlStreamWriterWrapper="#testXmlStreamWriterWrapper" />
-]]></script>
-</div></div><h3 id="JAXB-WorkingwiththeObjectFactory">Working with the
ObjectFactory</h3><p>If you use XJC to create the java class from the schema,
you will get an ObjectFactory for you JAXB context. Since the ObjectFactory
uses <a shape="rect" class="external-link"
href="http://java.sun.com/javase/6/docs/api/javax/xml/bind/JAXBElement.html"
rel="nofollow">JAXBElement</a> to hold the reference of the schema and element
instance value, jaxbDataformat will ignore the JAXBElement by default and you
will get the element instance value instead of the JAXBElement object form the
unmarshaled message body. <br clear="none"> If you want to get the JAXBElement
object form the unmarshaled message body, you need to set the JaxbDataFormat
object's ignoreJAXBElement property to be false.</p><h3
id="JAXB-Settingencoding">Setting encoding</h3><p>You can set the
<strong>encoding</strong> option to use when marshalling. Its the
<code>Marshaller.JAXB_ENCODING</code> encoding property on the JAXB Mars
haller.<br clear="none"> You can setup which encoding to use when you declare
the JAXB data format. You can also provide the encoding in the <a shape="rect"
href="exchange.html">Exchange</a> property <code>Exchange.CHARSET_NAME</code>.
This property will overrule the encoding set on the JAXB data format.</p><p>In
this Spring DSL we have defined to use <code>iso-8859-1</code> as the
encoding:</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[
-<camelContext id="camel"
xmlns="http://camel.apache.org/schema/spring">
- <route>
- <from uri="direct:start"/>
- <marshal>
- <jaxb prettyPrint="false"
encoding="iso-8859-1"
contextPath="org.apache.camel.example"/>
- </marshal>
- <to uri="mock:result"/>
- </route>
-</camelContext>
-]]></script>
-</div></div><h3 id="JAXB-Controllingnamespaceprefixmapping">Controlling
namespace prefix mapping</h3><p><strong>Available as of Camel
2.11</strong></p><p>When marshalling using <a shape="rect"
href="jaxb.html">JAXB</a> or <a shape="rect" href="soap.html">SOAP</a> then the
JAXB implementation will automatic assign namespace prefixes, such as ns2, ns3,
ns4 etc. To control this mapping, Camel allows you to refer to a map which
contains the desired mapping.</p><p>Notice this requires having JAXB-RI 2.1 or
better (from SUN) on the classpath, as the mapping functionality is dependent
on the implementation of JAXB, whether its supported.</p><p>For example in
Spring XML we can define a Map with the mapping. In the mapping file below, we
map SOAP to use soap as prefix. While our custom namespace
"http://www.mycompany.com/foo/2" is not using any prefix.</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[ <util:map id="myMap">
- <entry key="http://www.w3.org/2003/05/soap-envelope"
value="soap"/>
+</plain-text-body><p>The following example shows using the Spring DSL and also
enabling Camel's NonXML filtering:</p><parameter
ac:name="">xml</parameter><plain-text-body><bean
id="testXmlStreamWriterWrapper"
class="org.apache.camel.jaxb.TestXmlStreamWriter"/>
+<jaxb filterNonXmlChars="true" contextPath="org.apache.camel.foo.bar"
xmlStreamWriterWrapper="#testXmlStreamWriterWrapper" />
+</plain-text-body><h3 id="JAXB-WorkingwiththeObjectFactory">Working with the
ObjectFactory</h3><p>If you use XJC to create the java class from the schema,
you will get an ObjectFactory for you JAXB context. Since the ObjectFactory
uses <a shape="rect" class="external-link"
href="http://java.sun.com/javase/6/docs/api/javax/xml/bind/JAXBElement.html"
rel="nofollow">JAXBElement</a> to hold the reference of the schema and element
instance value, jaxbDataformat will ignore the JAXBElement by default and you
will get the element instance value instead of the JAXBElement object form the
unmarshaled message body. <br clear="none"> If you want to get the JAXBElement
object form the unmarshaled message body, you need to set the JaxbDataFormat
object's ignoreJAXBElement property to be false.</p><h3
id="JAXB-Settingencoding">Setting encoding</h3><p>You can set the
<strong>encoding</strong> option to use when marshalling. Its the
<code>Marshaller.JAXB_ENCODING</code> encoding property on the JAX
B Marshaller.<br clear="none"> You can setup which encoding to use when you
declare the JAXB data format. You can also provide the encoding in the <a
shape="rect" href="exchange.html">Exchange</a> property
<code>Exchange.CHARSET_NAME</code>. This property will overrule the encoding
set on the JAXB data format.</p><p>In this Spring DSL we have defined to use
<code>iso-8859-1</code> as the
encoding:<plain-text-body>{snippet:id=example|lang=xml|url=camel/trunk/components/camel-jaxb/src/test/resources/org/apache/camel/example/springDataFormatWithEncoding.xml}</plain-text-body></p><h3
id="JAXB-Controllingnamespaceprefixmapping">Controlling namespace prefix
mapping</h3><p><strong>Available as of Camel 2.11</strong></p><p>When
marshalling using <a shape="rect" href="jaxb.html">JAXB</a> or <a shape="rect"
href="soap.html">SOAP</a> then the JAXB implementation will automatic assign
namespace prefixes, such as ns2, ns3, ns4 etc. To control this mapping, Camel
allows you to refer to a map whic
h contains the desired mapping.</p><p>Notice this requires having JAXB-RI 2.1
or better (from SUN) on the classpath, as the mapping functionality is
dependent on the implementation of JAXB, whether its supported.</p><p>For
example in Spring XML we can define a Map with the mapping. In the mapping file
below, we map SOAP to use soap as prefix. While our custom namespace
"http://www.mycompany.com/foo/2" is not using any prefix.</p><parameter
ac:name="">xml</parameter><plain-text-body> <util:map id="myMap">
+ <entry key="http://www.w3.org/2003/05/soap-envelope" value="soap"/>
<!-- we dont want any prefix for our namespace -->
- <entry key="http://www.mycompany.com/foo/2"
value=""/>
+ <entry key="http://www.mycompany.com/foo/2" value=""/>
</util:map>
-]]></script>
-</div></div><p>To use this in <a shape="rect" href="jaxb.html">JAXB</a> or <a
shape="rect" href="soap.html">SOAP</a> you refer to this map, using the
<code>namespacePrefixRef</code> attribute as shown below. Then Camel will
lookup in the <a shape="rect" href="registry.html">Registry</a> a
<code>java.util.Map</code> with the id "myMap", which was what we defined
above.</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[ <marshal>
- <soapjaxb version="1.2"
contextPath="com.mycompany.foo"
namespacePrefixRef="myMap"/>
+</plain-text-body><p>To use this in <a shape="rect" href="jaxb.html">JAXB</a>
or <a shape="rect" href="soap.html">SOAP</a> you refer to this map, using the
<code>namespacePrefixRef</code> attribute as shown below. Then Camel will
lookup in the <a shape="rect" href="registry.html">Registry</a> a
<code>java.util.Map</code> with the id "myMap", which was what we defined
above.</p><parameter ac:name="">xml</parameter><plain-text-body>
<marshal>
+ <soapjaxb version="1.2" contextPath="com.mycompany.foo"
namespacePrefixRef="myMap"/>
</marshal>
-]]></script>
-</div></div><h3 id="JAXB-Schemavalidation">Schema
validation</h3><p><strong>Available as of Camel 2.11</strong></p><p>The JAXB <a
shape="rect" href="data-format.html">Data Format</a> supports validation by
marshalling and unmarshalling from/to XML. Your can use the prefix
<strong>classpath:</strong>, <strong>file:* or *http:</strong> to specify how
the resource should by resolved. You can separate multiple schema files by
using the <strong>','</strong> character.</p><div
class="confluence-information-macro
confluence-information-macro-information"><p class="title">Known issue</p><span
class="aui-icon aui-icon-small aui-iconfont-info
confluence-information-macro-icon"></span><div
class="confluence-information-macro-body"><p>Camel 2.11.0 and 2.11.1 has a
known issue by validation multiple <code>Exchange</code>'s in parallel. See <a
shape="rect" class="external-link"
href="https://issues.apache.org/jira/browse/CAMEL-6630">CAMEL-6630</a>. This is
fixed with Camel 2.11.2/2.12.0.</p></div
></div><p>Using the Java DSL, you can configure it in the following
>way:</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[JaxbDataFormat jaxbDataFormat = new
JaxbDataFormat();
+</plain-text-body><h3 id="JAXB-Schemavalidation">Schema
validation</h3><p><strong>Available as of Camel 2.11</strong></p><p>The JAXB <a
shape="rect" href="data-format.html">Data Format</a> supports validation by
marshalling and unmarshalling from/to XML. Your can use the prefix
<strong>classpath:</strong>, <strong>file:* or *http:</strong> to specify how
the resource should by resolved. You can separate multiple schema files by
using the <strong>','</strong> character.</p><parameter ac:name="title">Known
issue</parameter><rich-text-body><p>Camel 2.11.0 and 2.11.1 has a known issue
by validation multiple <code>Exchange</code>'s in parallel. See <a shape="rect"
class="external-link"
href="https://issues.apache.org/jira/browse/CAMEL-6630">CAMEL-6630</a>. This is
fixed with Camel 2.11.2/2.12.0.</p></rich-text-body><p>Using the Java DSL, you
can configure it in the following way:</p><parameter
ac:name="">java</parameter><plain-text-body>JaxbDataFormat jaxbDataFormat = new
JaxbDataFormat(
);
jaxbDataFormat.setContextPath(Person.class.getPackage().getName());
-jaxbDataFormat.setSchema("classpath:person.xsd,classpath:address.xsd");
-]]></script>
-</div></div><p>You can do the same using the 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[<marshal>
- <jaxb id="jaxb"
schema="classpath:person.xsd,classpath:address.xsd"/>
+jaxbDataFormat.setSchema("classpath:person.xsd,classpath:address.xsd");
+</plain-text-body><p>You can do the same using the XML DSL:</p><parameter
ac:name="">xml</parameter><plain-text-body><marshal>
+ <jaxb id="jaxb" schema="classpath:person.xsd,classpath:address.xsd"/>
</marshal>
-]]></script>
-</div></div><p>Camel will create and pool the underling
<code>SchemaFactory</code> instances on the fly, because the
<code>SchemaFactory</code> shipped with the JDK is not thread safe.<br
clear="none"> However, if you have a <code>SchemaFactory</code> implementation
which is thread safe, you can configure the JAXB data format to use this
one:</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[JaxbDataFormat jaxbDataFormat = new
JaxbDataFormat();
+</plain-text-body><p>Camel will create and pool the underling
<code>SchemaFactory</code> instances on the fly, because the
<code>SchemaFactory</code> shipped with the JDK is not thread safe.<br
clear="none"> However, if you have a <code>SchemaFactory</code> implementation
which is thread safe, you can configure the JAXB data format to use this
one:</p><parameter ac:name="">java</parameter><plain-text-body>JaxbDataFormat
jaxbDataFormat = new JaxbDataFormat();
jaxbDataFormat.setSchemaFactory(thradSafeSchemaFactory);
-]]></script>
-</div></div><h3 id="JAXB-SchemaLocation">Schema
Location</h3><p><strong>Available as of Camel 2.14</strong></p><p>The
JAXB <a shape="rect" href="data-format.html">Data Format</a> supports
to specify the SchemaLocation when marshaling the XML. </p><p>Using the
Java DSL, you can configure it in the following way:</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[JaxbDataFormat jaxbDataFormat = new
JaxbDataFormat();
+</plain-text-body><h3 id="JAXB-SchemaLocation">Schema
Location</h3><p><strong>Available as of Camel 2.14</strong></p><p>The
JAXB <a shape="rect" href="data-format.html">Data Format</a> supports
to specify the SchemaLocation when marshaling the XML. </p><p>Using the
Java DSL, you can configure it in the following way:</p><parameter
ac:name="">java</parameter><plain-text-body>JaxbDataFormat jaxbDataFormat = new
JaxbDataFormat();
jaxbDataFormat.setContextPath(Person.class.getPackage().getName());
-jaxbDataFormat.setSchemaLocation("schema/person.xsd");
-]]></script>
-</div></div><p>You can do the same using the 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[<marshal>
- <jaxb id="jaxb"
schemaLocation="schema/person.xsd"/>
-</marshal>]]></script>
-</div></div><h3 id="JAXB-MarshaldatathatisalreadyXML">Marshal data that is
already XML</h3><p><strong>Available as of Camel 2.14.1</strong></p><div>The
JAXB marshaller requires that the message body is JAXB compatible, eg its a
JAXBElement, eg a java instance that has JAXB annotations, or extend
JAXBElement. There can be situations where the message body is already in XML,
eg from a String type. There is a new
option <code>mustBeJAXBElement</code> you can set to false, to relax this
check, so the JAXB marshaller only attempts to marshal JAXBElements
(javax.xml.bind.JAXBIntrospector#isElement returns true). And in those
situations the marshaller fallbacks to marshal the message body
as-is.</div><div><h3 id="JAXB-XmlRootElementobjects"><span style="color:
rgb(51,51,51);">XmlRootElement objects</span></h3><p><strong>Available as of
Camel 2.17.2</strong></p><p>The JAXB <a shape="rect"
href="data-format.html">Data Format</a> option objectFactory has a default
value equals to false.
This is related to a performance degrading. For more information look at the
issue <a shape="rect" class="external-link"
href="https://issues.apache.org/jira/browse/CAMEL-10043">CAMEL-10043</a></p><p>For
the marshalling of <span style="color: rgb(51,51,51);">non-XmlRootElement JaxB
objects</span> you'll need to <span style="color: rgb(51,51,51);">call
JaxbDataFormat#setObjectFactory(true)</span></p></div><h3
id="JAXB-Dependencies">Dependencies</h3><p>To use JAXB in your camel routes you
need to add the a dependency on <strong>camel-jaxb</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: java; gutter: false; theme: Default"
type="syntaxhighlighter"><![CDATA[<dependency>
+jaxbDataFormat.setSchemaLocation("schema/person.xsd");
+</plain-text-body><p>You can do the same using the XML DSL:</p><parameter
ac:name="">xml</parameter><plain-text-body><marshal>
+ <jaxb id="jaxb" schemaLocation="schema/person.xsd"/>
+</marshal></plain-text-body><h3
id="JAXB-MarshaldatathatisalreadyXML">Marshal data that is already
XML</h3><p><strong>Available as of Camel 2.14.1</strong></p><div>The JAXB
marshaller requires that the message body is JAXB compatible, eg its a
JAXBElement, eg a java instance that has JAXB annotations, or extend
JAXBElement. There can be situations where the message body is already in XML,
eg from a String type. There is a new
option <code>mustBeJAXBElement</code> you can set to false, to relax this
check, so the JAXB marshaller only attempts to marshal JAXBElements
(javax.xml.bind.JAXBIntrospector#isElement returns true). And in those
situations the marshaller fallbacks to marshal the message body
as-is.</div><div><h3 id="JAXB-XmlRootElementobjects"><span style="color:
rgb(51,51,51);">XmlRootElement objects</span></h3><p><strong>Available as of
Camel 2.17.2</strong></p><p>The JAXB <a shape="rect"
href="data-format.html">Data Format</a> option objectFactory has a default v
alue equals to false. This is related to a performance degrading. For more
information look at the issue <a shape="rect" class="external-link"
href="https://issues.apache.org/jira/browse/CAMEL-10043">CAMEL-10043</a></p><p>For
the marshalling of <span style="color: rgb(51,51,51);">non-XmlRootElement JaxB
objects</span> you'll need to <span style="color: rgb(51,51,51);">call
JaxbDataFormat#setObjectFactory(true)</span></p></div><h3
id="JAXB-Dependencies">Dependencies</h3><p>To use JAXB in your camel routes you
need to add the a dependency on <strong>camel-jaxb</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><plain-text-body><dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-jaxb</artifactId>
<version>x.x.x</version>
</dependency>
-]]></script>
-</div></div></div>
+</plain-text-body></div>
</td>
<td valign="top">
<div class="navigation">