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 2014/06/30 16:17:55 UTC

svn commit: r914431 - in /websites/production/camel/content: cache/main.pageCache spark.html

Author: buildbot
Date: Mon Jun 30 14:17:54 2014
New Revision: 914431

Log:
Production update by buildbot for camel

Modified:
    websites/production/camel/content/cache/main.pageCache
    websites/production/camel/content/spark.html

Modified: websites/production/camel/content/cache/main.pageCache
==============================================================================
Binary files - no diff available.

Modified: websites/production/camel/content/spark.html
==============================================================================
--- websites/production/camel/content/spark.html (original)
+++ websites/production/camel/content/spark.html Mon Jun 30 14:17:54 2014
@@ -103,8 +103,25 @@
 <script class="theme: Default; brush: java; gutter: false" type="syntaxhighlighter"><![CDATA[  spark://verb:path?[options]
 ]]></script>
 </div></div><h3 id="Spark-URIOptions"><span style="line-height: 1.5625;font-size: 16.0px;">URI Options</span></h3><div class="confluenceTableSmall">
-<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> Description </p></th></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p> verb </p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>&#160;</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p> GET, POST, DELETE, etc. </p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p> path </p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>&#160;</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p> the content path which support Spark syntax. See further below for examples. </p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p> accept </p></td><td colspan="1" rowspan="1" class="confluenceTd"><p> <strong>/</strong> </p></td><td colspan="1" rowspan="1" class="confluenceTd"><p> accept type suc
 h as: 'text/xml', or 'application/json'. By default we accept all kinds of types. </p></td></tr></tbody></table>
-</div><p>&#160;</p><p></p><h3 id="Spark-SeeAlso">See Also</h3>
+<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> Description </p></th></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p> verb </p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>&#160;</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p> get, post, put, patch, delete, head, trace, connect, or options. </p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p> path </p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>&#160;</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p> the content path which support Spark syntax. See further below for examples. </p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p> accept </p></td><td colspan="1" rowspan="1" class="confluenceTd"><p> <strong>/</strong> </p></td><td colspan="1" rowspan="1"
  class="confluenceTd"><p> accept type such as: 'text/xml', or 'application/json'. By default we accept all kinds of types. </p></td></tr></tbody></table>
+</div><h3 id="Spark-PathusingSparksyntax">Path using Spark syntax</h3><p>The path option is defined using a Spark syntax where you define the REST context path using support for parameters and splat. See more details at the <a shape="rect" class="external-link" href="http://sparkjava.com/readme.html#title1" rel="nofollow">Spark Route</a> documentation.</p><p>The following is a Camel route using a fixed path</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;spark:get:hello&quot;)
+    .transform().constant(&quot;Bye World&quot;);]]></script>
+</div></div><p>And the following route uses a parameter which is mapped to a Camel header with the key "me".</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;spark:get:hello/:me&quot;)
+    .transform().simple(&quot;Bye ${header.me}&quot;);]]></script>
+</div></div><h3 id="Spark-MappingtoCamelMessage">Mapping to Camel Message</h3><p>The Spark Request object is mapped to a Camel Message as a&#160;org.apache.camel.component.spark.SparkMessage which has access to the raw Spark request using the getRequest method. By default the Spark body is mapped to Camel message body, and any HTTP headers / Spark parameters is mapped to Camel Message headers. There is special support for the Spark splat syntax, which is mapped to the Camel message header with key splat.</p><p>For example the given route below uses Spark splat (the asterisk sign)&#160;in the context path which we can access as a header form the Simple language to construct a response message.</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;spark:get:/hello/*/to/*&quot;)
+    .transform().simple(&quot;Bye big ${header.splat[1]} from ${header.splat[0]}&quot;);]]></script>
+</div></div><h3 id="Spark-SparkRouteBuilder"><span style="font-size: 16.0px;line-height: 1.5625;">SparkRouteBuilder</span></h3><p><span style="font-size: medium;"><span style="line-height: 25.0px;">If you use Java code, then you can use the class&#160;<code>org.apache.camel.component.spark.SparkRouteBuilder</code> to define routes using a Spark DSL, as shown below</span></span></p><p><span style="font-size: medium;"><span style="line-height: 25.0px;">&#160;</span></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[  return new SparkRouteBuilder() {
+      @Override
+      public void configure() throws Exception {
+            get(&quot;hello/:me&quot;)
+                .transform().simple(&quot;Bye ${header.me}&quot;);
+        }
+    };]]></script>
+</div></div><p><span style="font-size: medium;"><span style="line-height: 25.0px;">When using the SparkRouteBuilder, then you can define Camel routes using the REST verbs, such as get, post, put, delete etc.</span></span></p><h3 id="Spark-Moreexamples"><span style="font-size: 16.0px;line-height: 1.5625;">More examples</span></h3><p>There is a <strong>camel-example-spark-tomcat</strong> example in the Apache Camel distribution, that demonstrates how to use camel-spark in a web application that can be deployed on Apache Tomcat, or similar web containers.</p><p></p><h3 id="Spark-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>
         <td valign="top">