Modified: websites/production/camel/content/restlet.html
==============================================================================
--- websites/production/camel/content/restlet.html (original)
+++ websites/production/camel/content/restlet.html Fri Aug 25 09:20:43 2017
@@ -36,17 +36,6 @@
<![endif]-->
- <link href='//camel.apache.org/styles/highlighter/styles/shCoreCamel.css'
rel='stylesheet' type='text/css' />
- <link href='//camel.apache.org/styles/highlighter/styles/shThemeCamel.css'
rel='stylesheet' type='text/css' />
- <script src='//camel.apache.org/styles/highlighter/scripts/shCore.js'
type='text/javascript'></script>
- <script src='//camel.apache.org/styles/highlighter/scripts/shBrushJava.js'
type='text/javascript'></script>
- <script src='//camel.apache.org/styles/highlighter/scripts/shBrushXml.js'
type='text/javascript'></script>
- <script src='//camel.apache.org/styles/highlighter/scripts/shBrushPlain.js'
type='text/javascript'></script>
-
- <script type="text/javascript">
- SyntaxHighlighter.defaults['toolbar'] = false;
- SyntaxHighlighter.all();
- </script>
<title>
Apache Camel: Restlet
@@ -86,140 +75,39 @@
<tbody>
<tr>
<td valign="top" width="100%">
-<div class="wiki-content maincontent"><h2
id="Restlet-RestletComponent">Restlet Component</h2><p>The
<strong>Restlet</strong> component provides <a shape="rect"
class="external-link" href="http://www.restlet.org" rel="nofollow">Restlet</a>
based <a shape="rect" href="endpoint.html">endpoints</a> for consuming and
producing RESTful resources.</p><p>Maven users will need to add the following
dependency to their <code>pom.xml</code> for this component:</p><div
class="code panel pdl" style="border-width: 1px;"><div class="codeContent
panelContent pdl">
-<script class="brush: xml; gutter: false; theme: Default"
type="syntaxhighlighter"><![CDATA[<dependency>
+<div class="wiki-content maincontent"><h2
id="Restlet-RestletComponent">Restlet Component</h2><p>The
<strong>Restlet</strong> component provides <a shape="rect"
class="external-link" href="http://www.restlet.org" rel="nofollow">Restlet</a>
based <a shape="rect" href="endpoint.html">endpoints</a> for consuming and
producing RESTful resources.</p><p>Maven users will need to add the following
dependency to their <code>pom.xml</code> for this component:</p><parameter
ac:name="">xml</parameter><plain-text-body><dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-restlet</artifactId>
<version>x.x.x</version>
<!-- use the same version as your Camel core version -->
</dependency>
-]]></script>
-</div></div><h3 id="Restlet-URIformat">URI format</h3><div class="code panel
pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
-<script class="brush: java; gutter: false; theme: Default"
type="syntaxhighlighter"><![CDATA[restlet:restletUrl[?options]
-]]></script>
-</div></div><p>Format of restletUrl:</p><div class="code panel pdl"
style="border-width: 1px;"><div class="codeContent panelContent pdl">
-<script class="brush: java; gutter: false; theme: Default"
type="syntaxhighlighter"><![CDATA[protocol://hostname[:port][/resourcePattern]
-]]></script>
-</div></div><p>Restlet promotes decoupling of protocol and application
concerns. The reference implementation of <a shape="rect" class="external-link"
href="http://www.noelios.com/products/restlet-engine" rel="nofollow">Restlet
Engine</a> supports a number of protocols. However, we have tested the HTTP
protocol only. The default port is port 80. We do not automatically switch
default port based on the protocol yet.</p><p>You can append query options to
the URI in the following format,
<code>?option=value&option=value&...</code></p><p> </p><div
class="confluence-information-macro
confluence-information-macro-information"><span class="aui-icon aui-icon-small
aui-iconfont-info confluence-information-macro-icon"></span><div
class="confluence-information-macro-body"><p>It seems Restlet is case sensitive
in understanding headers. For example to use content-type, use Content-Type,
and for location use Location and so on.</p></div></div><div
class="confluence-information-macro
confluence-information-macro-warning"><span class="aui-icon aui-icon-small
aui-iconfont-error confluence-information-macro-icon"></span><div
class="confluence-information-macro-body"><p>We have received a report about
drop in performance in camel-restlet in Camel 2.14.0 and 2.14.1. We have
reported this to the Restlet team in <a shape="rect" class="external-link"
href="https://github.com/restlet/restlet-framework-java/issues/996"
rel="nofollow">issue 996</a>. To remedy the issue then from Camel 2.14.2
onwards you can set synchronous=true as option on the endpoint uris, Or set it
on the RestletComponent as a global option so all endpoints inherit this
option.</p></div></div><p> </p><h3 id="Restlet-Options">Options</h3><div
class="table-wrap"><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>Descript
ion</p></th></tr><tr><td colspan="1" rowspan="1"
class="confluenceTd"><p><code>headerFilterStrategy=#</code><em>refName</em></p></td><td
colspan="1" rowspan="1" class="confluenceTd"><p>An instance of
<code>RestletHeaderFilterStrategy</code></p></td><td colspan="1" rowspan="1"
class="confluenceTd"><p>Use the <code>#</code> notation
(<code>headerFilterStrategy=#</code><em>refName</em>) to reference a header
filter strategy in the Camel Registry. The strategy will be plugged into the
restlet binding if it is
<code>HeaderFilterStrategyAware</code>.</p></td></tr><tr><td colspan="1"
rowspan="1"
class="confluenceTd"><p><code>restletBinding=#</code><em>refName</em></p></td><td
colspan="1" rowspan="1" class="confluenceTd"><p>An instance of
<code>DefaultRestletBinding</code></p></td><td colspan="1" rowspan="1"
class="confluenceTd"><p>The bean ID of a <code>RestletBinding</code> object in
the Camel Registry.</p></td></tr><tr><td colspan="1" rowspan="1"
class="confluenceTd"><p><code>restletMeth
od</code></p></td><td colspan="1" rowspan="1"
class="confluenceTd"><p><code>GET</code></p></td><td colspan="1" rowspan="1"
class="confluenceTd"><p>On a producer endpoint, specifies the request method to
use. On a consumer endpoint, specifies that the endpoint consumes only
<code>restletMethod</code> requests. The string value is converted to <a
shape="rect" class="external-link"
href="http://www.restlet.org/documentation/1.1/api/org/restlet/data/Method.html"
rel="nofollow">org.restlet.data.Method</a> by the
<code>Method.valueOf(String)</code> method.</p></td></tr><tr><td colspan="1"
rowspan="1" class="confluenceTd"><p><code>restletMethods</code></p></td><td
colspan="1" rowspan="1" class="confluenceTd"><p><em>None</em></p></td><td
colspan="1" rowspan="1" class="confluenceTd"><p><strong>Consumer only</strong>
Specify one or more methods separated by commas (e.g.
<code>restletMethods=post,put</code>) to be serviced by a restlet consumer
endpoint. If both <code>restletMethod</code> and
<code>restletMethods</code> options are specified, the
<code>restletMethod</code> setting is ignored.</p></td></tr><tr><td colspan="1"
rowspan="1"
class="confluenceTd"><p><code>restletRealm=#</code><em>refName</em></p></td><td
colspan="1" rowspan="1" class="confluenceTd"><p><code>null</code></p></td><td
colspan="1" rowspan="1" class="confluenceTd"><p>The bean ID of the Realm Map in
the Camel Registry.</p></td></tr><tr><td colspan="1" rowspan="1"
class="confluenceTd"><p><code>restletUriPatterns=#</code><em>refName</em></p></td><td
colspan="1" rowspan="1" class="confluenceTd"><p><em>None</em></p></td><td
colspan="1" rowspan="1" class="confluenceTd"><p><strong>Consumer only</strong>
Specify one ore more URI templates to be serviced by a restlet consumer
endpoint, using the <code>#</code> notation to reference a
<code>List<String></code> in the Camel Registry. If a URI pattern has
been defined in the endpoint URI, both the URI pattern defined in the endpoint
and the <code>restletU
riPatterns</code> option will be honored.</p></td></tr><tr><td colspan="1"
rowspan="1" class="confluenceTd"><p><code>throwExceptionOnFailure</code>
(<strong>2.6 or later</strong>)</p></td><td colspan="1" rowspan="1"
class="confluenceTd"><p><code>true</code></p></td><td colspan="1" rowspan="1"
class="confluenceTd"><p>*Producer only * Throws exception on a producer
failure.</p></td></tr><tr><td colspan="1" rowspan="1"
class="confluenceTd"><p><code>connectionTimeout</code></p></td><td colspan="1"
rowspan="1" class="confluenceTd"><p>300000</p></td><td colspan="1" rowspan="1"
class="confluenceTd"><p><strong>Since Camel 2.12.3</strong> <strong>Producer
only</strong> The Client will give up connection if the connection is timeout,
0 for unlimited wait.</p></td></tr><tr><td colspan="1" rowspan="1"
class="confluenceTd"><p><code>socketTimeout</code></p></td><td colspan="1"
rowspan="1" class="confluenceTd"><p>300000</p></td><td colspan="1" rowspan="1"
class="confluenceTd"><p><strong>Since Came
l 2.12.3</strong> <strong>Producer only</strong> The Client socket receive
timeout, 0 for unlimited wait.</p></td></tr><tr><td colspan="1" rowspan="1"
class="confluenceTd"><code>disableStreamCache</code></td><td colspan="1"
rowspan="1" class="confluenceTd"><code>false</code></td><td colspan="1"
rowspan="1" class="confluenceTd"><strong>Camel 2.14:</strong><span
style="color: rgb(0,0,0);"> Determines whether or not the raw input stream
from Jetty is cached or not (Camel will read the stream into a in
memory/overflow to file, </span><a shape="rect" class="external-link"
href="http://camel.apache.org/stream-caching.html" title="Stream
caching">Stream caching</a><span style="color: rgb(0,0,0);">) cache. By default
Camel will cache the Jetty input stream to support reading it multiple times to
ensure it Camel can retrieve all data from the stream. However you can set this
option to </span><code>true</code><span style="color:
rgb(0,0,0);"> when you for example need to a
ccess the raw stream, such as streaming it directly to a file or other
persistent store. DefaultRestletBinding will copy the request input stream into
a stream cache and put it into message body if this option
is </span><code>false</code><span style="color: rgb(0,0,0);"> to
support reading the stream multiple times.</span></td></tr><tr><td colspan="1"
rowspan="1" class="confluenceTd"><code>streamRepresentation</code></td><td
colspan="1" rowspan="1" class="confluenceTd"><code>false</code></td><td
colspan="1" rowspan="1" class="confluenceTd"><strong>Camel
2.16.4/2.17.2:</strong> <strong>Producer only</strong> <span
style="line-height: 1.42857;">Whether to support stream representation as
response from calling a REST service using the restlet producer. If the
response is streaming then this option can be enabled to use an </span><a
shape="rect" class="external-link" href="http://java.io" rel="nofollow"
style="line-height: 1.42857;">java.io</a><span style="line-height: 1.42857
;">.InputStream as the message body on the Camel Message body. If using this
option you may want to enable the autoCloseStream option as well to ensure the
input stream is closed when the Camel Exchange is done being routed. However if
you need to read the stream outside a Camel route, you may need </span><span
style="line-height: 1.42857;">to not auto close the
stream.</span></td></tr><tr><td colspan="1" rowspan="1"
class="confluenceTd"><code>autoCloseStream</code></td><td colspan="1"
rowspan="1" class="confluenceTd"><code>false</code></td><td colspan="1"
rowspan="1" class="confluenceTd"><strong>Camel
2.16.4/2.17.2:</strong><span> </span><strong>Producer only </strong><span
style="line-height: 1.42857;">Whether to auto close the stream representation
as response from calling a REST service using the restlet producer. If the
response is streaming and the option streamRepresentation is enabled then you
may want to auto close the InputStream from the streaming response to ensure
the input stream is closed when the Camel Exchange is done being routed.
However if you need to read the stream outside a Camel route, you may need to
not auto close the stream.</span></td></tr><tr><td colspan="1" rowspan="1"
class="confluenceTd"><code>cookieHandler</code></td><td colspan="1" rowspan="1"
class="confluenceTd"><code>null</code></td><td colspan="1" rowspan="1"
class="confluenceTd"><strong>Camel 2.19: Producer only:</strong> Configure a
cookie handler to maintain a HTTP session</td></tr></tbody></table></div><h3
id="Restlet-ComponentOptions">Component Options</h3><p>The Restlet component
can be configured with the following options. Notice these are
<strong>component</strong> options and cannot be configured on the endpoint,
see further below for an example.</p><div class="table-wrap"><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 col
span="1" rowspan="1" class="confluenceTh"><p>Description</p></th></tr><tr><td
colspan="1" rowspan="1"
class="confluenceTd"><p><code>controllerDaemon</code></p></td><td colspan="1"
rowspan="1" class="confluenceTd"><p><code>true</code></p></td><td colspan="1"
rowspan="1" class="confluenceTd"><p><strong>Camel 2.10:</strong> Indicates if
the controller thread should be a daemon (not blocking JVM
exit).</p></td></tr><tr><td colspan="1" rowspan="1"
class="confluenceTd"><p><code>controllerSleepTimeMs</code></p></td><td
colspan="1" rowspan="1" class="confluenceTd"><p><code>100</code></p></td><td
colspan="1" rowspan="1" class="confluenceTd"><p><strong>Camel 2.10:</strong>
Time for the controller thread to sleep between each
control.</p></td></tr><tr><td colspan="1" rowspan="1"
class="confluenceTd"><p><code>inboundBufferSize</code></p></td><td colspan="1"
rowspan="1" class="confluenceTd"><p><code>8192</code></p></td><td colspan="1"
rowspan="1" class="confluenceTd"><p><strong>Camel 2.10:</stro
ng> The size of the buffer when reading messages.</p></td></tr><tr><td
colspan="1" rowspan="1"
class="confluenceTd"><p><code>minThreads</code></p></td><td colspan="1"
rowspan="1" class="confluenceTd"><p><code>1</code></p></td><td colspan="1"
rowspan="1" class="confluenceTd"><p><strong>Camel 2.10:</strong> Minimum
threads waiting to service requests.</p></td></tr><tr><td colspan="1"
rowspan="1" class="confluenceTd"><p><code>maxThreads</code></p></td><td
colspan="1" rowspan="1" class="confluenceTd"><p><code>10</code></p></td><td
colspan="1" rowspan="1" class="confluenceTd"><p><strong>Camel 2.10:</strong>
Maximum threads that will service requests.</p></td></tr><tr><td colspan="1"
rowspan="1" class="confluenceTd"><code><span>lowThreads</span></code></td><td
colspan="1" rowspan="1" class="confluenceTd">8</td><td colspan="1" rowspan="1"
class="confluenceTd"><strong>Camel 2.13: </strong>Number of worker threads
determining when the connector is considered overloaded.</td></tr><tr><td cols
pan="1" rowspan="1" class="confluenceTd"><code>maxQueued</code></td><td
colspan="1" rowspan="1" class="confluenceTd">0</td><td colspan="1" rowspan="1"
class="confluenceTd"><strong>Camel 2.13: </strong>Maximum number of calls that
can be queued if there aren't any worker thread available to service them. If
the value is '0', then no queue is used and calls are rejected if no worker
thread is immediately available. If the value is '-1', then an unbounded queue
is used and calls are never rejected.</td></tr><tr><td colspan="1" rowspan="1"
class="confluenceTd"><p><code>maxConnectionsPerHost</code></p></td><td
colspan="1" rowspan="1" class="confluenceTd"><p><code>-1</code></p></td><td
colspan="1" rowspan="1" class="confluenceTd"><p><strong>Camel 2.10:</strong>
Maximum number of concurrent connections per host (IP
address).</p></td></tr><tr><td colspan="1" rowspan="1"
class="confluenceTd"><p><code>maxTotalConnections</code></p></td><td
colspan="1" rowspan="1" class="confluenceTd"><p><code
>-1</code></p></td><td colspan="1" rowspan="1"
>class="confluenceTd"><p><strong>Camel 2.10:</strong> Maximum number of
>concurrent connections in total.</p></td></tr><tr><td colspan="1" rowspan="1"
>class="confluenceTd"><p><code>outboundBufferSize</code></p></td><td
>colspan="1" rowspan="1" class="confluenceTd"><p><code>8192</code></p></td><td
>colspan="1" rowspan="1" class="confluenceTd"><p><strong>Camel 2.10:</strong>
>The size of the buffer when writing messages.</p></td></tr><tr><td
>colspan="1" rowspan="1"
>class="confluenceTd"><p><code>persistingConnections</code></p></td><td
>colspan="1" rowspan="1" class="confluenceTd"><p><code>true</code></p></td><td
>colspan="1" rowspan="1" class="confluenceTd"><p><strong>Camel 2.10:</strong>
>Indicates if connections should be kept alive after a
>call.</p></td></tr><tr><td colspan="1" rowspan="1"
>class="confluenceTd"><p><code>pipeliningConnections</code></p></td><td
>colspan="1" rowspan="1"
>class="confluenceTd"><p><code>false</code></p></td><td colspa
n="1" rowspan="1" class="confluenceTd"><p><strong>Camel 2.10:</strong>
Indicates if pipelining connections are supported.</p></td></tr><tr><td
colspan="1" rowspan="1"
class="confluenceTd"><p><code>threadMaxIdleTimeMs</code></p></td><td
colspan="1" rowspan="1" class="confluenceTd"><p><code>60000</code></p></td><td
colspan="1" rowspan="1" class="confluenceTd"><p><strong>Camel 2.10:</strong>
Time for an idle thread to wait for an operation before being
collected.</p></td></tr><tr><td colspan="1" rowspan="1"
class="confluenceTd"><p><code>useForwardedForHeader</code></p></td><td
colspan="1" rowspan="1" class="confluenceTd"><p><code>false</code></p></td><td
colspan="1" rowspan="1" class="confluenceTd"><p><strong>Camel 2.10:</strong>
Lookup the "X-Forwarded-For" header supported by popular proxies and caches and
uses it to populate the Request.getClientAddresses() method result. This
information is only safe for intermediary components within your local network.
Other addresses could easil
y be changed by setting a fake header and should not be trusted for serious
security checks.</p></td></tr><tr><td colspan="1" rowspan="1"
class="confluenceTd"><p><code>reuseAddress</code></p></td><td colspan="1"
rowspan="1" class="confluenceTd"><p><code>true</code></p></td><td colspan="1"
rowspan="1" class="confluenceTd"><p><strong>Camel 2.10.5/2.11.1:</strong>
Enable/disable the SO_REUSEADDR socket option. See
java.io.ServerSocket#reuseAddress property for additional
details.</p></td></tr><tr><td colspan="1" rowspan="1"
class="confluenceTd"><code>disableStreamCache</code></td><td colspan="1"
rowspan="1" class="confluenceTd"><code>false</code></td><td colspan="1"
rowspan="1" class="confluenceTd"><strong>Camel 2.14:</strong><span
style="color: rgb(0,0,0);"> Determines whether or not the raw input stream
from Jetty is cached or not (Camel will read the stream into a in
memory/overflow to file, </span><a shape="rect" class="external-link"
href="http://camel.apache.org/stream-
caching.html" title="Stream caching">Stream caching</a><span style="color:
rgb(0,0,0);">) cache. By default Camel will cache the Jetty input stream to
support reading it multiple times to ensure it Camel can retrieve all data from
the stream. However you can set this option
to </span><code>true</code><span style="color: rgb(0,0,0);"> when you
for example need to access the raw stream, such as streaming it directly to a
file or other persistent store. DefaultRestletBinding will copy the request
input stream into a stream cache and put it into message body if this option
is </span><code>false</code><span style="color: rgb(0,0,0);"> to
support reading the stream multiple times.</span></td></tr><tr><td colspan="1"
rowspan="1" class="confluenceTd">enabledConverters</td><td colspan="1"
rowspan="1" class="confluenceTd">null</td><td colspan="1" rowspan="1"
class="confluenceTd"><p><strong>Camel 2.18:</strong><span> By default, Restlet
engine loads all the extension it fin
ds at run-time and this option filter out all the converters except those
explicit listed using full qualified class name or simple class name.
</span>i.e. by setting <span style="line-height:
1.42857;">enabledConverters=JacksonConverter, GsonConverter the
RestletComponent will remove all the converters loaded by the <span>Restlet
engine except Jackson and Gson. Note that you still need to add the extensions
as dependency.</span></span></p></td></tr></tbody></table></div><h3
id="Restlet-MessageHeaders">Message Headers</h3><div
class="confluenceTableSmall"><div class="table-wrap"><table
class="confluenceTable"><tbody><tr><th colspan="1" rowspan="1"
class="confluenceTh"><p>Name</p></th><th colspan="1" rowspan="1"
class="confluenceTh"><p>Type</p></th><th colspan="1" rowspan="1"
class="confluenceTh"><p>Description</p></th></tr><tr><td colspan="1"
rowspan="1" class="confluenceTd"><p><code>Content-Type</code></p></td><td
colspan="1" rowspan="1" class="confluenceTd"><p><code>String</code><
/p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>Specifies the
content type, which can be set on the OUT message by the application/processor.
The value is the <code>content-type</code> of the response message. If this
header is not set, the content type is based on the object type of the OUT
message body. In Camel 2.3 onward, if the Content-Type header is specified in
the Camel IN message, the value of the header determine the content type for
the Restlet request message.   Otherwise, it is defaulted to
"application/x-www-form-urlencoded'. Prior to release 2.3, it is not possible
to change the request content type default.</p></td></tr><tr><td colspan="1"
rowspan="1"
class="confluenceTd"><p><code>CamelAcceptContentType</code></p></td><td
colspan="1" rowspan="1" class="confluenceTd"><p><code>String</code></p></td><td
colspan="1" rowspan="1" class="confluenceTd"><p><strong>Since Camel 2.9.3,
2.10.0:</strong> The HTTP Accept request header.</p></td></tr><tr><td co
lspan="1" rowspan="1"
class="confluenceTd"><p><code>CamelHttpMethod</code></p></td><td colspan="1"
rowspan="1" class="confluenceTd"><p><code>String</code></p></td><td colspan="1"
rowspan="1" class="confluenceTd"><p>The HTTP request method. This is set in the
IN message header.</p></td></tr><tr><td colspan="1" rowspan="1"
class="confluenceTd"><p><code>CamelHttpQuery</code></p></td><td colspan="1"
rowspan="1" class="confluenceTd"><p><code>String</code></p></td><td colspan="1"
rowspan="1" class="confluenceTd"><p>The query string of the request URI. It is
set on the IN message by <code>DefaultRestletBinding</code> when the restlet
component receives a request.</p></td></tr><tr><td colspan="1" rowspan="1"
class="confluenceTd"><p><code>CamelHttpResponseCode</code></p></td><td
colspan="1" rowspan="1" class="confluenceTd"><p><code>String</code> or
<code>Integer</code></p></td><td colspan="1" rowspan="1"
class="confluenceTd"><p>The response code can be set on the OUT message by the
applicati
on/processor. The value is the response code of the response message. If this
header is not set, the response code is set by the restlet runtime
engine.</p></td></tr><tr><td colspan="1" rowspan="1"
class="confluenceTd"><p><code>CamelHttpUri</code></p></td><td colspan="1"
rowspan="1" class="confluenceTd"><p><code>String</code></p></td><td colspan="1"
rowspan="1" class="confluenceTd"><p>The HTTP request URI. This is set in the IN
message header.</p></td></tr><tr><td colspan="1" rowspan="1"
class="confluenceTd"><p><code>CamelRestletLogin</code></p></td><td colspan="1"
rowspan="1" class="confluenceTd"><p><code>String</code></p></td><td colspan="1"
rowspan="1" class="confluenceTd"><p>Login name for basic authentication. It is
set on the IN message by the application and gets filtered before the restlet
request header by Camel.</p></td></tr><tr><td colspan="1" rowspan="1"
class="confluenceTd"><p><code>CamelRestletPassword</code></p></td><td
colspan="1" rowspan="1" class="confluenceTd"><p>
<code>String</code></p></td><td colspan="1" rowspan="1"
class="confluenceTd"><p>Password name for basic authentication. It is set on
the IN message by the application and gets filtered before the restlet request
header by Camel.</p></td></tr><tr><td colspan="1" rowspan="1"
class="confluenceTd"><p><code>CamelRestletRequest</code></p></td><td
colspan="1" rowspan="1"
class="confluenceTd"><p><code>Request</code></p></td><td colspan="1"
rowspan="1" class="confluenceTd"><p><strong>Camel 2.8:</strong> The
<code>org.restlet.Request</code> object which holds all request
details.</p></td></tr><tr><td colspan="1" rowspan="1"
class="confluenceTd"><p><code>CamelRestletResponse</code></p></td><td
colspan="1" rowspan="1"
class="confluenceTd"><p><code>Response</code></p></td><td colspan="1"
rowspan="1" class="confluenceTd"><p><strong>Camel 2.8:</strong> The
<code>org.restlet.Response</code> object. You can use this to create responses
using the API from Restlet. See examples below.</p></td></tr><tr
><td colspan="1" rowspan="1"
>class="confluenceTd"><p><code>org.restlet.*</code></p></td><td colspan="1"
>rowspan="1" class="confluenceTd"><p> </p></td><td colspan="1"
>rowspan="1" class="confluenceTd"><p>Attributes of a Restlet message that get
>propagated to Camel IN headers.</p></td></tr><tr><td colspan="1" rowspan="1"
>class="confluenceTd"><p><code>cache-control</code></p></td><td colspan="1"
>rowspan="1" class="confluenceTd"><p><code>String</code> or
><code>List<CacheDirective></code></p></td><td colspan="1" rowspan="1"
>class="confluenceTd"><p><strong>Camel 2.11:</strong> User can set the
>cache-control with the String value or the List of CacheDirective of Restlet
>from the camel message header.</p></td></tr></tbody></table></div></div>
-
-
-<h3 id="Restlet-MessageBody">Message Body</h3><p>Camel will store the restlet
response from the external server on the OUT body. All headers from the IN
message will be copied to the OUT message, so that headers are preserved during
routing.</p><h3 id="Restlet-Samples">Samples</h3><h4
id="Restlet-RestletEndpointwithAuthentication">Restlet Endpoint with
Authentication</h4><p>The following route starts a <code>restlet</code>
consumer endpoint that listens for <code>POST</code> requests on <a
shape="rect" class="external-link" href="http://localhost:8080"
rel="nofollow">http://localhost:8080</a>. The processor creates a response that
echoes the request body and the value of the <code>id</code> header.</p><div
class="code panel pdl" style="border-width: 1px;"><div class="codeContent
panelContent pdl">
-<script class="brush: java; gutter: false; theme: Default"
type="syntaxhighlighter"><![CDATA[
-from("restlet:http://localhost:" + port +
"/securedOrders?restletMethod=post&restletRealm=#realm").process(new
Processor() {
- public void process(Exchange exchange) throws Exception {
- exchange.getOut().setBody(
- "received [" + exchange.getIn().getBody(String.class)
- + "] as an order id = "
- + exchange.getIn().getHeader("id"));
- }
-});
-]]></script>
-</div></div>The <code>restletRealm</code> setting in the URI query is used to
look up a Realm Map in the registry. If this option is specified, the restlet
consumer uses the information to authenticate user logins. Only
<em>authenticated</em> requests can access the resources. In this sample, we
create a Spring application context that serves as a registry. The bean ID of
the Realm Map should match the <em>restletRealmRef</em>.<div class="code panel
pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
-<script class="brush: xml; gutter: false; theme: Default"
type="syntaxhighlighter"><![CDATA[
-<util:map id="realm">
- <entry key="admin" value="foo" />
- <entry key="bar" value="foo" />
-</util:map>
-]]></script>
-</div></div>The following sample starts a <code>direct</code> endpoint that
sends requests to the server on <a shape="rect" class="external-link"
href="http://localhost:8080" rel="nofollow">http://localhost:8080</a> (that is,
our restlet consumer endpoint).<div class="code panel pdl" style="border-width:
1px;"><div class="codeContent panelContent pdl">
-<script class="brush: java; gutter: false; theme: Default"
type="syntaxhighlighter"><![CDATA[
-// Note: restletMethod and restletRealmRef are stripped
-// from the query before a request is sent as they are
-// only processed by Camel.
-from("direct:start-auth").to("restlet:http://localhost:" +
port + "/securedOrders?restletMethod=post");
-]]></script>
-</div></div>That is all we need. We are ready to send a request and try out
the restlet component:<div class="code panel pdl" style="border-width:
1px;"><div class="codeContent panelContent pdl">
-<script class="brush: java; gutter: false; theme: Default"
type="syntaxhighlighter"><![CDATA[
-final String id = "89531";
-
-Map<String, Object> headers = new HashMap<String, Object>();
-headers.put(RestletConstants.RESTLET_LOGIN, "admin");
-headers.put(RestletConstants.RESTLET_PASSWORD, "foo");
-headers.put(Exchange.CONTENT_TYPE, MediaType.APPLICATION_XML);
-headers.put("id", id);
-
-String response = template.requestBodyAndHeaders(
- "direct:start-auth", "<order foo='1'/>",
headers, String.class);
-]]></script>
-</div></div>The sample client sends a request to the
<code>direct:start-auth</code> endpoint with the following
headers:<ul><li><code>CamelRestletLogin</code> (used internally by
Camel)</li><li><code>CamelRestletPassword</code> (used internally by
Camel)</li><li><code>id</code> (application header)</li></ul><div
class="confluence-information-macro
confluence-information-macro-information"><p class="title">Note</p><span
class="aui-icon aui-icon-small aui-iconfont-info
confluence-information-macro-icon"></span><div
class="confluence-information-macro-body"><p><code>org.apache.camel.restlet.auth.login</code>
and <code>org.apache.camel.restlet.auth.password</code> will not be propagated
as Restlet header.</p></div></div><p>The sample client gets a response like the
following:</p><div class="code panel pdl" style="border-width: 1px;"><div
class="codeContent panelContent pdl">
-<script class="brush: text; gutter: false; theme: Default"
type="syntaxhighlighter"><![CDATA[received [<order foo='1'/>] as
an order id = 89531
-]]></script>
-</div></div><h4
id="Restlet-SinglerestletendpointtoservicemultiplemethodsandURItemplates">Single
restlet endpoint to service multiple methods and URI templates</h4><p>It is
possible to create a single route to service multiple HTTP methods using the
<code>restletMethods</code> option. This snippet also shows how to retrieve the
request method from the header:</p><div class="code panel pdl"
style="border-width: 1px;"><div class="codeContent panelContent pdl">
-<script class="brush: java; gutter: false; theme: Default"
type="syntaxhighlighter"><![CDATA[
-from("restlet:http://localhost:" + portNum +
"/users/{username}?restletMethods=post,get,put")
- .process(new Processor() {
- public void process(Exchange exchange) throws Exception {
- // echo the method
-
exchange.getOut().setBody(exchange.getIn().getHeader(Exchange.HTTP_METHOD,
String.class));
- }
- });
-]]></script>
-</div></div>In addition to servicing multiple methods, the next snippet shows
how to create an endpoint that supports multiple URI templates using the
<code>restletUriPatterns</code> option. The request URI is available in the
header of the IN message as well. If a URI pattern has been defined in the
endpoint URI (which is not the case in this sample), both the URI pattern
defined in the endpoint and the <code>restletUriPatterns</code> option will be
honored.<div class="code panel pdl" style="border-width: 1px;"><div
class="codeContent panelContent pdl">
-<script class="brush: java; gutter: false; theme: Default"
type="syntaxhighlighter"><![CDATA[
-from("restlet:http://localhost:" + portNum +
"?restletMethods=post,get&restletUriPatterns=#uriTemplates")
- .process(new Processor() {
- public void process(Exchange exchange) throws Exception {
- // echo the method
- String uri = exchange.getIn().getHeader(Exchange.HTTP_URI,
String.class);
- String out = exchange.getIn().getHeader(Exchange.HTTP_METHOD,
String.class);
- if (("http://localhost:" + portNum +
"/users/homer").equals(uri)) {
- exchange.getOut().setBody(out + " " +
exchange.getIn().getHeader("username", String.class));
- } else if (("http://localhost:" + portNum +
"/atom/collection/foo/component/bar").equals(uri)) {
- exchange.getOut().setBody(out + " " +
exchange.getIn().getHeader("id", String.class)
- + " " +
exchange.getIn().getHeader("cid", String.class));
- }
- }
- });
-]]></script>
-</div></div>The <code>restletUriPatterns=#uriTemplates</code> option
references the <code>List<String></code> bean defined in the Spring XML
configuration.<div class="code panel pdl" style="border-width: 1px;"><div
class="codeContent panelContent pdl">
-<script class="brush: xml; gutter: false; theme: Default"
type="syntaxhighlighter"><![CDATA[<util:list id="uriTemplates">
+</plain-text-body><h3 id="Restlet-URIformat">URI format</h3><parameter
ac:name="language">java</parameter><plain-text-body>restlet:restletUrl[?options]
+</plain-text-body><p>Format of restletUrl:</p><parameter
ac:name="language">java</parameter><plain-text-body>protocol://hostname[:port][/resourcePattern]
+</plain-text-body><p>Restlet promotes decoupling of protocol and application
concerns. The reference implementation of <a shape="rect" class="external-link"
href="http://www.noelios.com/products/restlet-engine" rel="nofollow">Restlet
Engine</a> supports a number of protocols. However, we have tested the HTTP
protocol only. The default port is port 80. We do not automatically switch
default port based on the protocol yet.</p><p>You can append query options to
the URI in the following format,
<code>?option=value&option=value&...</code></p><p> </p><rich-text-body><p>It
seems Restlet is case sensitive in understanding headers. For example to use
content-type, use Content-Type, and for location use Location and so
on.</p></rich-text-body><rich-text-body><p>We have received a report about drop
in performance in camel-restlet in Camel 2.14.0 and 2.14.1. We have reported
this to the Restlet team in <a shape="rect" class="external-link"
href="https://github.com/restlet/restlet-f
ramework-java/issues/996" rel="nofollow">issue 996</a>. To remedy the issue
then from Camel 2.14.2 onwards you can set synchronous=true as option on the
endpoint uris, Or set it on the RestletComponent as a global option so all
endpoints inherit this option.</p></rich-text-body><p> </p><h3
id="Restlet-Options">Options</h3><div class="table-wrap"><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><code>headerFilterStrategy=#</code><em>refName</em></p></td><td
colspan="1" rowspan="1" class="confluenceTd"><p>An instance of
<code>RestletHeaderFilterStrategy</code></p></td><td colspan="1" rowspan="1"
class="confluenceTd"><p>Use the <code>#</code> notation
(<code>headerFilterStrategy=#</code><em>refName</em>) to reference a h
eader filter strategy in the Camel Registry. The strategy will be plugged into
the restlet binding if it is
<code>HeaderFilterStrategyAware</code>.</p></td></tr><tr><td colspan="1"
rowspan="1"
class="confluenceTd"><p><code>restletBinding=#</code><em>refName</em></p></td><td
colspan="1" rowspan="1" class="confluenceTd"><p>An instance of
<code>DefaultRestletBinding</code></p></td><td colspan="1" rowspan="1"
class="confluenceTd"><p>The bean ID of a <code>RestletBinding</code> object in
the Camel Registry.</p></td></tr><tr><td colspan="1" rowspan="1"
class="confluenceTd"><p><code>restletMethod</code></p></td><td colspan="1"
rowspan="1" class="confluenceTd"><p><code>GET</code></p></td><td colspan="1"
rowspan="1" class="confluenceTd"><p>On a producer endpoint, specifies the
request method to use. On a consumer endpoint, specifies that the endpoint
consumes only <code>restletMethod</code> requests. The string value is
converted to <a shape="rect" class="external-link" href="http://www.rest
let.org/documentation/1.1/api/org/restlet/data/Method.html"
rel="nofollow">org.restlet.data.Method</a> by the
<code>Method.valueOf(String)</code> method.</p></td></tr><tr><td colspan="1"
rowspan="1" class="confluenceTd"><p><code>restletMethods</code></p></td><td
colspan="1" rowspan="1" class="confluenceTd"><p><em>None</em></p></td><td
colspan="1" rowspan="1" class="confluenceTd"><p><strong>Consumer only</strong>
Specify one or more methods separated by commas (e.g.
<code>restletMethods=post,put</code>) to be serviced by a restlet consumer
endpoint. If both <code>restletMethod</code> and <code>restletMethods</code>
options are specified, the <code>restletMethod</code> setting is
ignored.</p></td></tr><tr><td colspan="1" rowspan="1"
class="confluenceTd"><p><code>restletRealm=#</code><em>refName</em></p></td><td
colspan="1" rowspan="1" class="confluenceTd"><p><code>null</code></p></td><td
colspan="1" rowspan="1" class="confluenceTd"><p>The bean ID of the Realm Map in
the Camel Registry
.</p></td></tr><tr><td colspan="1" rowspan="1"
class="confluenceTd"><p><code>restletUriPatterns=#</code><em>refName</em></p></td><td
colspan="1" rowspan="1" class="confluenceTd"><p><em>None</em></p></td><td
colspan="1" rowspan="1" class="confluenceTd"><p><strong>Consumer only</strong>
Specify one ore more URI templates to be serviced by a restlet consumer
endpoint, using the <code>#</code> notation to reference a
<code>List<String></code> in the Camel Registry. If a URI pattern has
been defined in the endpoint URI, both the URI pattern defined in the endpoint
and the <code>restletUriPatterns</code> option will be
honored.</p></td></tr><tr><td colspan="1" rowspan="1"
class="confluenceTd"><p><code>throwExceptionOnFailure</code> (<strong>2.6 or
later</strong>)</p></td><td colspan="1" rowspan="1"
class="confluenceTd"><p><code>true</code></p></td><td colspan="1" rowspan="1"
class="confluenceTd"><p>*Producer only * Throws exception on a producer
failure.</p></td></tr><tr><td colspan
="1" rowspan="1"
class="confluenceTd"><p><code>connectionTimeout</code></p></td><td colspan="1"
rowspan="1" class="confluenceTd"><p>300000</p></td><td colspan="1" rowspan="1"
class="confluenceTd"><p><strong>Since Camel 2.12.3</strong> <strong>Producer
only</strong> The Client will give up connection if the connection is timeout,
0 for unlimited wait.</p></td></tr><tr><td colspan="1" rowspan="1"
class="confluenceTd"><p><code>socketTimeout</code></p></td><td colspan="1"
rowspan="1" class="confluenceTd"><p>300000</p></td><td colspan="1" rowspan="1"
class="confluenceTd"><p><strong>Since Camel 2.12.3</strong> <strong>Producer
only</strong> The Client socket receive timeout, 0 for unlimited
wait.</p></td></tr><tr><td colspan="1" rowspan="1"
class="confluenceTd"><code>disableStreamCache</code></td><td colspan="1"
rowspan="1" class="confluenceTd"><code>false</code></td><td colspan="1"
rowspan="1" class="confluenceTd"><strong>Camel 2.14:</strong><span
style="color: rgb(0,0,0);"> Determi
nes whether or not the raw input stream from Jetty is cached or not (Camel
will read the stream into a in memory/overflow to file, </span><a
shape="rect" class="external-link"
href="http://camel.apache.org/stream-caching.html" title="Stream
caching">Stream caching</a><span style="color: rgb(0,0,0);">) cache. By default
Camel will cache the Jetty input stream to support reading it multiple times to
ensure it Camel can retrieve all data from the stream. However you can set this
option to </span><code>true</code><span style="color:
rgb(0,0,0);"> when you for example need to access the raw stream, such as
streaming it directly to a file or other persistent store.
DefaultRestletBinding will copy the request input stream into a stream cache
and put it into message body if this option
is </span><code>false</code><span style="color: rgb(0,0,0);"> to
support reading the stream multiple times.</span></td></tr><tr><td colspan="1"
rowspan="1" class="confluenceTd"><code>
streamRepresentation</code></td><td colspan="1" rowspan="1"
class="confluenceTd"><code>false</code></td><td colspan="1" rowspan="1"
class="confluenceTd"><strong>Camel 2.16.4/2.17.2:</strong> <strong>Producer
only</strong> <span style="line-height: 1.42857;">Whether to support stream
representation as response from calling a REST service using the restlet
producer. If the response is streaming then this option can be enabled to use
an </span><a shape="rect" class="external-link" href="http://java.io"
rel="nofollow" style="line-height: 1.42857;">java.io</a><span
style="line-height: 1.42857;">.InputStream as the message body on the Camel
Message body. If using this option you may want to enable the autoCloseStream
option as well to ensure the input stream is closed when the Camel Exchange is
done being routed. However if you need to read the stream outside a Camel
route, you may need </span><span style="line-height: 1.42857;">to not auto
close the stream.</span></td></tr><tr><td colspa
n="1" rowspan="1" class="confluenceTd"><code>autoCloseStream</code></td><td
colspan="1" rowspan="1" class="confluenceTd"><code>false</code></td><td
colspan="1" rowspan="1" class="confluenceTd"><strong>Camel
2.16.4/2.17.2:</strong><span> </span><strong>Producer only </strong><span
style="line-height: 1.42857;">Whether to auto close the stream representation
as response from calling a REST service using the restlet producer. If the
response is streaming and the option streamRepresentation is enabled then you
may want to auto close the InputStream from the streaming response to ensure
the input stream is closed when the Camel Exchange is done being routed.
However if you need to read the stream outside a Camel route, you may need to
not auto close the stream.</span></td></tr><tr><td colspan="1" rowspan="1"
class="confluenceTd"><code>cookieHandler</code></td><td colspan="1" rowspan="1"
class="confluenceTd"><code>null</code></td><td colspan="1" rowspan="1"
class="confluenceTd"><stro
ng>Camel 2.19: Producer only:</strong> Configure a cookie handler to maintain
a HTTP session</td></tr></tbody></table></div><h3
id="Restlet-ComponentOptions">Component Options</h3><p>The Restlet component
can be configured with the following options. Notice these are
<strong>component</strong> options and cannot be configured on the endpoint,
see further below for an example.</p><div class="table-wrap"><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><code>controllerDaemon</code></p></td><td
colspan="1" rowspan="1" class="confluenceTd"><p><code>true</code></p></td><td
colspan="1" rowspan="1" class="confluenceTd"><p><strong>Camel 2.10:</strong>
Indicates if the controller thread should be a daemon (not blocking JVM exit).</
p></td></tr><tr><td colspan="1" rowspan="1"
class="confluenceTd"><p><code>controllerSleepTimeMs</code></p></td><td
colspan="1" rowspan="1" class="confluenceTd"><p><code>100</code></p></td><td
colspan="1" rowspan="1" class="confluenceTd"><p><strong>Camel 2.10:</strong>
Time for the controller thread to sleep between each
control.</p></td></tr><tr><td colspan="1" rowspan="1"
class="confluenceTd"><p><code>inboundBufferSize</code></p></td><td colspan="1"
rowspan="1" class="confluenceTd"><p><code>8192</code></p></td><td colspan="1"
rowspan="1" class="confluenceTd"><p><strong>Camel 2.10:</strong> The size of
the buffer when reading messages.</p></td></tr><tr><td colspan="1" rowspan="1"
class="confluenceTd"><p><code>minThreads</code></p></td><td colspan="1"
rowspan="1" class="confluenceTd"><p><code>1</code></p></td><td colspan="1"
rowspan="1" class="confluenceTd"><p><strong>Camel 2.10:</strong> Minimum
threads waiting to service requests.</p></td></tr><tr><td colspan="1"
rowspan="1" class=
"confluenceTd"><p><code>maxThreads</code></p></td><td colspan="1" rowspan="1"
class="confluenceTd"><p><code>10</code></p></td><td colspan="1" rowspan="1"
class="confluenceTd"><p><strong>Camel 2.10:</strong> Maximum threads that will
service requests.</p></td></tr><tr><td colspan="1" rowspan="1"
class="confluenceTd"><code><span>lowThreads</span></code></td><td colspan="1"
rowspan="1" class="confluenceTd">8</td><td colspan="1" rowspan="1"
class="confluenceTd"><strong>Camel 2.13: </strong>Number of worker threads
determining when the connector is considered overloaded.</td></tr><tr><td
colspan="1" rowspan="1" class="confluenceTd"><code>maxQueued</code></td><td
colspan="1" rowspan="1" class="confluenceTd">0</td><td colspan="1" rowspan="1"
class="confluenceTd"><strong>Camel 2.13: </strong>Maximum number of calls that
can be queued if there aren't any worker thread available to service them. If
the value is '0', then no queue is used and calls are rejected if no worker
thread is immediate
ly available. If the value is '-1', then an unbounded queue is used and calls
are never rejected.</td></tr><tr><td colspan="1" rowspan="1"
class="confluenceTd"><p><code>maxConnectionsPerHost</code></p></td><td
colspan="1" rowspan="1" class="confluenceTd"><p><code>-1</code></p></td><td
colspan="1" rowspan="1" class="confluenceTd"><p><strong>Camel 2.10:</strong>
Maximum number of concurrent connections per host (IP
address).</p></td></tr><tr><td colspan="1" rowspan="1"
class="confluenceTd"><p><code>maxTotalConnections</code></p></td><td
colspan="1" rowspan="1" class="confluenceTd"><p><code>-1</code></p></td><td
colspan="1" rowspan="1" class="confluenceTd"><p><strong>Camel 2.10:</strong>
Maximum number of concurrent connections in total.</p></td></tr><tr><td
colspan="1" rowspan="1"
class="confluenceTd"><p><code>outboundBufferSize</code></p></td><td colspan="1"
rowspan="1" class="confluenceTd"><p><code>8192</code></p></td><td colspan="1"
rowspan="1" class="confluenceTd"><p><strong>Camel
2.10:</strong> The size of the buffer when writing
messages.</p></td></tr><tr><td colspan="1" rowspan="1"
class="confluenceTd"><p><code>persistingConnections</code></p></td><td
colspan="1" rowspan="1" class="confluenceTd"><p><code>true</code></p></td><td
colspan="1" rowspan="1" class="confluenceTd"><p><strong>Camel 2.10:</strong>
Indicates if connections should be kept alive after a
call.</p></td></tr><tr><td colspan="1" rowspan="1"
class="confluenceTd"><p><code>pipeliningConnections</code></p></td><td
colspan="1" rowspan="1" class="confluenceTd"><p><code>false</code></p></td><td
colspan="1" rowspan="1" class="confluenceTd"><p><strong>Camel 2.10:</strong>
Indicates if pipelining connections are supported.</p></td></tr><tr><td
colspan="1" rowspan="1"
class="confluenceTd"><p><code>threadMaxIdleTimeMs</code></p></td><td
colspan="1" rowspan="1" class="confluenceTd"><p><code>60000</code></p></td><td
colspan="1" rowspan="1" class="confluenceTd"><p><strong>Camel 2.10:</strong>
Time for an
idle thread to wait for an operation before being
collected.</p></td></tr><tr><td colspan="1" rowspan="1"
class="confluenceTd"><p><code>useForwardedForHeader</code></p></td><td
colspan="1" rowspan="1" class="confluenceTd"><p><code>false</code></p></td><td
colspan="1" rowspan="1" class="confluenceTd"><p><strong>Camel 2.10:</strong>
Lookup the "X-Forwarded-For" header supported by popular proxies and caches and
uses it to populate the Request.getClientAddresses() method result. This
information is only safe for intermediary components within your local network.
Other addresses could easily be changed by setting a fake header and should not
be trusted for serious security checks.</p></td></tr><tr><td colspan="1"
rowspan="1" class="confluenceTd"><p><code>reuseAddress</code></p></td><td
colspan="1" rowspan="1" class="confluenceTd"><p><code>true</code></p></td><td
colspan="1" rowspan="1" class="confluenceTd"><p><strong>Camel
2.10.5/2.11.1:</strong> Enable/disable the SO_REUSEADDR socket
option. See java.io.ServerSocket#reuseAddress property for additional
details.</p></td></tr><tr><td colspan="1" rowspan="1"
class="confluenceTd"><code>disableStreamCache</code></td><td colspan="1"
rowspan="1" class="confluenceTd"><code>false</code></td><td colspan="1"
rowspan="1" class="confluenceTd"><strong>Camel 2.14:</strong><span
style="color: rgb(0,0,0);"> Determines whether or not the raw input stream
from Jetty is cached or not (Camel will read the stream into a in
memory/overflow to file, </span><a shape="rect" class="external-link"
href="http://camel.apache.org/stream-caching.html" title="Stream
caching">Stream caching</a><span style="color: rgb(0,0,0);">) cache. By default
Camel will cache the Jetty input stream to support reading it multiple times to
ensure it Camel can retrieve all data from the stream. However you can set this
option to </span><code>true</code><span style="color:
rgb(0,0,0);"> when you for example need to access the raw stream, such
as streaming it directly to a file or other persistent store.
DefaultRestletBinding will copy the request input stream into a stream cache
and put it into message body if this option
is </span><code>false</code><span style="color: rgb(0,0,0);"> to
support reading the stream multiple times.</span></td></tr><tr><td colspan="1"
rowspan="1" class="confluenceTd">enabledConverters</td><td colspan="1"
rowspan="1" class="confluenceTd">null</td><td colspan="1" rowspan="1"
class="confluenceTd"><p><strong>Camel 2.18:</strong><span> By default, Restlet
engine loads all the extension it finds at run-time and this option filter out
all the converters except those explicit listed using full qualified class name
or simple class name. </span>i.e. by setting <span style="line-height:
1.42857;">enabledConverters=JacksonConverter, GsonConverter the
RestletComponent will remove all the converters loaded by the <span>Restlet
engine except Jackson and Gson. Note that you still need to add the ex
tensions as dependency.</span></span></p></td></tr></tbody></table></div><h3
id="Restlet-MessageHeaders">Message Headers</h3><parameter
ac:name="class">confluenceTableSmall</parameter><rich-text-body><div
class="table-wrap"><table class="confluenceTable"><tbody><tr><th colspan="1"
rowspan="1" class="confluenceTh"><p>Name</p></th><th colspan="1" rowspan="1"
class="confluenceTh"><p>Type</p></th><th colspan="1" rowspan="1"
class="confluenceTh"><p>Description</p></th></tr><tr><td colspan="1"
rowspan="1" class="confluenceTd"><p><code>Content-Type</code></p></td><td
colspan="1" rowspan="1" class="confluenceTd"><p><code>String</code></p></td><td
colspan="1" rowspan="1" class="confluenceTd"><p>Specifies the content type,
which can be set on the OUT message by the application/processor. The value is
the <code>content-type</code> of the response message. If this header is not
set, the content type is based on the object type of the OUT message body. In
Camel 2.3 onward, if the Content-Type he
ader is specified in the Camel IN message, the value of the header determine
the content type for the Restlet request message.   Otherwise, it is
defaulted to "application/x-www-form-urlencoded'. Prior to release 2.3, it is
not possible to change the request content type default.</p></td></tr><tr><td
colspan="1" rowspan="1"
class="confluenceTd"><p><code>CamelAcceptContentType</code></p></td><td
colspan="1" rowspan="1" class="confluenceTd"><p><code>String</code></p></td><td
colspan="1" rowspan="1" class="confluenceTd"><p><strong>Since Camel 2.9.3,
2.10.0:</strong> The HTTP Accept request header.</p></td></tr><tr><td
colspan="1" rowspan="1"
class="confluenceTd"><p><code>CamelHttpMethod</code></p></td><td colspan="1"
rowspan="1" class="confluenceTd"><p><code>String</code></p></td><td colspan="1"
rowspan="1" class="confluenceTd"><p>The HTTP request method. This is set in the
IN message header.</p></td></tr><tr><td colspan="1" rowspan="1"
class="confluenceTd"><p><code>CamelHttp
Query</code></p></td><td colspan="1" rowspan="1"
class="confluenceTd"><p><code>String</code></p></td><td colspan="1" rowspan="1"
class="confluenceTd"><p>The query string of the request URI. It is set on the
IN message by <code>DefaultRestletBinding</code> when the restlet component
receives a request.</p></td></tr><tr><td colspan="1" rowspan="1"
class="confluenceTd"><p><code>CamelHttpResponseCode</code></p></td><td
colspan="1" rowspan="1" class="confluenceTd"><p><code>String</code> or
<code>Integer</code></p></td><td colspan="1" rowspan="1"
class="confluenceTd"><p>The response code can be set on the OUT message by the
application/processor. The value is the response code of the response message.
If this header is not set, the response code is set by the restlet runtime
engine.</p></td></tr><tr><td colspan="1" rowspan="1"
class="confluenceTd"><p><code>CamelHttpUri</code></p></td><td colspan="1"
rowspan="1" class="confluenceTd"><p><code>String</code></p></td><td colspan="1"
rowspan="1
" class="confluenceTd"><p>The HTTP request URI. This is set in the IN message
header.</p></td></tr><tr><td colspan="1" rowspan="1"
class="confluenceTd"><p><code>CamelRestletLogin</code></p></td><td colspan="1"
rowspan="1" class="confluenceTd"><p><code>String</code></p></td><td colspan="1"
rowspan="1" class="confluenceTd"><p>Login name for basic authentication. It is
set on the IN message by the application and gets filtered before the restlet
request header by Camel.</p></td></tr><tr><td colspan="1" rowspan="1"
class="confluenceTd"><p><code>CamelRestletPassword</code></p></td><td
colspan="1" rowspan="1" class="confluenceTd"><p><code>String</code></p></td><td
colspan="1" rowspan="1" class="confluenceTd"><p>Password name for basic
authentication. It is set on the IN message by the application and gets
filtered before the restlet request header by Camel.</p></td></tr><tr><td
colspan="1" rowspan="1"
class="confluenceTd"><p><code>CamelRestletRequest</code></p></td><td
colspan="1" rowspan
="1" class="confluenceTd"><p><code>Request</code></p></td><td colspan="1"
rowspan="1" class="confluenceTd"><p><strong>Camel 2.8:</strong> The
<code>org.restlet.Request</code> object which holds all request
details.</p></td></tr><tr><td colspan="1" rowspan="1"
class="confluenceTd"><p><code>CamelRestletResponse</code></p></td><td
colspan="1" rowspan="1"
class="confluenceTd"><p><code>Response</code></p></td><td colspan="1"
rowspan="1" class="confluenceTd"><p><strong>Camel 2.8:</strong> The
<code>org.restlet.Response</code> object. You can use this to create responses
using the API from Restlet. See examples below.</p></td></tr><tr><td
colspan="1" rowspan="1"
class="confluenceTd"><p><code>org.restlet.*</code></p></td><td colspan="1"
rowspan="1" class="confluenceTd"><p> </p></td><td colspan="1" rowspan="1"
class="confluenceTd"><p>Attributes of a Restlet message that get propagated to
Camel IN headers.</p></td></tr><tr><td colspan="1" rowspan="1"
class="confluenceTd"><p><code>cache-c
ontrol</code></p></td><td colspan="1" rowspan="1"
class="confluenceTd"><p><code>String</code> or
<code>List<CacheDirective></code></p></td><td colspan="1" rowspan="1"
class="confluenceTd"><p><strong>Camel 2.11:</strong> User can set the
cache-control with the String value or the List of CacheDirective of Restlet
from the camel message
header.</p></td></tr></tbody></table></div></rich-text-body><h3
id="Restlet-MessageBody">Message Body</h3><p>Camel will store the restlet
response from the external server on the OUT body. All headers from the IN
message will be copied to the OUT message, so that headers are preserved during
routing.</p><h3 id="Restlet-Samples">Samples</h3><h4
id="Restlet-RestletEndpointwithAuthentication">Restlet Endpoint with
Authentication</h4><p>The following route starts a <code>restlet</code>
consumer endpoint that listens for <code>POST</code> requests on <a
shape="rect" class="external-link" href="http://localhost:8080"
rel="nofollow">http://localhost:808
0</a>. The processor creates a response that echoes the request body and the
value of the <code>id</code>
header.<plain-text-body>{snippet:id=consumer_route|lang=java|url=camel/trunk/components/camel-restlet/src/test/java/org/apache/camel/component/restlet/route/TestRouteBuilder.java}</plain-text-body>The
<code>restletRealm</code> setting in the URI query is used to look up a Realm
Map in the registry. If this option is specified, the restlet consumer uses the
information to authenticate user logins. Only <em>authenticated</em> requests
can access the resources. In this sample, we create a Spring application
context that serves as a registry. The bean ID of the Realm Map should match
the
<em>restletRealmRef</em>.<plain-text-body>{snippet:id=realm|lang=xml|url=camel/trunk/components/camel-restlet/src/test/resources/org/apache/camel/component/restlet/camel-context.xml}</plain-text-body>The
following sample starts a <code>direct</code> endpoint that sends requests to
the server on <a s
hape="rect" class="external-link" href="http://localhost:8080"
rel="nofollow">http://localhost:8080</a> (that is, our restlet consumer
endpoint).<plain-text-body>{snippet:id=producer_route|lang=java|url=camel/trunk/components/camel-restlet/src/test/java/org/apache/camel/component/restlet/route/TestRouteBuilder.java}</plain-text-body>That
is all we need. We are ready to send a request and try out the restlet
component:<plain-text-body>{snippet:id=auth_request|lang=java|url=camel/trunk/components/camel-restlet/src/test/java/org/apache/camel/component/restlet/RestletRouteBuilderAuthTest.java}</plain-text-body>The
sample client sends a request to the <code>direct:start-auth</code> endpoint
with the following headers:</p><ul><li><code>CamelRestletLogin</code> (used
internally by Camel)</li><li><code>CamelRestletPassword</code> (used internally
by Camel)</li><li><code>id</code> (application header)</li></ul><parameter
ac:name="title">Note</parameter><rich-text-body><p><code>org.apache.cam
el.restlet.auth.login</code> and
<code>org.apache.camel.restlet.auth.password</code> will not be propagated as
Restlet header.</p></rich-text-body><p>The sample client gets a response like
the following:</p><parameter
ac:name="language">text</parameter><plain-text-body>received [<order
foo='1'/>] as an order id = 89531
+</plain-text-body><h4
id="Restlet-SinglerestletendpointtoservicemultiplemethodsandURItemplates">Single
restlet endpoint to service multiple methods and URI templates</h4><p>It is
possible to create a single route to service multiple HTTP methods using the
<code>restletMethods</code> option. This snippet also shows how to retrieve the
request method from the
header:<plain-text-body>{snippet:id=routeDefinition|lang=java|url=camel/trunk/components/camel-restlet/src/test/java/org/apache/camel/component/restlet/RestletMultiMethodsEndpointTest.java}</plain-text-body>In
addition to servicing multiple methods, the next snippet shows how to create
an endpoint that supports multiple URI templates using the
<code>restletUriPatterns</code> option. The request URI is available in the
header of the IN message as well. If a URI pattern has been defined in the
endpoint URI (which is not the case in this sample), both the URI pattern
defined in the endpoint and the <code>restletUriPatterns</code> op
tion will be
honored.<plain-text-body>{snippet:id=routeDefinition|lang=java|url=camel/trunk/components/camel-restlet/src/test/java/org/apache/camel/component/restlet/RestletMultiUriTemplatesEndpointTest.java}</plain-text-body>The
<code>restletUriPatterns=#uriTemplates</code> option references the
<code>List<String></code> bean defined in the Spring XML
configuration.</p><parameter
ac:name="">xml</parameter><plain-text-body><util:list id="uriTemplates">
<value>/users/{username}</value>
<value>/atom/collection/{id}/component/{cid}</value>
</util:list>
-]]></script>
-</div></div><h4 id="Restlet-UsingRestletAPItopopulateresponse">Using Restlet
API to populate response</h4><p><strong>Available as of Camel
2.8</strong></p><p>You may want to use the <code>org.restlet.Response</code>
API to populate the response. This gives you full access to the Restlet API and
fine grained control of the response. See the route snippet below where we
generate the response from an inlined Camel <a shape="rect"
href="processor.html">Processor</a>:</p><div class="code panel pdl"
style="border-width: 1px;"><div class="codeHeader panelHeader pdl"
style="border-bottom-width: 1px;"><b>Generating response using Restlet Response
API</b></div><div class="codeContent panelContent pdl">
-<script class="brush: java; gutter: false; theme: Default"
type="syntaxhighlighter"><![CDATA[
-from("restlet:http://localhost:" + portNum +
"/users/{id}/like/{beer}")
- .process(new Processor() {
- public void process(Exchange exchange) throws Exception {
- // the Restlet request should be available if needed
- Request request =
exchange.getIn().getHeader(RestletConstants.RESTLET_REQUEST, Request.class);
- assertNotNull("Restlet Request", request);
-
- // use Restlet API to create the response
- Response response =
exchange.getIn().getHeader(RestletConstants.RESTLET_RESPONSE, Response.class);
- assertNotNull("Restlet Response", response);
- response.setStatus(Status.SUCCESS_OK);
- response.setEntity("<response>Beer is
Good</response>", MediaType.TEXT_XML);
- exchange.getOut().setBody(response);
- }
- });
-]]></script>
-</div></div><h4 id="Restlet-Configuringmaxthreadsoncomponent">Configuring max
threads on component</h4><p>To configure the max threads options you must do
this on the component, such as:</p><div class="code panel pdl"
style="border-width: 1px;"><div class="codeContent panelContent pdl">
-<script class="brush: xml; gutter: false; theme: Default"
type="syntaxhighlighter"><![CDATA[<bean id="restlet"
class="org.apache.camel.component.restlet.RestletComponent">
- <property name="maxThreads" value="100"/>
+</plain-text-body><h4 id="Restlet-UsingRestletAPItopopulateresponse">Using
Restlet API to populate response</h4><p><strong>Available as of Camel
2.8</strong></p><p>You may want to use the <code>org.restlet.Response</code>
API to populate the response. This gives you full access to the Restlet API and
fine grained control of the response. See the route snippet below where we
generate the response from an inlined Camel <a shape="rect"
href="processor.html">Processor</a>:<plain-text-body>{snippet:id=e1|title=Generating
response using Restlet Response
API|lang=java|url=camel/trunk/components/camel-restlet/src/test/java/org/apache/camel/component/restlet/RestletRequestAndResponseAPITest.java}</plain-text-body></p><h4
id="Restlet-Configuringmaxthreadsoncomponent">Configuring max threads on
component</h4><p>To configure the max threads options you must do this on the
component, such as:</p><parameter
ac:name="">xml</parameter><plain-text-body><bean id="restlet"
class="org.apache.camel.c
omponent.restlet.RestletComponent">
+ <property name="maxThreads" value="100"/>
</bean>
-]]></script>
-</div></div><h4 id="Restlet-UsingtheRestletservletwithinawebapp">Using the
Restlet servlet within a webapp</h4><p><strong>Available as of Camel
2.8</strong><br clear="none"> There are <a shape="rect" class="external-link"
href="http://www.restlet.org/documentation/2.0/jee/ext/org/restlet/ext/servlet/ServerServlet.html"
rel="nofollow">three possible ways</a> to configure a Restlet application
within a servlet container and using the subclassed SpringServerServlet enables
configuration within Camel by injecting the Restlet Component.</p><p>Use of the
Restlet servlet within a servlet container enables routes to be configured with
relative paths in URIs (removing the restrictions of hard-coded absolute URIs)
and for the hosting servlet container to handle incoming requests (rather than
have to spawn a separate server process on a new port).</p><p>To configure, add
the following to your camel-context.xml;</p><div class="code panel pdl"
style="border-width: 1px;"><div class="codeContent p
anelContent pdl">
-<script class="brush: xml; gutter: false; theme: Default"
type="syntaxhighlighter"><![CDATA[<camelContext>
- <route id="RS_RestletDemo">
- <from uri="restlet:/demo/{id}" />
+</plain-text-body><h4 id="Restlet-UsingtheRestletservletwithinawebapp">Using
the Restlet servlet within a webapp</h4><p><strong>Available as of Camel
2.8</strong><br clear="none"> There are <a shape="rect" class="external-link"
href="http://www.restlet.org/documentation/2.0/jee/ext/org/restlet/ext/servlet/ServerServlet.html"
rel="nofollow">three possible ways</a> to configure a Restlet application
within a servlet container and using the subclassed SpringServerServlet enables
configuration within Camel by injecting the Restlet Component.</p><p>Use of the
Restlet servlet within a servlet container enables routes to be configured with
relative paths in URIs (removing the restrictions of hard-coded absolute URIs)
and for the hosting servlet container to handle incoming requests (rather than
have to spawn a separate server process on a new port).</p><p>To configure, add
the following to your camel-context.xml;</p><parameter
ac:name="language">xml</parameter><plain-text-body><camelCon
text>
+ <route id="RS_RestletDemo">
+ <from uri="restlet:/demo/{id}" />
<transform>
<simple>Request type : ${header.CamelHttpMethod} and ID :
${header.id}</simple>
</transform>
</route>
</camelContext>
-<bean id="RestletComponent"
class="org.restlet.Component" />
+<bean id="RestletComponent" class="org.restlet.Component" />
-<bean id="RestletComponentService"
class="org.apache.camel.component.restlet.RestletComponent">
- <constructor-arg index="0">
- <ref bean="RestletComponent" />
+<bean id="RestletComponentService"
class="org.apache.camel.component.restlet.RestletComponent">
+ <constructor-arg index="0">
+ <ref bean="RestletComponent" />
</constructor-arg>
</bean>
-]]></script>
-</div></div><p>And add this to your web.xml;</p><div class="code panel pdl"
style="border-width: 1px;"><div class="codeContent panelContent pdl">
-<script class="brush: xml; gutter: false; theme: Default"
type="syntaxhighlighter"><![CDATA[<!-- Restlet Servlet -->
+</plain-text-body><p>And add this to your web.xml;</p><parameter
ac:name="">xml</parameter><plain-text-body><!-- Restlet Servlet -->
<servlet>
<servlet-name>RestletServlet</servlet-name>
<servlet-class>org.restlet.ext.spring.SpringServerServlet</servlet-class>
@@ -233,26 +121,18 @@ from("restlet:http://localhost:&quo
<servlet-name>RestletServlet</servlet-name>
<url-pattern>/rs/*</url-pattern>
</servlet-mapping>
-]]></script>
-</div></div><p>You will then be able to access the deployed route at <a
shape="rect" class="external-link"
href="http://localhost:8080/mywebapp/rs/demo/1234"
rel="nofollow">http://localhost:8080/mywebapp/rs/demo/1234</a>
where;</p><p>localhost:8080 is the server and port of your servlet container<br
clear="none"> mywebapp is the name of your deployed webapp<br clear="none">
Your browser will then show the following content;</p><div class="code panel
pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
-<script class="brush: java; gutter: false; theme: Default"
type="syntaxhighlighter"><![CDATA["Request type : GET and ID : 1234"
-]]></script>
-</div></div><p>You will need to add dependency on the Spring extension to
restlet which you can do in your Maven pom.xml file:</p><div class="code panel
pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
-<script class="brush: xml; gutter: false; theme: Default"
type="syntaxhighlighter"><![CDATA[<dependency>
+</plain-text-body><p>You will then be able to access the deployed route at <a
shape="rect" class="external-link"
href="http://localhost:8080/mywebapp/rs/demo/1234"
rel="nofollow">http://localhost:8080/mywebapp/rs/demo/1234</a>
where;</p><p>localhost:8080 is the server and port of your servlet container<br
clear="none"> mywebapp is the name of your deployed webapp<br clear="none">
Your browser will then show the following content;</p><plain-text-body>"Request
type : GET and ID : 1234"
+</plain-text-body><p>You will need to add dependency on the Spring extension
to restlet which you can do in your Maven pom.xml file:</p><parameter
ac:name="">xml</parameter><plain-text-body><dependency>
<groupId>org.restlet.jee</groupId>
<artifactId>org.restlet.ext.spring</artifactId>
<version>${restlet-version}</version>
</dependency>
-]]></script>
-</div></div><p>And you would need to add dependency on the restlet maven
repository as well:</p><div class="code panel pdl" style="border-width:
1px;"><div class="codeContent panelContent pdl">
-<script class="brush: xml; gutter: false; theme: Default"
type="syntaxhighlighter"><![CDATA[<repository>
+</plain-text-body><p>And you would need to add dependency on the restlet maven
repository as well:</p><parameter
ac:name="">xml</parameter><plain-text-body><repository>
<id>maven-restlet</id>
<name>Public online Restlet repository</name>
<url>http://maven.restlet.org</url>
</repository>
-]]></script>
-</div></div><p></p><h3 id="Restlet-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>
+</plain-text-body><p><parameter ac:name=""><a shape="rect"
href="endpoint-see-also.html">Endpoint See Also</a></parameter></p></div>
</td>
<td valign="top">
<div class="navigation">