Modified: websites/production/camel/content/http4.html ============================================================================== --- websites/production/camel/content/http4.html (original) +++ websites/production/camel/content/http4.html Fri Dec 28 13:27:43 2012 @@ -79,7 +79,7 @@ <p><b>Available as of Camel 2.3</b></p> -<p>The <b>http4:</b> component provides HTTP based <a shape="rect" href="endpoint.html" title="Endpoint">endpoints</a> for consuming external HTTP resources (as a client to call external servers using HTTP).</p> +<p>The <b>http4:</b> component provides HTTP based <a shape="rect" href="endpoint.html" title="Endpoint">endpoints</a> for calling external HTTP resources (as a client to call external servers using HTTP).</p> <p>Maven users will need to add the following dependency to their <tt>pom.xml</tt> for this component:</p> <div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent"> @@ -119,7 +119,7 @@ http4:hostname[:port][/resourceUri][?opt <h3><a shape="rect" name="HTTP4-HttpEndpointOptions"></a>HttpEndpoint 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"> Default Value </th><th colspan="1" rowspan="1" class="confluenceTh"> Description </th></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"> <tt>throwExceptionOnFailure</tt> </td><td colspan="1" rowspan="1" class="confluenceTd"> <tt>true</tt> </td><td colspan="1" rowspan="1" class="confluenceTd"> Option to disable throwing the <tt>HttpOperationFailedException</tt> in case of failed responses from the remote server. This allows you to get all responses regardless of the HTTP status code. </td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"> <tt>bridgeEndpoint</tt> </td><td colspan="1" rowspan="1" class="confluenceTd"> <tt>false</tt> </td><td colspan="1" rowspan="1" class="confluenceTd"> If true, HttpProducer will ignore the Exchange.HTTP_URI header, and use the endpoint's URI for request. You may also set the <b> throwExcpetionOnFailure</b> to be false to let the HttpProducer send all fault responses back. Also if set to true HttpProducer and CamelServlet will skip the gzip processing if the content-encoding is "gzip". </td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"> <tt>disableStreamCache</tt> </td><td colspan="1" rowspan="1" class="confluenceTd"> <tt>false</tt> </td><td colspan="1" rowspan="1" class="confluenceTd"> DefaultHttpBinding will copy the request input stream into a stream cache and put it into the message body if this option is false to support multiple reads, otherwise DefaultHttpBinding will set the request input stream directly in the message body. </td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"> <tt>headerFilterStrategy</tt> </td><td colspan="1" rowspan="1" class="confluenceTd"> <tt>null</tt> </td><td colspan="1" rowspan="1" class="confluenceTd"> <b>Camel 2.10.4:</b> Reference to a instance of <tt>org.apache.camel.spi.HeaderFilterStrategy </tt> in the <a shape="rect" href="registry.html" title="Registry">Registry</a>. It will be used to apply the custom headerFilterStrategy on the new create HttpEndpoint. </td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"> <tt>httpBindingRef</tt> </td><td colspan="1" rowspan="1" class="confluenceTd"> <tt>null</tt> </td><td colspan="1" rowspan="1" class="confluenceTd"> Reference to a <tt>org.apache.camel.component.http.HttpBinding</tt> in the <a shape="rect" href="registry.html" title="Registry">Registry</a>. Recommended to use the <tt>httpBinding</tt> option instead. </td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"> <tt>httpBinding</tt> </td><td colspan="1" rowspan="1" class="confluenceTd"> <tt>null</tt> </td><td colspan="1" rowspan="1" class="confluenceTd"> To use a custom <tt>org.apache.camel.component.http.HttpBinding</tt>. </td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"> <tt>httpClientConfigurerRef</tt> </td><td colspan="1" ro wspan="1" class="confluenceTd"> <tt>null</tt> </td><td colspan="1" rowspan="1" class="confluenceTd"> Reference to a <tt>org.apache.camel.component.http.HttpClientConfigurer</tt> in the <a shape="rect" href="registry.html" title="Registry">Registry</a>. Recommended to use the <tt>httpClientConfigurer</tt> option instead. </td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"> <tt>httpContext</tt> </td><td colspan="1" rowspan="1" class="confluenceTd"> <tt>null</tt> </td><td colspan="1" rowspan="1" class="confluenceTd"> <b>Camel 2.9.2:</b> To use a custom <tt>org.apache.http.protocol.HttpContext</tt> when executing requests. </td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"> <tt>httpContextRef</tt> </td><td colspan="1" rowspan="1" class="confluenceTd"> <tt>null</tt> </td><td colspan="1" rowspan="1" class="confluenceTd"> <b>Camel 2.9.2:</b> Reference to a custom <tt>org.apache.http.protocol.HttpContext</tt> in the <a shape="rect" href="registry.html" title=" Registry">Registry</a>. Recommended to use the <tt>httpContext</tt> option instead. </td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"> <tt>httpClientConfigurer</tt> </td><td colspan="1" rowspan="1" class="confluenceTd"> <tt>null</tt> </td><td colspan="1" rowspan="1" class="confluenceTd"> Reference to a <tt>org.apache.camel.component.http.HttpClientConfigurer</tt> in the <a shape="rect" href="registry.html" title="Registry">Registry</a>. </td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"> <tt>httpClient.XXX</tt> </td><td colspan="1" rowspan="1" class="confluenceTd"> <tt>null</tt> </td><td colspan="1" rowspan="1" class="confluenceTd"> Setting options on the <a shape="rect" class="external-link" href="http://hc.apache.org/httpcomponents-core-ga/httpcore/apidocs/org/apache/http/params/BasicHttpParams.html">BasicHttpParams</a>. For instance <tt>httpClient.soTimeout=5000</tt> will set the <tt>SO_TIMEOUT</tt> to 5 seconds. Look on the setter methods of the following parameter beans for a complete reference: <a shape="rect" class="external-link" href="http://hc.apache.org/httpcomponents-client-ga/httpclient/apidocs/org/apache/http/auth/params/AuthParamBean.html">AuthParamBean</a>, <a shape="rect" class="external-link" href="http://hc.apache.org/httpcomponents-client-ga/httpclient/apidocs/org/apache/http/client/params/ClientParamBean.html">ClientParamBean</a>, <a shape="rect" class="external-link" href="http://hc.apache.org/httpcomponents-client-ga/httpclient/apidocs/org/apache/http/conn/params/ConnConnectionParamBean.html">ConnConnectionParamBean</a>, <a shape="rect" class="external-link" href="http://hc.apache.org/httpcomponents-client-ga/httpclient/apidocs/org/apache/http/conn/params/ConnRouteParamBean.html">ConnRouteParamBean</a>, <a shape="rect" class="external-link" href="http://hc.apache.org/httpcomponents-client-ga/httpclient/apidocs/org/apache/http/cookie/params/CookieSpecParamBean.html">CookieSpecParamBean</a>, <a shap e="rect" class="external-link" href="http://hc.apache.org/httpcomponents-core-ga/httpcore/apidocs/org/apache/http/params/HttpConnectionParamBean.html">HttpConnectionParamBean</a> and <a shape="rect" class="external-link" href="http://hc.apache.org/httpcomponents-core-ga/httpcore/apidocs/org/apache/http/params/HttpProtocolParamBean.html">HttpProtocolParamBean</a> </td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"> <tt>clientConnectionManager</tt> </td><td colspan="1" rowspan="1" class="confluenceTd"> <tt>null</tt> </td><td colspan="1" rowspan="1" class="confluenceTd"> To use a custom <tt>org.apache.http.conn.ClientConnectionManager</tt>. </td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"> <tt>transferException</tt> </td><td colspan="1" rowspan="1" class="confluenceTd"> <tt>false</tt> </td><td colspan="1" rowspan="1" class="confluenceTd"> If enabled and an <a shape="rect" href="exchange.html" title="Exchange">Exchange</a> failed processing on the consum er side, and if the caused <tt>Exception</tt> was send back serialized in the response as a <tt>application/x-java-serialized-object</tt> content type (for example using <a shape="rect" href="jetty.html" title="Jetty">Jetty</a> or <a shape="rect" href="servlet.html" title="SERVLET">SERVLET</a> Camel components). On the producer side the exception will be deserialized and thrown as is, instead of the <tt>HttpOperationFailedException</tt>. The caused exception is required to be serialized. </td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"> <tt>sslContextParametersRef</tt> </td><td colspan="1" rowspan="1" class="confluenceTd"> <tt>null</tt> </td><td colspan="1" rowspan="1" class="confluenceTd"> <b>Camel 2.8:</b> Reference to a <tt>org.apache.camel.util.jsse.SSLContextParameters</tt> in the <a shape="rect" href="registry.html" title="Registry">Registry</a>.  This reference overrides any configured SSLContextParameters at the component level. See <a shape="rect" href="#HTTP4-UsingtheJSSEConfigurationUtility">Using the JSSE Configuration Utility</a>. </td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"> <tt>x509HostnameVerifier</tt> </td><td colspan="1" rowspan="1" class="confluenceTd"> <tt>BrowserCompatHostnameVerifier</tt> </td><td colspan="1" rowspan="1" class="confluenceTd"> <b>Camel 2.7:</b> You can refer to a different <tt>org.apache.http.conn.ssl.X509HostnameVerifier</tt> instance in the <a shape="rect" href="registry.html" title="Registry">Registry</a> such as <tt>org.apache.http.conn.ssl.StrictHostnameVerifier</tt> or <tt>org.apache.http.conn.ssl.AllowAllHostnameVerifier</tt>. </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"> Default Value </th><th colspan="1" rowspan="1" class="confluenceTh"> Description </th></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"> <tt>throwExceptionOnFailure</tt> </td><td colspan="1" rowspan="1" class="confluenceTd"> <tt>true</tt> </td><td colspan="1" rowspan="1" class="confluenceTd"> Option to disable throwing the <tt>HttpOperationFailedException</tt> in case of failed responses from the remote server. This allows you to get all responses regardless of the HTTP status code. </td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"> <tt>bridgeEndpoint</tt> </td><td colspan="1" rowspan="1" class="confluenceTd"> <tt>false</tt> </td><td colspan="1" rowspan="1" class="confluenceTd"> If true, HttpProducer will ignore the Exchange.HTTP_URI header, and use the endpoint's URI for request. You may also set the <b> throwExcpetionOnFailure</b> to be false to let the HttpProducer send all fault responses back. Also if set to true HttpProducer and CamelServlet will skip the gzip processing if the content-encoding is "gzip". </td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"> <tt>disableStreamCache</tt> </td><td colspan="1" rowspan="1" class="confluenceTd"> <tt>false</tt> </td><td colspan="1" rowspan="1" class="confluenceTd"> DefaultHttpBinding will copy the request input stream into a stream cache and put it into the message body if this option is false to support multiple reads, otherwise DefaultHttpBinding will set the request input stream directly in the message body. </td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"> <tt>headerFilterStrategy</tt> </td><td colspan="1" rowspan="1" class="confluenceTd"> <tt>null</tt> </td><td colspan="1" rowspan="1" class="confluenceTd"> <b>Camel 2.10.4:</b> Reference to a instance of <tt>org.apache.camel.spi.HeaderFilterStrategy </tt> in the <a shape="rect" href="registry.html" title="Registry">Registry</a>. It will be used to apply the custom headerFilterStrategy on the new create HttpEndpoint. </td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"> <tt>httpBindingRef</tt> </td><td colspan="1" rowspan="1" class="confluenceTd"> <tt>null</tt> </td><td colspan="1" rowspan="1" class="confluenceTd"> Reference to a <tt>org.apache.camel.component.http.HttpBinding</tt> in the <a shape="rect" href="registry.html" title="Registry">Registry</a>. Recommended to use the <tt>httpBinding</tt> option instead. </td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"> <tt>httpBinding</tt> </td><td colspan="1" rowspan="1" class="confluenceTd"> <tt>null</tt> </td><td colspan="1" rowspan="1" class="confluenceTd"> To use a custom <tt>org.apache.camel.component.http.HttpBinding</tt>. </td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"> <tt>httpClientConfigurerRef</tt> </td><td colspan="1" ro wspan="1" class="confluenceTd"> <tt>null</tt> </td><td colspan="1" rowspan="1" class="confluenceTd"> Reference to a <tt>org.apache.camel.component.http.HttpClientConfigurer</tt> in the <a shape="rect" href="registry.html" title="Registry">Registry</a>. Recommended to use the <tt>httpClientConfigurer</tt> option instead. </td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"> <tt>httpContext</tt> </td><td colspan="1" rowspan="1" class="confluenceTd"> <tt>null</tt> </td><td colspan="1" rowspan="1" class="confluenceTd"> <b>Camel 2.9.2:</b> To use a custom <tt>org.apache.http.protocol.HttpContext</tt> when executing requests. </td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"> <tt>httpContextRef</tt> </td><td colspan="1" rowspan="1" class="confluenceTd"> <tt>null</tt> </td><td colspan="1" rowspan="1" class="confluenceTd"> <b>Camel 2.9.2:</b> Reference to a custom <tt>org.apache.http.protocol.HttpContext</tt> in the <a shape="rect" href="registry.html" title=" Registry">Registry</a>. Recommended to use the <tt>httpContext</tt> option instead. </td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"> <tt>httpClientConfigurer</tt> </td><td colspan="1" rowspan="1" class="confluenceTd"> <tt>null</tt> </td><td colspan="1" rowspan="1" class="confluenceTd"> Reference to a <tt>org.apache.camel.component.http.HttpClientConfigurer</tt> in the <a shape="rect" href="registry.html" title="Registry">Registry</a>. </td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"> <tt>httpClient.XXX</tt> </td><td colspan="1" rowspan="1" class="confluenceTd"> <tt>null</tt> </td><td colspan="1" rowspan="1" class="confluenceTd"> Setting options on the <a shape="rect" class="external-link" href="http://hc.apache.org/httpcomponents-core-ga/httpcore/apidocs/org/apache/http/params/BasicHttpParams.html">BasicHttpParams</a>. For instance <tt>httpClient.soTimeout=5000</tt> will set the <tt>SO_TIMEOUT</tt> to 5 seconds. Look on the setter methods of the following parameter beans for a complete reference: <a shape="rect" class="external-link" href="http://hc.apache.org/httpcomponents-client-ga/httpclient/apidocs/org/apache/http/auth/params/AuthParamBean.html">AuthParamBean</a>, <a shape="rect" class="external-link" href="http://hc.apache.org/httpcomponents-client-ga/httpclient/apidocs/org/apache/http/client/params/ClientParamBean.html">ClientParamBean</a>, <a shape="rect" class="external-link" href="http://hc.apache.org/httpcomponents-client-ga/httpclient/apidocs/org/apache/http/conn/params/ConnConnectionParamBean.html">ConnConnectionParamBean</a>, <a shape="rect" class="external-link" href="http://hc.apache.org/httpcomponents-client-ga/httpclient/apidocs/org/apache/http/conn/params/ConnRouteParamBean.html">ConnRouteParamBean</a>, <a shape="rect" class="external-link" href="http://hc.apache.org/httpcomponents-client-ga/httpclient/apidocs/org/apache/http/cookie/params/CookieSpecParamBean.html">CookieSpecParamBean</a>, <a shap e="rect" class="external-link" href="http://hc.apache.org/httpcomponents-core-ga/httpcore/apidocs/org/apache/http/params/HttpConnectionParamBean.html">HttpConnectionParamBean</a> and <a shape="rect" class="external-link" href="http://hc.apache.org/httpcomponents-core-ga/httpcore/apidocs/org/apache/http/params/HttpProtocolParamBean.html">HttpProtocolParamBean</a> </td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"> <tt>clientConnectionManager</tt> </td><td colspan="1" rowspan="1" class="confluenceTd"> <tt>null</tt> </td><td colspan="1" rowspan="1" class="confluenceTd"> To use a custom <tt>org.apache.http.conn.ClientConnectionManager</tt>. </td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"> <tt>transferException</tt> </td><td colspan="1" rowspan="1" class="confluenceTd"> <tt>false</tt> </td><td colspan="1" rowspan="1" class="confluenceTd"> If enabled and an <a shape="rect" href="exchange.html" title="Exchange">Exchange</a> failed processing on the consum er side, and if the caused <tt>Exception</tt> was send back serialized in the response as a <tt>application/x-java-serialized-object</tt> content type (for example using <a shape="rect" href="jetty.html" title="Jetty">Jetty</a> or <a shape="rect" href="servlet.html" title="SERVLET">SERVLET</a> Camel components). On the producer side the exception will be deserialized and thrown as is, instead of the <tt>HttpOperationFailedException</tt>. The caused exception is required to be serialized. </td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"> <tt>sslContextParametersRef</tt> </td><td colspan="1" rowspan="1" class="confluenceTd"> <tt>null</tt> </td><td colspan="1" rowspan="1" class="confluenceTd"> <b>Camel 2.8:</b> Reference to a <tt>org.apache.camel.util.jsse.SSLContextParameters</tt> in the <a shape="rect" href="registry.html" title="Registry">Registry</a>.  This reference overrides any configured SSLContextParameters at the component level. See <a shape="rect" href="#HTTP4-UsingtheJSSEConfigurationUtility">Using the JSSE Configuration Utility</a>. </td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"> <tt>x509HostnameVerifier</tt> </td><td colspan="1" rowspan="1" class="confluenceTd"> <tt>BrowserCompatHostnameVerifier</tt> </td><td colspan="1" rowspan="1" class="confluenceTd"> <b>Camel 2.7:</b> You can refer to a different <tt>org.apache.http.conn.ssl.X509HostnameVerifier</tt> instance in the <a shape="rect" href="registry.html" title="Registry">Registry</a> such as <tt>org.apache.http.conn.ssl.StrictHostnameVerifier</tt> or <tt>org.apache.http.conn.ssl.AllowAllHostnameVerifier</tt>. </td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"> <tt>urlRewrite</tt> </td><td colspan="1" rowspan="1" class="confluenceTd"> <tt>null</tt> </td><td colspan="1" rowspan="1" class="confluenceTd"> <b>Camel 2.11:</b> <b>Producer only</b> Refers to a custom <tt>org.apache.camel.component.http4.UrlRewrite</tt> which allows you to rew rite urls when you bridge/proxy endpoints. See more details at <a shape="rect" href="urlrewrite.html" title="UrlRewrite">UrlRewrite</a> and <a shape="rect" href="how-to-use-camel-as-a-http-proxy-between-a-client-and-server.html" title="How to use Camel as a HTTP proxy between a client and server">How to use Camel as a HTTP proxy between a client and server</a>. </td></tr></tbody></table> </div> </div>
Modified: websites/production/camel/content/jetty.html ============================================================================== --- websites/production/camel/content/jetty.html (original) +++ websites/production/camel/content/jetty.html Fri Dec 28 13:27:43 2012 @@ -84,6 +84,18 @@ Jetty can also be used as a http client If you find a situation where the message body appears to be empty or you need to access the data multiple times (eg: doing multicasting, or redelivery error handling)<br clear="none"> you should use <a shape="rect" href="stream-caching.html" title="Stream caching">Stream caching</a> or convert the message body to a <tt>String</tt> which is safe to be re-read multiple times.</td></tr></table></div> +<p>Maven users will need to add the following dependency to their <tt>pom.xml</tt> for this component:</p> +<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent"> +<pre class="code-xml"> +<span class="code-tag"><dependency></span> + <span class="code-tag"><groupId></span>org.apache.camel<span class="code-tag"></groupId></span> + <span class="code-tag"><artifactId></span>camel-jetty<span class="code-tag"></artifactId></span> + <span class="code-tag"><version></span>x.x.x<span class="code-tag"></version></span> + <span class="code-tag"><span class="code-comment"><!-- use the same version as your Camel core version --></span></span> +<span class="code-tag"></dependency></span> +</pre> +</div></div> + <h3><a shape="rect" name="Jetty-URIformat"></a>URI format</h3> <div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent"> Modified: websites/production/camel/content/urlrewrite.html ============================================================================== --- websites/production/camel/content/urlrewrite.html (original) +++ websites/production/camel/content/urlrewrite.html Fri Dec 28 13:27:43 2012 @@ -93,24 +93,74 @@ <h3><a shape="rect" name="UrlRewrite-Usage"></a>Usage</h3> -<p>You setup the url rewrite as a bean such as shown below:<br clear="none"> -TODO: java</p> +<p>The following component producers supports using together with the <tt>camel-urlrewrite</tt> component: <a shape="rect" href="http.html" title="HTTP">HTTP</a>, <a shape="rect" href="http4.html" title="HTTP4">HTTP4</a> <a shape="rect" href="jetty.html" title="Jetty">Jetty</a>.</p> -<p>And in XML DSL you can do:<br clear="none"> -TODO: xml</p> +<div class="confluenceTableSmall"><div class="table-wrap"> +<table class="confluenceTable"><tbody><tr><th colspan="1" rowspan="1" class="confluenceTh"> Component </th><th colspan="1" rowspan="1" class="confluenceTh"> Class </th></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"> <tt>camel-http</tt> </td><td colspan="1" rowspan="1" class="confluenceTd"> <tt>org.apache.camel.component.urlrewrite.http.HttpUrlRewrite</tt> </td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"> <tt>camel-jetty</tt> </td><td colspan="1" rowspan="1" class="confluenceTd"> <tt>org.apache.camel.component.urlrewrite.http.HttpUrlRewrite</tt> </td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"> <tt>camel-http4</tt> </td><td colspan="1" rowspan="1" class="confluenceTd"> <tt>org.apache.camel.component.urlrewrite.http4.HttpUrlRewrite</tt> </td></tr></tbody></table> +</div> +</div> -<p>In the Camel routes<br clear="none"> -TODO: route</p> +<p>You setup the url rewrite as a bean of the type <tt>org.apache.camel.component.urlrewrite.http.HttpUrlRewrite</tt> (when using <a shape="rect" href="http.html" title="HTTP">HTTP</a> component) as shown below:</p> +<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent"> +<pre class="code-java">HttpUrlRewrite myRewrite = <span class="code-keyword">new</span> HttpUrlRewrite(); +myRewrite.setConfigFile(<span class="code-quote">"example/urlrewrite2.xml"</span>); +</pre> +</div></div> + +<p>And in XML DSL you can do:</p> +<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent"> +<pre class="code-xml"> +<span class="code-tag"><bean id=<span class="code-quote">"myRewrite"</span> class=<span class="code-quote">"org.apache.camel.component.urlrewrite.HttpUrlRewrite"</span>></span> + <span class="code-tag"><property name=<span class="code-quote">"configFile"</span> value=<span class="code-quote">"example/urlrewrite2.xml"</span>/></span> +<span class="code-tag"></bean></span> +</pre> +</div></div> + +<p>In the Camel routes, you bridge the endpoints, and refer to the url rewrite on the producer endpoint as shown below. Notice how we refer to our url rewrite filter using the <tt>urlRewrite</tt> option in the endpoint uri.</p> +<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent"> +<pre class="code-java">from(<span class="code-quote">"jetty:http:<span class="code-comment">//localhost:{{port}}/myapp?matchOnUriPrefix=<span class="code-keyword">true</span>"</span>) +</span> .to(<span class="code-quote">"jetty:http:<span class="code-comment">//localhost:{{port2}}/myapp2?bridgeEndpoint=<span class="code-keyword">true</span>&throwExceptionOnFailure=<span class="code-keyword">false</span>&urlRewrite=#myRewrite"</span>);</span> +</pre> +</div></div> <h3><a shape="rect" name="UrlRewrite-Writingcustomurlrewriters"></a>Writing custom url rewriters</h3> -<p>You can implement your custom url rewriters by implementing either of the following interfaces:</p> +<p>You can implement your custom url rewriters by implementing either of the following interfaces from the component of choice:</p> + +<p>Component(s): camel-http / camel-jetty</p> <ul class="alternate" type="square"><li><tt>org.apache.camel.component.http.UrlRewrite</tt></li><li><tt>org.apache.camel.component.http.HttpServletUrlRewrite</tt></li></ul> +<p>Component(s): camel-http4</p> +<ul class="alternate" type="square"><li><tt>org.apache.camel.component.http4.UrlRewrite</tt></li><li><tt>org.apache.camel.component.http4.HttpServletUrlRewrite</tt></li></ul> + + <p>The former is a simple and generic interface, which is not dependent on the Servlet API.<br clear="none"> The later is servlet based which requires the Camel route to start from a servlet based component such as <a shape="rect" href="jetty.html" title="Jetty">Jetty</a> or <a shape="rect" href="servlet.html" title="SERVLET">SERVLET</a>. The servlet based is more feature rich and that's the API we use to integrate with the <a shape="rect" class="external-link" href="http://code.google.com/p/urlrewritefilter/" rel="nofollow">UrlRewriteFilter</a> project in this <tt>camel-urlrewrite</tt> component.</p> +<h4><a shape="rect" name="UrlRewrite-Asimpleurlrewritefilter"></a>A simple url rewrite filter</h4> + +<p>In this example we implement a custom <tt>org.apache.camel.component.http.UrlRewrite</tt> that just replaces yahoo with google. Mind this example is based on a unit test, and only for demonstration purposes. As its java code you have full power to implement more complex logic.</p> + +<p>The url parameter contains the full url including scheme://hostname:port/path?query. The relativeUrl parameter is the url without the endpoint configured path. Notice this option may be null if the url doesn't start with the endpoint configured path. </p> + +<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent"> +<pre class="code-java">/** + * A very simple url rewrite that replaces yahoo with google in the url. + * <p/> + * This is only used <span class="code-keyword">for</span> testing purposes. + */ +<span class="code-keyword">public</span> class GoogleUrlRewrite <span class="code-keyword">implements</span> UrlRewrite { + + @Override + <span class="code-keyword">public</span> <span class="code-object">String</span> rewrite(<span class="code-object">String</span> url, <span class="code-object">String</span> relativeUrl, Producer producer) { + <span class="code-keyword">return</span> url.replaceAll(<span class="code-quote">"yahoo"</span>, <span class="code-quote">"google"</span>); + } +} +</pre> +</div></div> + + <h3><a shape="rect" name="UrlRewrite-SeeAlso"></a>See Also</h3> <ul><li><a shape="rect" href="configuring-camel.html" title="Configuring Camel">Configuring Camel</a></li><li><a shape="rect" href="component.html" title="Component">Component</a></li><li><a shape="rect" href="endpoint.html" title="Endpoint">Endpoint</a></li><li><a shape="rect" href="getting-started.html" title="Getting Started">Getting Started</a></li></ul>