You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by bu...@apache.org on 2015/05/29 17:19:56 UTC

svn commit: r953102 - in /websites/production/camel/content: cache/main.pageCache grape.html

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;">&#160;</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>&#160;</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>&#160;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>&#160;</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>&#160;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(&quot;direct:loadCamelFTP&quot;).
@@ -114,20 +116,21 @@
 &lt;/dependency&gt;]]></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(&quot;grape:defaultMavenCoordinates&quot;, &quot;org.apache.camel/camel-ftp/2.15.2&quot;);]]></script>
-</div></div><p>But of course Camel build-in&#160;<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;">&#160;</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&#160;<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;">&#160;</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(&quot;grape:defaultMavenCoordinates&quot;, &quot;org.apache.camel/camel-ftp/2.15.2&quot;.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>&#160;</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>&#160;</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(&quot;grape:grape&quot;, &quot;org.apache.camel/camel-stream/2.15.2&quot;);
 template.sendBody(&quot;stream:out&quot;, &quot;msg&quot;);]]></script>
-</div></div><h3 id="Grape-Loadingprocessorsbeanatruntime">Loading processors&#160;<span style="line-height: 1.5625;">bean</span><span style="line-height: 1.5625;">&#160;at runtime</span></h3><p>In order to load the new processor&#160;bean &#160;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&#160;<span style="line-height: 1.5625;">bean</span><span style="line-height: 1.5625;">&#160;at runtime</span></h3><p>In order to load the new processor&#160;bean &#160;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(&quot;grape:grape&quot;, &quot;com.example/my-business-processors/1.0&quot;);
 int productId = 1;
 int price = template.requestBody(&quot;bean:com.example.PricingBean?method=currentProductPrice&quot;, productId, int.class)]]></script>
-</div></div><p>&#160;</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&#160;<span style="line-height: 1.4285715;"><code>GrapeEndpoint.loadPatches()</code>&#160;</span><span style="line-height: 1.4285715;">method in your route:&#160;</span></p><p>&#160;</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
+</div></div><p>&#160;</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&#160;<span style="line-height: 1.4285715;"><code>GrapeEndpoint.loadPatches()</code>&#160;</span><span style="line-height: 1.4285715;">method in your route:&#160;</span></p><p>&#160;</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>&#160;</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&#160;<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(&quot;netty-http4:http://0.0.0.0:80/patches&quot;).
+        setHeader(GrapeConstats.GRAPE_COMMAND, constant(CamelGrapeCommand.listPatches)).
+        to(&quot;grape:list&quot;); ]]></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&#160;<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(&quot;netty-http4:http://0.0.0.0:80/patches&quot;).
+        setHeader(GrapeConstats.GRAPE_COMMAND, constant(CamelGrapeCommand.clearPatches)).
+        setBody().constant(&quot;Installed patches have been deleted.&quot;); ]]></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>