Author: buildbot
Date: Fri May 29 15:19:55 2015
New Revision: 953102
Log:
Production update by buildbot for camel
Modified:
websites/production/camel/content/cache/main.pageCache
websites/production/camel/content/grape.html
Modified: websites/production/camel/content/cache/main.pageCache
==============================================================================
Binary files - no diff available.
Modified: websites/production/camel/content/grape.html
==============================================================================
--- websites/production/camel/content/grape.html (original)
+++ websites/production/camel/content/grape.html Fri May 29 15:19:55 2015
@@ -91,12 +91,14 @@
<p>Available as of Camel 2.16<span
style="line-height: 1.4285715;"> </span></p>
</div>
</div>
-<p><a shape="rect" class="external-link"
href="http://docs.groovy-lang.org/latest/html/documentation/grape.html"
rel="nofollow">Grape</a> component allows you to fetch, load and manage
additional jars when <code>CamelContext</code> is running. In practice with
Camel Grape component you can add new components, data formats and beans to
your <code>CamelContext</code> without the restart of the router. Grape
component supports only producer endpoints.</p><h3
id="Grape-Settingupclassloader">Setting up class loader</h3><p>Grape requires
using Groovy class loader with CamelContext. You can enable Groovy class
loading on the existing Camel Context using the
<code>GrapeComponent#grapeCamelContext()</code> method:</p><p> </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[CamelContext camelContext =
grapeCamelContext(new DefaultCamelContext());]]></script>
-</div></div><p> You can also set up the Groovy class loader by
yourself:</p><div class="code panel pdl" style="border-width: 1px;"><div
class="codeContent panelContent pdl">
+<p><a shape="rect" class="external-link"
href="http://docs.groovy-lang.org/latest/html/documentation/grape.html"
rel="nofollow">Grape</a> component allows you to fetch, load and manage
additional jars when <code>CamelContext</code> is running. In practice with
Camel Grape component you can add new components, data formats and beans to
your <code>CamelContext</code> without the restart of the router.</p><h3
id="Grape-Settingupclassloader">Setting up class loader</h3><p>Grape requires
using Groovy class loader with the <code>CamelContext</code>. You can enable
Groovy class loading on the existing Camel Context using the
<code>GrapeComponent#grapeCamelContext()</code> method:</p><p> </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[import static
org.apache.camel.component.grape.GrapeComponent.grapeCamelContext;
+...
+CamelContext camelContext = grapeCamelContext(new
DefaultCamelContext());]]></script>
+</div></div><p> You can also set up the Groovy class loader used be Camel
context by yourself:</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[camelContext.setApplicationContextClassLoader(new
GroovyClassLoader(myClassLoader));]]></script>
-</div></div><h3 id="Grape-URIformat"><span>URI format</span></h3><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[grape:defaultMavenCoordinates[?options]
+</div></div><h3 id="Grape-URIformat"><span>URI
format</span></h3><p><span>Grape component supports only producer
endpoints.</span></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[grape:defaultMavenCoordinates
]]></script>
</div></div><p><span style="line-height: 1.4285715;">For example the following
snippet loads Camel FTP component:</span></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("direct:loadCamelFTP").
@@ -114,20 +116,21 @@
</dependency>]]></script>
</div></div><h3 id="Grape-Defaultpayloadtype"><span style="line-height:
1.5625;font-size: 16.0px;">Default payload type</span></h3><p><span
style="line-height: 1.4285715;">By default Camel Grape component operates on
the String payloads:</span></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[producerTemplate.sendBody("grape:defaultMavenCoordinates",
"org.apache.camel/camel-ftp/2.15.2");]]></script>
-</div></div><p>But of course Camel build-in <a shape="rect"
href="type-converter.html">type conversion API</a> can perform the automatic
data type transformations for you. In the example below Camel automatically
converts binary payload into String:</p><p><span style="line-height:
1.4285715;"> </span></p><div class="code panel pdl" style="border-width:
1px;"><div class="codeContent panelContent pdl">
+</div></div><p>But of course Camel build-in <a shape="rect"
href="type-converter.html">type conversion API</a> can perform the automatic
data type transformations for you. In the example below Camel automatically
converts binary payload into the String:</p><p><span style="line-height:
1.4285715;"> </span></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[producerTemplate.sendBody("grape:defaultMavenCoordinates",
"org.apache.camel/camel-ftp/2.15.2".getBytes());]]></script>
-</div></div><h3 id="Grape-Headers">Headers</h3><p>The following headers are
recognized by the Grape component:</p><div class="confluenceTableSmall"><div
class="table-wrap"><table class="confluenceTable"><tbody><tr><th colspan="1"
rowspan="1" class="confluenceTh"><p>Header</p></th><th colspan="1" rowspan="1"
class="confluenceTh"><p>Java constant</p></th><th colspan="1" rowspan="1"
class="confluenceTh">Endpoint type</th><th colspan="1" rowspan="1"
class="confluenceTh">Value type</th><th colspan="1" rowspan="1"
class="confluenceTh"><p>Description</p></th></tr><tr><td colspan="1"
rowspan="1" class="confluenceTd"><code>CamelGrapeCommand</code></td><td
colspan="1" rowspan="1"
class="confluenceTd"><code><span>GrapeConstants.</span><span>GRAPE_COMMAND</span></code></td><td
colspan="1" rowspan="1" class="confluenceTd">Producer</td><td colspan="1"
rowspan="1"
class="confluenceTd"><code>org.apache.camel.component.grape.GrapeCommand</code></td><td
colspan="1" rowspan="1" class="confluenceTd">Th
e command to be performed by the Grape endpoint. Default to
<code>grab</code>.</td></tr></tbody></table></div></div><p> </p><h3
id="Grape-Loadingcomponentsatruntime">Loading components at runtime</h3><p>In
order to load the new component at the router runtime, just grab the jar
containing the component:</p><div class="code panel pdl" style="border-width:
1px;"><div class="codeContent panelContent pdl">
+</div></div><h3 id="Grape-Headers">Headers</h3><p>The following headers are
recognized by the Grape component:</p><div class="confluenceTableSmall"><div
class="table-wrap"><table class="confluenceTable"><tbody><tr><th colspan="1"
rowspan="1" class="confluenceTh"><p>Header</p></th><th colspan="1" rowspan="1"
class="confluenceTh"><p>Java constant</p></th><th colspan="1" rowspan="1"
class="confluenceTh">Endpoint type</th><th colspan="1" rowspan="1"
class="confluenceTh">Value type</th><th colspan="1" rowspan="1"
class="confluenceTh"><p>Description</p></th></tr><tr><td colspan="1"
rowspan="1" class="confluenceTd"><code>CamelGrapeCommand</code></td><td
colspan="1" rowspan="1"
class="confluenceTd"><code><span>GrapeConstants.</span><span>GRAPE_COMMAND</span></code></td><td
colspan="1" rowspan="1" class="confluenceTd">Producer</td><td colspan="1"
rowspan="1"
class="confluenceTd"><code>org.apache.camel.component.grape.GrapeCommand</code></td><td
colspan="1" rowspan="1" class="confluenceTd">Th
e command to be performed by the Grape endpoint. Default to
<code>grab</code>.</td></tr></tbody></table></div></div><p> </p><h3
id="Grape-Loadingcomponentsatruntime">Loading components at runtime</h3><p>In
order to load the new component at the router runtime, just grab the jar
containing the given component:</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[ProducerTemplate template =
camelContext.createProducerTemplate();
template.sendBody("grape:grape",
"org.apache.camel/camel-stream/2.15.2");
template.sendBody("stream:out", "msg");]]></script>
-</div></div><h3 id="Grape-Loadingprocessorsbeanatruntime">Loading
processors <span style="line-height: 1.5625;">bean</span><span
style="line-height: 1.5625;"> at runtime</span></h3><p>In order to load
the new processor bean  with your custom business login at the router
runtime, just grab the jar containing the bean:</p><div class="code panel pdl"
style="border-width: 1px;"><div class="codeContent panelContent pdl">
+</div></div><h3 id="Grape-Loadingprocessorsbeanatruntime">Loading
processors <span style="line-height: 1.5625;">bean</span><span
style="line-height: 1.5625;"> at runtime</span></h3><p>In order to load
the new processor bean  with your custom business login at the router
runtime, just grab the jar containing the required bean:</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[ProducerTemplate template =
camelContext.createProducerTemplate();
template.sendBody("grape:grape",
"com.example/my-business-processors/1.0");
int productId = 1;
int price =
template.requestBody("bean:com.example.PricingBean?method=currentProductPrice",
productId, int.class)]]></script>
-</div></div><p> </p><h3
id="Grape-LoadingdeployedjarsafterCamelcontextrestart">Loading deployed jars
after Camel context restart</h3><p>After you download new jar, you usually
would like to have it loaded by Camel again after the restart of the
<code>CamelContext</code>. Grape component keeps track of the jar files you
have installed. In order to load again the installed jars on the context
startup, use the <span style="line-height:
1.4285715;"><code>GrapeEndpoint.loadPatches()</code> </span><span
style="line-height: 1.4285715;">method in your
route: </span></p><p> </p><div class="code panel pdl"
style="border-width: 1px;"><div class="codeContent panelContent pdl">
+</div></div><p> </p><h3
id="Grape-LoadingdeployedjarsafterCamelcontextrestart">Loading deployed jars
after Camel context restart</h3><p>After you download new jar, you usually
would like to have it loaded by the Camel again after the restart of the
<code>CamelContext</code>. It is certainly possible, as Grape component keeps
track of the jar files you have installed. In order to load again the installed
jars on the context startup, use the <span style="line-height:
1.4285715;"><code>GrapeEndpoint.loadPatches()</code> </span><span
style="line-height: 1.4285715;">method in your
route: </span></p><p> </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[import static
org.apache.camel.component.grape.GrapeEndpoint.loadPatches;
-Â
+
+...Â
camelContext.addRoutes(
new RouteBuilder() {Â
@OverrideÂ
@@ -140,6 +143,18 @@ camelContext.addRoutes(
});
]]></script>
+</div></div><p> </p><h3 id="Grape-Managingtheinstalledjars">Managing the
installed jars</h3><p>If you would like to check what jars have been installed
into the given <code>CamelContext</code>, send message to the grape endpoint
with the <span><code>CamelGrapeCommand</code> header set to
<code><span>GrapeCommand.</span>listPatches</code>:</span></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("netty-http4:http://0.0.0.0:80/patches").
+ setHeader(GrapeConstats.GRAPE_COMMAND,
constant(CamelGrapeCommand.listPatches)).
+ to("grape:list");Â ]]></script>
+</div></div><p>Connecting the to the route defined above using the HTTP client
returns the list of the jars installed by Grape component:</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[$ curl http://my-router.com/patches
+grape:org.apache.camel/camel-ftp/2.15.2
+grape:org.apache.camel/camel-jms/2.15.2]]></script>
+</div></div><p>If you would like to remove the installed jars, so these won't
be loaded again after the context restart, use
the <code><span>GrapeCommand.</span></code><span><code>clearPatches</code>
command:</span></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("netty-http4:http://0.0.0.0:80/patches").
+ setHeader(GrapeConstats.GRAPE_COMMAND,
constant(CamelGrapeCommand.clearPatches)).
+ setBody().constant("Installed patches have been deleted.");Â
]]></script>
</div></div><p><br clear="none"></p><h3 id="Grape-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></div>
</td>