Author: buildbot
Date: Sun Mar 31 20:26:42 2013
New Revision: 856784
Log:
Production update by buildbot for camel
Modified:
websites/production/camel/content/book-component-appendix.html
websites/production/camel/content/cxfrs.html
Modified: websites/production/camel/content/book-component-appendix.html
==============================================================================
--- websites/production/camel/content/book-component-appendix.html (original)
+++ websites/production/camel/content/book-component-appendix.html Sun Mar 31
20:26:42 2013
@@ -2776,8 +2776,11 @@ cxfrs:bean:cxfEndpoint?resourceClasses=o
<h3><a shape="rect" name="BookComponentAppendix-Options"></a>Options</h3>
<div class="confluenceTableSmall"><div class="table-wrap">
-<table class="confluenceTable"><tbody><tr><th colspan="1" rowspan="1"
class="confluenceTh"> Name </th><th colspan="1" rowspan="1"
class="confluenceTh"> Description </th><th colspan="1" rowspan="1"
class="confluenceTh"> Example </th><th colspan="1" rowspan="1"
class="confluenceTh"> Required? </th><th colspan="1" rowspan="1"
class="confluenceTh"> default value </th></tr><tr><td colspan="1" rowspan="1"
class="confluenceTd"> <tt>resourceClasses</tt> </td><td colspan="1" rowspan="1"
class="confluenceTd"> The resource classes which you want to export as REST
service. Multiple classes can be separated by comma. </td><td colspan="1"
rowspan="1" class="confluenceTd"> <tt>resourceClasses
=org.apache.camel.rs.Example1,org.apache.camel.rs.Exchange2</tt> </td><td
colspan="1" rowspan="1" class="confluenceTd"> No </td><td colspan="1"
rowspan="1" class="confluenceTd"> <em>None</em> </td></tr><tr><td colspan="1"
rowspan="1" class="confluenceTd"> <tt>resourceClass</tt> </td><td colspan="1" ro
wspan="1" class="confluenceTd"> <b>Deprecated</b>: Use
<tt>resourceClasses</tt> The resource class which you want to export as REST
service. </td><td colspan="1" rowspan="1" class="confluenceTd">
<tt>resourceClass =org.apache.camel.rs.Example1</tt> </td><td colspan="1"
rowspan="1" class="confluenceTd"> No </td><td colspan="1" rowspan="1"
class="confluenceTd"> <em>None</em> </td></tr><tr><td colspan="1" rowspan="1"
class="confluenceTd"> <tt>httpClientAPI</tt> </td><td colspan="1" rowspan="1"
class="confluenceTd"> <b>new to Camel 2.1</b> If it is true, the CxfRsProducer
will use the HttpClientAPI to invoke the service <br clear="none"
class="atl-forced-newline">
-If it is false, the CxfRsProducer will use the ProxyClientAPI to invoke the
service </td><td colspan="1" rowspan="1" class="confluenceTd">
httpClientAPI=true </td><td colspan="1" rowspan="1" class="confluenceTd"> No
</td><td colspan="1" rowspan="1" class="confluenceTd"> <em>true</em>
</td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"> synchronous
</td><td colspan="1" rowspan="1" class="confluenceTd"> New in 2.5, this option
will let CxfRsConsumer decide to use sync or async API to do the underlying
work. The default value is false which means it will try to use async API by
default. </td><td colspan="1" rowspan="1" class="confluenceTd">
synchronous=true </td><td colspan="1" rowspan="1" class="confluenceTd"> No
</td><td colspan="1" rowspan="1" class="confluenceTd"> false </td></tr><tr><td
colspan="1" rowspan="1" class="confluenceTd"> throwExceptionOnFailure </td><td
colspan="1" rowspan="1" class="confluenceTd"> New in 2.6, this option tells the
CxfRsProducer to in
spect return codes and will generate an Exception if the return code is larger
than 207. </td><td colspan="1" rowspan="1" class="confluenceTd">
throwExceptionOnFailure=true </td><td colspan="1" rowspan="1"
class="confluenceTd"> No </td><td colspan="1" rowspan="1" class="confluenceTd">
true </td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd">
<tt>maxClientCacheSize</tt> </td><td colspan="1" rowspan="1"
class="confluenceTd"> New in 2.6, you can set a IN message header
CamelDestinationOverrideUrl to dynamically override the target destination Web
Service or REST Service defined in your routes.  The implementation caches
CXF clients or ClientFactoryBean in CxfProvider and CxfRsProvider.  This
option allows you to configure the maximum size of the cache. <br clear="none"
class="atl-forced-newline"> </td><td colspan="1" rowspan="1"
class="confluenceTd"> maxClientCacheSize=5 </td><td colspan="1" rowspan="1"
class="confluenceTd"> No <br clear="none" class="atl-f
orced-newline"> </td><td colspan="1" rowspan="1" class="confluenceTd"> 10
</td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd">
<tt>setDefaultBus</tt> </td><td colspan="1" rowspan="1" class="confluenceTd">
New in 2.9.0. Will set the default bus when CXF endpoint create a bus by itself
</td><td colspan="1" rowspan="1" class="confluenceTd">
<tt>setDefaultBus=true</tt> </td><td colspan="1" rowspan="1"
class="confluenceTd"> No </td><td colspan="1" rowspan="1" class="confluenceTd">
<tt>false</tt> </td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd">
<tt>bus</tt> </td><td colspan="1" rowspan="1" class="confluenceTd"> New in
2.9.0. A default bus created by CXF Bus Factory. Use <tt>#</tt> notation to
reference a bus object from the registry. The referenced object must be an
instance of <tt>org.apache.cxf.Bus</tt>. </td><td colspan="1" rowspan="1"
class="confluenceTd"> <tt>bus=#busName</tt> </td><td colspan="1" rowspan="1"
class="confluenceTd"> No </td><td colspan
="1" rowspan="1" class="confluenceTd"> <em>None</em> </td></tr></tbody></table>
+<table class="confluenceTable"><tbody><tr><th colspan="1" rowspan="1"
class="confluenceTh"> Name </th><th colspan="1" rowspan="1"
class="confluenceTh"> Description </th><th colspan="1" rowspan="1"
class="confluenceTh"> Example </th><th colspan="1" rowspan="1"
class="confluenceTh"> Required? </th><th colspan="1" rowspan="1"
class="confluenceTh"> default value </th></tr><tr><td colspan="1" rowspan="1"
class="confluenceTd"> <tt>resourceClasses</tt> </td><td colspan="1" rowspan="1"
class="confluenceTd"> The resource classes which you want to export as REST
service. Multiple classes can be separated by comma. </td><td colspan="1"
rowspan="1" class="confluenceTd">
<tt>resourceClasses=org.apache.camel.rs.Example1,</tt><br clear="none">
+<tt>org.apache.camel.rs.Exchange2</tt> </td><td colspan="1" rowspan="1"
class="confluenceTd"> No </td><td colspan="1" rowspan="1" class="confluenceTd">
<em>None</em> </td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd">
<tt>resourceClass</tt> </td><td colspan="1" rowspan="1" class="confluenceTd">
<b>Deprecated</b>: Use <tt>resourceClasses</tt> The resource class which you
want to export as REST service. </td><td colspan="1" rowspan="1"
class="confluenceTd"> <tt>resourceClass =org.apache.camel.rs.Example1</tt>
</td><td colspan="1" rowspan="1" class="confluenceTd"> No </td><td colspan="1"
rowspan="1" class="confluenceTd"> <em>None</em> </td></tr><tr><td colspan="1"
rowspan="1" class="confluenceTd"> <tt>httpClientAPI</tt> </td><td colspan="1"
rowspan="1" class="confluenceTd"> <b>new to Camel 2.1</b> If it is true, the
CxfRsProducer will use the HttpClientAPI to invoke the service <br clear="none"
class="atl-forced-newline">
+If it is false, the CxfRsProducer will use the ProxyClientAPI to invoke the
service </td><td colspan="1" rowspan="1" class="confluenceTd">
httpClientAPI=true </td><td colspan="1" rowspan="1" class="confluenceTd"> No
</td><td colspan="1" rowspan="1" class="confluenceTd"> <em>true</em>
</td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"> synchronous
</td><td colspan="1" rowspan="1" class="confluenceTd"> New in 2.5, this option
will let CxfRsConsumer decide to use sync or async API to do the underlying
work. The default value is false which means it will try to use async API by
default. </td><td colspan="1" rowspan="1" class="confluenceTd">
synchronous=true </td><td colspan="1" rowspan="1" class="confluenceTd"> No
</td><td colspan="1" rowspan="1" class="confluenceTd"> false </td></tr><tr><td
colspan="1" rowspan="1" class="confluenceTd"> throwExceptionOnFailure </td><td
colspan="1" rowspan="1" class="confluenceTd"> New in 2.6, this option tells the
CxfRsProducer to in
spect return codes and will generate an Exception if the return code is larger
than 207. </td><td colspan="1" rowspan="1" class="confluenceTd">
throwExceptionOnFailure=true </td><td colspan="1" rowspan="1"
class="confluenceTd"> No </td><td colspan="1" rowspan="1" class="confluenceTd">
true </td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd">
<tt>maxClientCacheSize</tt> </td><td colspan="1" rowspan="1"
class="confluenceTd"> New in 2.6, you can set a IN message header
CamelDestinationOverrideUrl to dynamically override the target destination Web
Service or REST Service defined in your routes.  The implementation caches
CXF clients or ClientFactoryBean in CxfProvider and CxfRsProvider.  This
option allows you to configure the maximum size of the cache. <br clear="none"
class="atl-forced-newline"> </td><td colspan="1" rowspan="1"
class="confluenceTd"> maxClientCacheSize=5 </td><td colspan="1" rowspan="1"
class="confluenceTd"> No <br clear="none" class="atl-f
orced-newline"> </td><td colspan="1" rowspan="1" class="confluenceTd"> 10
</td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd">
<tt>setDefaultBus</tt> </td><td colspan="1" rowspan="1" class="confluenceTd">
New in 2.9.0. Will set the default bus when CXF endpoint create a bus by itself
</td><td colspan="1" rowspan="1" class="confluenceTd">
<tt>setDefaultBus=true</tt> </td><td colspan="1" rowspan="1"
class="confluenceTd"> No </td><td colspan="1" rowspan="1" class="confluenceTd">
<tt>false</tt> </td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd">
<tt>bus</tt> </td><td colspan="1" rowspan="1" class="confluenceTd"> New in
2.9.0. A default bus created by CXF Bus Factory. Use <tt>#</tt> notation to
reference a bus object from the registry. The referenced object must be an
instance of <tt>org.apache.cxf.Bus</tt>. </td><td colspan="1" rowspan="1"
class="confluenceTd"> <tt>bus=#busName</tt> </td><td colspan="1" rowspan="1"
class="confluenceTd"> No </td><td colspan
="1" rowspan="1" class="confluenceTd"> <em>None</em> </td></tr><tr><td
colspan="1" rowspan="1" class="confluenceTd"> <tt>bindingStyle</tt> </td><td
colspan="1" rowspan="1" class="confluenceTd"> <b>As of 2.11</b>. Sets how
requests and responses will be mapped to/from Camel. Two values are possible:
+<ul class="alternate" type="square"><li><tt>SimpleConsumer</tt> => see the
<a shape="rect"
href="#BookComponentAppendix-ConsumingaRESTRequestSimpleBindingStyle">Consuming
a REST Request with the Simple Binding Style</a>
below.</li><li><tt>Default</tt> => the default style. For consumers this
passes on a <tt>MessageContentsList</tt> to the route, requiring low-level
processing in the route.</li></ul>
+</td><td colspan="1" rowspan="1" class="confluenceTd">
<tt>bindingStyle=SimpleConsumer</tt> </td><td colspan="1" rowspan="1"
class="confluenceTd"> No </td><td colspan="1" rowspan="1" class="confluenceTd">
<em>Default</em> </td></tr></tbody></table>
</div>
</div>
@@ -2787,7 +2790,7 @@ Please check out the <a shape="rect" cla
<h3><a shape="rect"
name="BookComponentAppendix-HowtoconfiguretheRESTendpointinCamel"></a>How to
configure the REST endpoint in Camel</h3>
<p>In <a shape="rect" class="external-link"
href="http://svn.apache.org/repos/asf/camel/trunk/components/camel-cxf/src/main/resources/schema/cxfEndpoint.xsd">camel-cxf
schema file</a>, there are two elements for the REST endpoint definition.
<b>cxf:rsServer</b> for REST consumer, <b>cxf:rsClient</b> for REST
producer.<br clear="none">
-You can find an camel REST service route configuration example here.</p>
+You can find a Camel REST service route configuration example here.</p>
<div class="code panel" style="border-width: 1px;"><div class="codeContent
panelContent">
<pre class="code-xml"><beans xmlns=<span
class="code-quote">"http://www.springframework.org/schema/beans"</span>
@@ -2842,7 +2845,106 @@ You can find an camel REST service route
</pre>
</div></div>
-<h3><a shape="rect"
name="BookComponentAppendix-HowtoconsumetheRESTrequestinCamel"></a>How to
consume the REST request in Camel</h3>
+<h3><a shape="rect"
name="BookComponentAppendix-ConsumingaRESTRequestSimpleBindingStyle"></a>Consuming
a REST Request - Simple Binding Style</h3>
+
+<p><b>Available as of Camel 2.11</b></p>
+
+<p>The <tt>Default</tt> binding style is rather low-level, requiring the user
to manually process the <tt>MessageContentsList</tt> object coming into the
route. Thus, it tightly couples the route logic with the method signature and
parameter indices of the JAX-RS operation. Somewhat inelegant, difficult and
error-prone.</p>
+
+<p>In contrast, the <tt>SimpleConsumer</tt> binding style performs the
following mappings, in order to <b>make the request data more accessible</b> to
you within the Camel Message:</p>
+
+<ul><li>JAX-RS Parameters (@HeaderParam, @QueryParam, etc.) are injected as IN
message headers. The header name matches the value of the
annotation.</li><li>The request entity (POJO or other type) becomes the IN
message body. If a single entity cannot be identified in the JAX-RS method
signature, it falls back to the original
<tt>MessageContentsList</tt>.</li><li>Binary <tt>@Multipart</tt> body parts
become IN message attachments, supporting <tt>DataHandler</tt>,
<tt>InputStream</tt>, <tt>DataSource</tt> and CXF's <tt>Attachment</tt>
class.</li><li>Non-binary <tt>@Multipart</tt> body parts are mapped as IN
message headers. The header name matches the Body Part name.</li></ul>
+
+
+<p>Additionally, the following rules apply to the <b>Response mapping</b>:</p>
+
+<ul><li>If the message body type is different to
<tt>javax.ws.rs.core.Response</tt> (user-built response), a new
<tt>Response</tt> is created and the message body is set as the entity (so long
it's not null). The response status code is taken from the
<tt>Exchange.HTTP_RESPONSE_CODE</tt> header, or defaults to 200 OK if not
present.</li><li>If the message body type is equal to
<tt>javax.ws.rs.core.Response</tt>, it means that the user has built a custom
response, and therefore it is respected and it becomes the final
response.</li><li>In all cases, Camel headers permitted by custom or default
<tt>HeaderFilterStrategy</tt> are added to the HTTP response.</li></ul>
+
+
+<h4><a shape="rect"
name="BookComponentAppendix-EnablingtheSimpleBindingStyle"></a>Enabling the
Simple Binding Style</h4>
+
+<p>This binding style can be activated by setting the <tt>bindingStyle</tt>
parameter in the consumer endpoint to value <tt>SimpleConsumer</tt>:</p>
+
+<div class="code panel" style="border-width: 1px;"><div class="codeContent
panelContent">
+<pre class="code-java">
+ from(<span
class="code-quote">"cxf:bean:rsServer?bindingStyle=SimpleConsumer"</span>)
+ .to(<span class="code-quote">"log:TEST?showAll=<span
class="code-keyword">true</span>"</span>);
+</pre>
+</div></div>
+
+<h4><a shape="rect"
name="BookComponentAppendix-Examplesofrequestbindingwithdifferentmethodsignatures"></a>Examples
of request binding with different method signatures</h4>
+
+<p>Below is a list of method signatures along with the expected result from
the Simple binding.</p>
+
+<p><b><tt>public Response doAction(BusinessObject request);</tt></b><br
clear="none">
+Request payload is placed in IN message body, replacing the original
MessageContentsList.</p>
+
+<p><b><tt>public Response doAction(BusinessObject request,
@HeaderParam("abcd") String abcd, @QueryParam("defg") String defg);</tt></b><br
clear="none">
+Request payload placed in IN message body, replacing the original
MessageContentsList. Both request params mapped as IN message headers with
names abcd and defg.</p>
+
+<p><b><tt>public Response doAction(@HeaderParam("abcd") String abcd,
@QueryParam("defg") String defg);</tt></b><br clear="none">
+Both request params mapped as IN message headers with names abcd and defg. The
original MessageContentsList is preserved, even though it only contains the 2
parameters.</p>
+
+<p><b><tt>public Response doAction(@Multipart(value="body1") BusinessObject
request, @Multipart(value="body2") BusinessObject request2);</tt></b><br
clear="none">
+The first parameter is transferred as a header with name body1, and the second
one is mapped as header body2. The original MessageContentsList is preserved as
the IN message body.</p>
+
+<p><b><tt>public Response doAction(InputStream abcd);</tt></b><br clear="none">
+The InputStream is unwrapped from the MessageContentsList and preserved as the
IN message body. </p>
+
+<p><b><tt>public Response doAction(DataHandler abcd);</tt></b><br clear="none">
+The DataHandler is unwrapped from the MessageContentsList and preserved as the
IN message body. </p>
+
+<h4><a shape="rect"
name="BookComponentAppendix-MoreexamplesoftheSimpleBindingStyle"></a>More
examples of the Simple Binding Style</h4>
+
+<p>Given a JAX-RS resource class with this method:</p>
+
+<div class="code panel" style="border-width: 1px;"><div class="codeContent
panelContent">
+<pre class="code-java">
+ @POST @Path(<span class="code-quote">"/customers/{type}"</span>)
+ <span class="code-keyword">public</span> Response newCustomer(Customer
customer, @PathParam(<span class="code-quote">"type"</span>) <span
class="code-object">String</span> type, @QueryParam(<span
class="code-quote">"active"</span>) @DefaultValue(<span
class="code-quote">"<span class="code-keyword">true</span>"</span>) <span
class="code-object">boolean</span> active) {
+ <span class="code-keyword">return</span> <span
class="code-keyword">null</span>;
+ }
+</pre>
+</div></div>
+
+<p>Serviced by the following route:</p>
+
+<div class="code panel" style="border-width: 1px;"><div class="codeContent
panelContent">
+<pre class="code-java">
+ from(<span
class="code-quote">"cxf:bean:rsServer?bindingStyle=SimpleConsumer"</span>)
+ .recipientList(simple(<span
class="code-quote">"direct:${header.operationName}"</span>));
+
+ from(<span class="code-quote">"direct:newCustomer"</span>)
+ .log(<span class="code-quote">"Request: type=${header.type},
active=${header.active}, customerData=${body}"</span>);
+</pre>
+</div></div>
+
+<p>The following HTTP request with XML payload (given that the Customer DTO is
JAXB-annotated):</p>
+
+<div class="code panel" style="border-width: 1px;"><div class="codeContent
panelContent">
+<pre class="code-java">
+POST /customers/gold?active=<span class="code-keyword">true</span>
+
+Payload:
+<Customer>
+ <fullName>Raul Kripalani</fullName>
+ <country>Spain</country>
+ <project>Apache Camel</project>
+</Customer>
+</pre>
+</div></div>
+
+<p>Will print the message:</p>
+
+<div class="code panel" style="border-width: 1px;"><div class="codeContent
panelContent">
+<pre class="code-java">
+Request: type=gold, active=<span class="code-keyword">true</span>,
customerData=<Customer.toString() representation>
+</pre>
+</div></div>
+
+<p>For more examples on how to process requests and write responses can be
found <a shape="rect" class="external-link"
href="https://svn.apache.org/repos/asf/camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/jaxrs/simplebinding/">here</a>.</p>
+
+<h3><a shape="rect"
name="BookComponentAppendix-ConsumingaRESTRequestDefaultBindingStyle"></a>Consuming
a REST Request - Default Binding Style</h3>
<p><a shape="rect" class="external-link"
href="http://cwiki.apache.org/CXF20DOC/jax-rs.html">CXF JAXRS front end</a>
implements the <a shape="rect" class="external-link"
href="https://jsr311.dev.java.net/" rel="nofollow">JAXRS(JSR311) API</a>, so we
can export the resources classes as a REST service. And we leverage the <a
shape="rect" class="external-link"
href="http://cwiki.apache.org/confluence/display/CXF20DOC/Invokers">CXF Invoker
API</a> to turn a REST request into a normal Java object method invocation.<br
clear="none">
Unlike the <tt>camel-restlet</tt>, you don't need to specify the URI template
within your restlet endpoint, CXF take care of the REST request URI to resource
class method mapping according to the JSR311 specification. All you need to do
in Camel is delegate this method request to a right processor or endpoint.</p>
Modified: websites/production/camel/content/cxfrs.html
==============================================================================
--- websites/production/camel/content/cxfrs.html (original)
+++ websites/production/camel/content/cxfrs.html Sun Mar 31 20:26:42 2013
@@ -116,8 +116,11 @@ cxfrs:bean:cxfEndpoint?resourceClasses=o
<h3><a shape="rect" name="CXFRS-Options"></a>Options</h3>
<div class="confluenceTableSmall"><div class="table-wrap">
-<table class="confluenceTable"><tbody><tr><th colspan="1" rowspan="1"
class="confluenceTh"> Name </th><th colspan="1" rowspan="1"
class="confluenceTh"> Description </th><th colspan="1" rowspan="1"
class="confluenceTh"> Example </th><th colspan="1" rowspan="1"
class="confluenceTh"> Required? </th><th colspan="1" rowspan="1"
class="confluenceTh"> default value </th></tr><tr><td colspan="1" rowspan="1"
class="confluenceTd"> <tt>resourceClasses</tt> </td><td colspan="1" rowspan="1"
class="confluenceTd"> The resource classes which you want to export as REST
service. Multiple classes can be separated by comma. </td><td colspan="1"
rowspan="1" class="confluenceTd"> <tt>resourceClasses
=org.apache.camel.rs.Example1,org.apache.camel.rs.Exchange2</tt> </td><td
colspan="1" rowspan="1" class="confluenceTd"> No </td><td colspan="1"
rowspan="1" class="confluenceTd"> <em>None</em> </td></tr><tr><td colspan="1"
rowspan="1" class="confluenceTd"> <tt>resourceClass</tt> </td><td colspan="1" ro
wspan="1" class="confluenceTd"> <b>Deprecated</b>: Use
<tt>resourceClasses</tt> The resource class which you want to export as REST
service. </td><td colspan="1" rowspan="1" class="confluenceTd">
<tt>resourceClass =org.apache.camel.rs.Example1</tt> </td><td colspan="1"
rowspan="1" class="confluenceTd"> No </td><td colspan="1" rowspan="1"
class="confluenceTd"> <em>None</em> </td></tr><tr><td colspan="1" rowspan="1"
class="confluenceTd"> <tt>httpClientAPI</tt> </td><td colspan="1" rowspan="1"
class="confluenceTd"> <b>new to Camel 2.1</b> If it is true, the CxfRsProducer
will use the HttpClientAPI to invoke the service <br clear="none"
class="atl-forced-newline">
-If it is false, the CxfRsProducer will use the ProxyClientAPI to invoke the
service </td><td colspan="1" rowspan="1" class="confluenceTd">
httpClientAPI=true </td><td colspan="1" rowspan="1" class="confluenceTd"> No
</td><td colspan="1" rowspan="1" class="confluenceTd"> <em>true</em>
</td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"> synchronous
</td><td colspan="1" rowspan="1" class="confluenceTd"> New in 2.5, this option
will let CxfRsConsumer decide to use sync or async API to do the underlying
work. The default value is false which means it will try to use async API by
default. </td><td colspan="1" rowspan="1" class="confluenceTd">
synchronous=true </td><td colspan="1" rowspan="1" class="confluenceTd"> No
</td><td colspan="1" rowspan="1" class="confluenceTd"> false </td></tr><tr><td
colspan="1" rowspan="1" class="confluenceTd"> throwExceptionOnFailure </td><td
colspan="1" rowspan="1" class="confluenceTd"> New in 2.6, this option tells the
CxfRsProducer to in
spect return codes and will generate an Exception if the return code is larger
than 207. </td><td colspan="1" rowspan="1" class="confluenceTd">
throwExceptionOnFailure=true </td><td colspan="1" rowspan="1"
class="confluenceTd"> No </td><td colspan="1" rowspan="1" class="confluenceTd">
true </td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd">
<tt>maxClientCacheSize</tt> </td><td colspan="1" rowspan="1"
class="confluenceTd"> New in 2.6, you can set a IN message header
CamelDestinationOverrideUrl to dynamically override the target destination Web
Service or REST Service defined in your routes.  The implementation caches
CXF clients or ClientFactoryBean in CxfProvider and CxfRsProvider.  This
option allows you to configure the maximum size of the cache. <br clear="none"
class="atl-forced-newline"> </td><td colspan="1" rowspan="1"
class="confluenceTd"> maxClientCacheSize=5 </td><td colspan="1" rowspan="1"
class="confluenceTd"> No <br clear="none" class="atl-f
orced-newline"> </td><td colspan="1" rowspan="1" class="confluenceTd"> 10
</td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd">
<tt>setDefaultBus</tt> </td><td colspan="1" rowspan="1" class="confluenceTd">
New in 2.9.0. Will set the default bus when CXF endpoint create a bus by itself
</td><td colspan="1" rowspan="1" class="confluenceTd">
<tt>setDefaultBus=true</tt> </td><td colspan="1" rowspan="1"
class="confluenceTd"> No </td><td colspan="1" rowspan="1" class="confluenceTd">
<tt>false</tt> </td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd">
<tt>bus</tt> </td><td colspan="1" rowspan="1" class="confluenceTd"> New in
2.9.0. A default bus created by CXF Bus Factory. Use <tt>#</tt> notation to
reference a bus object from the registry. The referenced object must be an
instance of <tt>org.apache.cxf.Bus</tt>. </td><td colspan="1" rowspan="1"
class="confluenceTd"> <tt>bus=#busName</tt> </td><td colspan="1" rowspan="1"
class="confluenceTd"> No </td><td colspan
="1" rowspan="1" class="confluenceTd"> <em>None</em> </td></tr></tbody></table>
+<table class="confluenceTable"><tbody><tr><th colspan="1" rowspan="1"
class="confluenceTh"> Name </th><th colspan="1" rowspan="1"
class="confluenceTh"> Description </th><th colspan="1" rowspan="1"
class="confluenceTh"> Example </th><th colspan="1" rowspan="1"
class="confluenceTh"> Required? </th><th colspan="1" rowspan="1"
class="confluenceTh"> default value </th></tr><tr><td colspan="1" rowspan="1"
class="confluenceTd"> <tt>resourceClasses</tt> </td><td colspan="1" rowspan="1"
class="confluenceTd"> The resource classes which you want to export as REST
service. Multiple classes can be separated by comma. </td><td colspan="1"
rowspan="1" class="confluenceTd">
<tt>resourceClasses=org.apache.camel.rs.Example1,</tt><br clear="none">
+<tt>org.apache.camel.rs.Exchange2</tt> </td><td colspan="1" rowspan="1"
class="confluenceTd"> No </td><td colspan="1" rowspan="1" class="confluenceTd">
<em>None</em> </td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd">
<tt>resourceClass</tt> </td><td colspan="1" rowspan="1" class="confluenceTd">
<b>Deprecated</b>: Use <tt>resourceClasses</tt> The resource class which you
want to export as REST service. </td><td colspan="1" rowspan="1"
class="confluenceTd"> <tt>resourceClass =org.apache.camel.rs.Example1</tt>
</td><td colspan="1" rowspan="1" class="confluenceTd"> No </td><td colspan="1"
rowspan="1" class="confluenceTd"> <em>None</em> </td></tr><tr><td colspan="1"
rowspan="1" class="confluenceTd"> <tt>httpClientAPI</tt> </td><td colspan="1"
rowspan="1" class="confluenceTd"> <b>new to Camel 2.1</b> If it is true, the
CxfRsProducer will use the HttpClientAPI to invoke the service <br clear="none"
class="atl-forced-newline">
+If it is false, the CxfRsProducer will use the ProxyClientAPI to invoke the
service </td><td colspan="1" rowspan="1" class="confluenceTd">
httpClientAPI=true </td><td colspan="1" rowspan="1" class="confluenceTd"> No
</td><td colspan="1" rowspan="1" class="confluenceTd"> <em>true</em>
</td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"> synchronous
</td><td colspan="1" rowspan="1" class="confluenceTd"> New in 2.5, this option
will let CxfRsConsumer decide to use sync or async API to do the underlying
work. The default value is false which means it will try to use async API by
default. </td><td colspan="1" rowspan="1" class="confluenceTd">
synchronous=true </td><td colspan="1" rowspan="1" class="confluenceTd"> No
</td><td colspan="1" rowspan="1" class="confluenceTd"> false </td></tr><tr><td
colspan="1" rowspan="1" class="confluenceTd"> throwExceptionOnFailure </td><td
colspan="1" rowspan="1" class="confluenceTd"> New in 2.6, this option tells the
CxfRsProducer to in
spect return codes and will generate an Exception if the return code is larger
than 207. </td><td colspan="1" rowspan="1" class="confluenceTd">
throwExceptionOnFailure=true </td><td colspan="1" rowspan="1"
class="confluenceTd"> No </td><td colspan="1" rowspan="1" class="confluenceTd">
true </td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd">
<tt>maxClientCacheSize</tt> </td><td colspan="1" rowspan="1"
class="confluenceTd"> New in 2.6, you can set a IN message header
CamelDestinationOverrideUrl to dynamically override the target destination Web
Service or REST Service defined in your routes.  The implementation caches
CXF clients or ClientFactoryBean in CxfProvider and CxfRsProvider.  This
option allows you to configure the maximum size of the cache. <br clear="none"
class="atl-forced-newline"> </td><td colspan="1" rowspan="1"
class="confluenceTd"> maxClientCacheSize=5 </td><td colspan="1" rowspan="1"
class="confluenceTd"> No <br clear="none" class="atl-f
orced-newline"> </td><td colspan="1" rowspan="1" class="confluenceTd"> 10
</td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd">
<tt>setDefaultBus</tt> </td><td colspan="1" rowspan="1" class="confluenceTd">
New in 2.9.0. Will set the default bus when CXF endpoint create a bus by itself
</td><td colspan="1" rowspan="1" class="confluenceTd">
<tt>setDefaultBus=true</tt> </td><td colspan="1" rowspan="1"
class="confluenceTd"> No </td><td colspan="1" rowspan="1" class="confluenceTd">
<tt>false</tt> </td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd">
<tt>bus</tt> </td><td colspan="1" rowspan="1" class="confluenceTd"> New in
2.9.0. A default bus created by CXF Bus Factory. Use <tt>#</tt> notation to
reference a bus object from the registry. The referenced object must be an
instance of <tt>org.apache.cxf.Bus</tt>. </td><td colspan="1" rowspan="1"
class="confluenceTd"> <tt>bus=#busName</tt> </td><td colspan="1" rowspan="1"
class="confluenceTd"> No </td><td colspan
="1" rowspan="1" class="confluenceTd"> <em>None</em> </td></tr><tr><td
colspan="1" rowspan="1" class="confluenceTd"> <tt>bindingStyle</tt> </td><td
colspan="1" rowspan="1" class="confluenceTd"> <b>As of 2.11</b>. Sets how
requests and responses will be mapped to/from Camel. Two values are possible:
+<ul class="alternate" type="square"><li><tt>SimpleConsumer</tt> => see the
<a shape="rect" href="#CXFRS-ConsumingaRESTRequestSimpleBindingStyle">Consuming
a REST Request with the Simple Binding Style</a>
below.</li><li><tt>Default</tt> => the default style. For consumers this
passes on a <tt>MessageContentsList</tt> to the route, requiring low-level
processing in the route.</li></ul>
+</td><td colspan="1" rowspan="1" class="confluenceTd">
<tt>bindingStyle=SimpleConsumer</tt> </td><td colspan="1" rowspan="1"
class="confluenceTd"> No </td><td colspan="1" rowspan="1" class="confluenceTd">
<em>Default</em> </td></tr></tbody></table>
</div>
</div>
@@ -127,7 +130,7 @@ Please check out the <a shape="rect" cla
<h3><a shape="rect" name="CXFRS-HowtoconfiguretheRESTendpointinCamel"></a>How
to configure the REST endpoint in Camel</h3>
<p>In <a shape="rect" class="external-link"
href="http://svn.apache.org/repos/asf/camel/trunk/components/camel-cxf/src/main/resources/schema/cxfEndpoint.xsd">camel-cxf
schema file</a>, there are two elements for the REST endpoint definition.
<b>cxf:rsServer</b> for REST consumer, <b>cxf:rsClient</b> for REST
producer.<br clear="none">
-You can find an camel REST service route configuration example here.</p>
+You can find a Camel REST service route configuration example here.</p>
<div class="code panel" style="border-width: 1px;"><div class="codeContent
panelContent">
<pre class="code-xml"><beans xmlns=<span
class="code-quote">"http://www.springframework.org/schema/beans"</span>
@@ -182,7 +185,106 @@ You can find an camel REST service route
</pre>
</div></div>
-<h3><a shape="rect" name="CXFRS-HowtoconsumetheRESTrequestinCamel"></a>How to
consume the REST request in Camel</h3>
+<h3><a shape="rect"
name="CXFRS-ConsumingaRESTRequestSimpleBindingStyle"></a>Consuming a REST
Request - Simple Binding Style</h3>
+
+<p><b>Available as of Camel 2.11</b></p>
+
+<p>The <tt>Default</tt> binding style is rather low-level, requiring the user
to manually process the <tt>MessageContentsList</tt> object coming into the
route. Thus, it tightly couples the route logic with the method signature and
parameter indices of the JAX-RS operation. Somewhat inelegant, difficult and
error-prone.</p>
+
+<p>In contrast, the <tt>SimpleConsumer</tt> binding style performs the
following mappings, in order to <b>make the request data more accessible</b> to
you within the Camel Message:</p>
+
+<ul><li>JAX-RS Parameters (@HeaderParam, @QueryParam, etc.) are injected as IN
message headers. The header name matches the value of the
annotation.</li><li>The request entity (POJO or other type) becomes the IN
message body. If a single entity cannot be identified in the JAX-RS method
signature, it falls back to the original
<tt>MessageContentsList</tt>.</li><li>Binary <tt>@Multipart</tt> body parts
become IN message attachments, supporting <tt>DataHandler</tt>,
<tt>InputStream</tt>, <tt>DataSource</tt> and CXF's <tt>Attachment</tt>
class.</li><li>Non-binary <tt>@Multipart</tt> body parts are mapped as IN
message headers. The header name matches the Body Part name.</li></ul>
+
+
+<p>Additionally, the following rules apply to the <b>Response mapping</b>:</p>
+
+<ul><li>If the message body type is different to
<tt>javax.ws.rs.core.Response</tt> (user-built response), a new
<tt>Response</tt> is created and the message body is set as the entity (so long
it's not null). The response status code is taken from the
<tt>Exchange.HTTP_RESPONSE_CODE</tt> header, or defaults to 200 OK if not
present.</li><li>If the message body type is equal to
<tt>javax.ws.rs.core.Response</tt>, it means that the user has built a custom
response, and therefore it is respected and it becomes the final
response.</li><li>In all cases, Camel headers permitted by custom or default
<tt>HeaderFilterStrategy</tt> are added to the HTTP response.</li></ul>
+
+
+<h4><a shape="rect" name="CXFRS-EnablingtheSimpleBindingStyle"></a>Enabling
the Simple Binding Style</h4>
+
+<p>This binding style can be activated by setting the <tt>bindingStyle</tt>
parameter in the consumer endpoint to value <tt>SimpleConsumer</tt>:</p>
+
+<div class="code panel" style="border-width: 1px;"><div class="codeContent
panelContent">
+<pre class="code-java">
+ from(<span
class="code-quote">"cxf:bean:rsServer?bindingStyle=SimpleConsumer"</span>)
+ .to(<span class="code-quote">"log:TEST?showAll=<span
class="code-keyword">true</span>"</span>);
+</pre>
+</div></div>
+
+<h4><a shape="rect"
name="CXFRS-Examplesofrequestbindingwithdifferentmethodsignatures"></a>Examples
of request binding with different method signatures</h4>
+
+<p>Below is a list of method signatures along with the expected result from
the Simple binding.</p>
+
+<p><b><tt>public Response doAction(BusinessObject request);</tt></b><br
clear="none">
+Request payload is placed in IN message body, replacing the original
MessageContentsList.</p>
+
+<p><b><tt>public Response doAction(BusinessObject request,
@HeaderParam("abcd") String abcd, @QueryParam("defg") String defg);</tt></b><br
clear="none">
+Request payload placed in IN message body, replacing the original
MessageContentsList. Both request params mapped as IN message headers with
names abcd and defg.</p>
+
+<p><b><tt>public Response doAction(@HeaderParam("abcd") String abcd,
@QueryParam("defg") String defg);</tt></b><br clear="none">
+Both request params mapped as IN message headers with names abcd and defg. The
original MessageContentsList is preserved, even though it only contains the 2
parameters.</p>
+
+<p><b><tt>public Response doAction(@Multipart(value="body1") BusinessObject
request, @Multipart(value="body2") BusinessObject request2);</tt></b><br
clear="none">
+The first parameter is transferred as a header with name body1, and the second
one is mapped as header body2. The original MessageContentsList is preserved as
the IN message body.</p>
+
+<p><b><tt>public Response doAction(InputStream abcd);</tt></b><br clear="none">
+The InputStream is unwrapped from the MessageContentsList and preserved as the
IN message body. </p>
+
+<p><b><tt>public Response doAction(DataHandler abcd);</tt></b><br clear="none">
+The DataHandler is unwrapped from the MessageContentsList and preserved as the
IN message body. </p>
+
+<h4><a shape="rect" name="CXFRS-MoreexamplesoftheSimpleBindingStyle"></a>More
examples of the Simple Binding Style</h4>
+
+<p>Given a JAX-RS resource class with this method:</p>
+
+<div class="code panel" style="border-width: 1px;"><div class="codeContent
panelContent">
+<pre class="code-java">
+ @POST @Path(<span class="code-quote">"/customers/{type}"</span>)
+ <span class="code-keyword">public</span> Response newCustomer(Customer
customer, @PathParam(<span class="code-quote">"type"</span>) <span
class="code-object">String</span> type, @QueryParam(<span
class="code-quote">"active"</span>) @DefaultValue(<span
class="code-quote">"<span class="code-keyword">true</span>"</span>) <span
class="code-object">boolean</span> active) {
+ <span class="code-keyword">return</span> <span
class="code-keyword">null</span>;
+ }
+</pre>
+</div></div>
+
+<p>Serviced by the following route:</p>
+
+<div class="code panel" style="border-width: 1px;"><div class="codeContent
panelContent">
+<pre class="code-java">
+ from(<span
class="code-quote">"cxf:bean:rsServer?bindingStyle=SimpleConsumer"</span>)
+ .recipientList(simple(<span
class="code-quote">"direct:${header.operationName}"</span>));
+
+ from(<span class="code-quote">"direct:newCustomer"</span>)
+ .log(<span class="code-quote">"Request: type=${header.type},
active=${header.active}, customerData=${body}"</span>);
+</pre>
+</div></div>
+
+<p>The following HTTP request with XML payload (given that the Customer DTO is
JAXB-annotated):</p>
+
+<div class="code panel" style="border-width: 1px;"><div class="codeContent
panelContent">
+<pre class="code-java">
+POST /customers/gold?active=<span class="code-keyword">true</span>
+
+Payload:
+<Customer>
+ <fullName>Raul Kripalani</fullName>
+ <country>Spain</country>
+ <project>Apache Camel</project>
+</Customer>
+</pre>
+</div></div>
+
+<p>Will print the message:</p>
+
+<div class="code panel" style="border-width: 1px;"><div class="codeContent
panelContent">
+<pre class="code-java">
+Request: type=gold, active=<span class="code-keyword">true</span>,
customerData=<Customer.toString() representation>
+</pre>
+</div></div>
+
+<p>For more examples on how to process requests and write responses can be
found <a shape="rect" class="external-link"
href="https://svn.apache.org/repos/asf/camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/jaxrs/simplebinding/">here</a>.</p>
+
+<h3><a shape="rect"
name="CXFRS-ConsumingaRESTRequestDefaultBindingStyle"></a>Consuming a REST
Request - Default Binding Style</h3>
<p><a shape="rect" class="external-link"
href="http://cwiki.apache.org/CXF20DOC/jax-rs.html">CXF JAXRS front end</a>
implements the <a shape="rect" class="external-link"
href="https://jsr311.dev.java.net/" rel="nofollow">JAXRS(JSR311) API</a>, so we
can export the resources classes as a REST service. And we leverage the <a
shape="rect" class="external-link"
href="http://cwiki.apache.org/confluence/display/CXF20DOC/Invokers">CXF Invoker
API</a> to turn a REST request into a normal Java object method invocation.<br
clear="none">
Unlike the <tt>camel-restlet</tt>, you don't need to specify the URI template
within your restlet endpoint, CXF take care of the REST request URI to resource
class method mapping according to the JSR311 specification. All you need to do
in Camel is delegate this method request to a right processor or endpoint.</p>