Author: buildbot Date: Mon Jul 21 10:18:36 2014 New Revision: 916933 Log: Production update by buildbot for camel
Modified: websites/production/camel/content/cache/main.pageCache websites/production/camel/content/rest-dsl.html Modified: websites/production/camel/content/cache/main.pageCache ============================================================================== Binary files - no diff available. Modified: websites/production/camel/content/rest-dsl.html ============================================================================== --- websites/production/camel/content/rest-dsl.html (original) +++ websites/production/camel/content/rest-dsl.html Mon Jul 21 10:18:36 2014 @@ -155,7 +155,7 @@ <p>The REST DSL will take care of duplicate path separators when using path prefixes. In the example above the rest path prefix ends with a slash ( / ) and the verb starts with a slash ( / ). But Apache Camel will take care of this and remove the duplicated slash.</p> </div> </div> -<p> </p><p> </p><h3 id="RestDSL-camel-example-spark-rest-tomcat">camel-example-spark-rest-tomcat</h3><p>We provide an example that uses the REST DSL with the <a shape="rect" href="spark-rest.html">Spark Rest</a> component that can be deployed in web containers such as Apache Tomcat. This example defines<span style="line-height: 1.4285715;"> a single REST service which offers a GET operation that accepts 3 different types: plain text, json, and xml.</span></p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl"> +<p> </p><h3 id="RestDSL-camel-example-spark-rest-tomcat">camel-example-spark-rest-tomcat</h3><p>We provide an example that uses the REST DSL with the <a shape="rect" href="spark-rest.html">Spark Rest</a> component that can be deployed in web containers such as Apache Tomcat. This example defines<span style="line-height: 1.4285715;"> a single REST service which offers a GET operation that accepts 3 different types: plain text, json, and xml.</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[public class MySparkRouteBuilder extends RouteBuilder { @Override public void configure() throws Exception { @@ -179,13 +179,13 @@ .transform().simple("<message>Hello ${header.me}</message>"); } }]]></script> -</div></div><p>To define the REST services we use the <code>rest</code> method, where we can setup the path, which is "/hello/{me}". Where me refers the a wildcard that is mapped to Camel message header with the same key. Notice how we can refer to this header in the embedded Camel routes where we do <a shape="rect" href="message-translator.html">message transformation</a>. <span style="line-height: 1.4285715;">And because we used embedded routes, we need to define this using .route(), and to denote the end of the route, we use .endRest() to </span><em style="line-height: 1.4285715;">go back</em><span style="line-height: 1.4285715;"> to the Rest DSL, where we can then add the 2nd, and 3rd get service. </span></p><h3 id="RestDSL-ConfiguringRestDSL">Configuring Rest DSL</h3><p>The Rest DSL allows to configure the following options using a builder style</p><div class="table-wrap"><table class="confluenceTable"><tbody><tr><th colspan="1" rowspan="1" class="confluenceTh">O ption</th><th colspan="1" rowspan="1" class="confluenceTh">Default</th><th colspan="1" rowspan="1" class="confluenceTh">Description</th></tr><tr><td colspan="1" rowspan="1" class="confluenceTd">component</td><td colspan="1" rowspan="1" class="confluenceTd"> </td><td colspan="1" rowspan="1" class="confluenceTd">The Camel Rest component to use for the REST transport, such as restlet, spark-rest.</td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd">scheme</td><td colspan="1" rowspan="1" class="confluenceTd">http</td><td colspan="1" rowspan="1" class="confluenceTd">The scheme to use for exposing the REST service. Usually http or https is supported</td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd">hostname</td><td colspan="1" rowspan="1" class="confluenceTd">0.0.0.0</td><td colspan="1" rowspan="1" class="confluenceTd">The hostname to use for exposing the REST service.</td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd">port</td><td colspan="1" rowspan= "1" class="confluenceTd"> </td><td colspan="1" rowspan="1" class="confluenceTd">The port number to use for exposing the REST service.</td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd">property</td><td colspan="1" rowspan="1" class="confluenceTd"> </td><td colspan="1" rowspan="1" class="confluenceTd">Allows to configure as many additional properties. This is used to configure component specific options such as for <a shape="rect" href="restlet.html">Restlet</a> / <a shape="rect" href="spark-rest.html">Spark-Rest</a> etc.</td></tr></tbody></table></div><p> </p><p>For example to configure to use the spark-rest component on port 9091, then we can do as follows</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl"> +</div></div><p>To define the REST services we use the <code>rest</code> method, where we can setup the path, which is "/hello/{me}". Where me refers the a wildcard that is mapped to Camel message header with the same key. Notice how we can refer to this header in the embedded Camel routes where we do <a shape="rect" href="message-translator.html">message transformation</a>. <span style="line-height: 1.4285715;">And because we used embedded routes, we need to define this using .route(), and to denote the end of the route, we use .endRest() to </span><em style="line-height: 1.4285715;">go back</em><span style="line-height: 1.4285715;"> to the Rest DSL, where we can then add the 2nd, and 3rd get service. </span></p><h3 id="RestDSL-ConfiguringRestDSL">Configuring Rest DSL</h3><p>The Rest DSL allows to configure the following options using a builder style</p><div class="table-wrap"><table class="confluenceTable"><tbody><tr><th colspan="1" rowspan="1" class="confluenceTh">O ption</th><th colspan="1" rowspan="1" class="confluenceTh">Default</th><th colspan="1" rowspan="1" class="confluenceTh">Description</th></tr><tr><td colspan="1" rowspan="1" class="confluenceTd">component</td><td colspan="1" rowspan="1" class="confluenceTd"> </td><td colspan="1" rowspan="1" class="confluenceTd">The Camel Rest component to use for the REST transport, such as restlet, spark-rest. If no component has been explicit configured, then Camel will lookup if there is a Camel component that integrates with the Rest DSL, or if a <code>org.apache.camel.spi.RestConsumerFactory</code> is registered in the registry. If either one is found, then that is being used.</td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd">scheme</td><td colspan="1" rowspan="1" class="confluenceTd">http</td><td colspan="1" rowspan="1" class="confluenceTd">The scheme to use for exposing the REST service. Usually http or https is supported</td></tr><tr><td colspan="1" rowspan="1" class="conflue nceTd">hostname</td><td colspan="1" rowspan="1" class="confluenceTd">0.0.0.0</td><td colspan="1" rowspan="1" class="confluenceTd">The hostname to use for exposing the REST service.</td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd">port</td><td colspan="1" rowspan="1" class="confluenceTd"> </td><td colspan="1" rowspan="1" class="confluenceTd">The port number to use for exposing the REST service.</td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd">property</td><td colspan="1" rowspan="1" class="confluenceTd"> </td><td colspan="1" rowspan="1" class="confluenceTd">Allows to configure as many additional properties. This is used to configure component specific options such as for <a shape="rect" href="restlet.html">Restlet</a> / <a shape="rect" href="spark-rest.html">Spark-Rest</a> etc.</td></tr></tbody></table></div><p><span style="line-height: 1.4285715;"><br clear="none"></span></p><p><span style="line-height: 1.4285715;">For example to configure to use the spark-rest component on port 9091, then we can do as follows</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[restConfiguration().component("spark-rest").port(9091).property("foo", "123");]]></script> -</div></div><p> </p><p>And with XML DSL</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl"> +</div></div><p><span style="line-height: 1.4285715;">And with XML DSL</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[ <restConfiguration component="spark-rest" port="9091"> <restProperty key="foo" value="123"/> </restConfiguration>]]></script> -</div></div><p> </p><p> </p><h3 id="RestDSL-SeeAlso">See Also</h3><ul class="alternate"><li><a shape="rect" href="dsl.html">DSL</a></li><li><a shape="rect" href="rest.html">Rest</a></li><li><a shape="rect" href="restlet.html">Restlet</a></li><li><a shape="rect" href="spark-rest.html">Spark-rest</a></li></ul></div> +</div></div><h3 id="RestDSL-IntegrationaCamelcomponentwithRestDSL">Integration a Camel component with Rest DSL</h3><p>Any Apache Camel component can integrate with the Rest DSL if they can be used as a REST service (eg as a REST consumer in Camel lingo). To integrate with the Rest DSL, then the component should implement the <code>org.apache.camel.spi.RestConsumerFactory</code>. The Rest DSL will then invoke the <code>createConsumer</code> method when it setup the Camel routes from the defined DSL. The component should then implement logic to create a Camel consumer that exposes the REST services based on the given parameters, such as path, verb, and other options. For example see the source code for camel-restlet, camel-spark-rest.</p><p> </p><h3 id="RestDSL-SeeAlso">See Also</h3><ul class="alternate"><li><a shape="rect" href="dsl.html">DSL</a></li><li><a shape="rect" href="rest.html">Rest</a></li><li><a shape="rect" href="restlet.html">Restlet</a></li><li><a shape=" rect" href="spark-rest.html">Spark-rest</a></li></ul></div> </td> <td valign="top"> <div class="navigation">