camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject svn commit: r1426462 - in /camel/trunk/components: camel-http/src/main/java/org/apache/camel/component/http/ camel-http/src/main/java/org/apache/camel/component/http/helper/ camel-http/src/test/java/org/apache/camel/component/http/ camel-http4/src/main...
Date Fri, 28 Dec 2012 11:33:14 GMT
Author: davsclaus
Date: Fri Dec 28 11:33:13 2012
New Revision: 1426462

URL: http://svn.apache.org/viewvc?rev=1426462&view=rev
Log:
CAMEL-5912: Added support for urlrewrite in camel-http4. Aligned code between camel-http4 and camel-http in the producer code.

Added:
    camel/trunk/components/camel-http4/src/main/java/org/apache/camel/component/http4/HttpServletUrlRewrite.java   (with props)
    camel/trunk/components/camel-http4/src/main/java/org/apache/camel/component/http4/UrlRewrite.java   (with props)
    camel/trunk/components/camel-http4/src/main/java/org/apache/camel/component/http4/helper/UrlRewriteHttpServletRequestAdapter.java   (with props)
    camel/trunk/components/camel-http4/src/test/java/org/apache/camel/component/http4/GoogleUrlRewrite.java   (with props)
    camel/trunk/components/camel-http4/src/test/java/org/apache/camel/component/http4/UrlRewriteTest.java   (with props)
    camel/trunk/components/camel-urlrewrite/src/main/java/org/apache/camel/component/urlrewrite/http/
    camel/trunk/components/camel-urlrewrite/src/main/java/org/apache/camel/component/urlrewrite/http/HttpUrlRewrite.java
      - copied, changed from r1426429, camel/trunk/components/camel-urlrewrite/src/main/java/org/apache/camel/component/urlrewrite/HttpUrlRewrite.java
    camel/trunk/components/camel-urlrewrite/src/main/java/org/apache/camel/component/urlrewrite/http4/
    camel/trunk/components/camel-urlrewrite/src/main/java/org/apache/camel/component/urlrewrite/http4/Http4UrlRewrite.java   (with props)
    camel/trunk/components/camel-urlrewrite/src/test/java/org/apache/camel/component/urlrewrite/http4/
    camel/trunk/components/camel-urlrewrite/src/test/java/org/apache/camel/component/urlrewrite/http4/Http4UrlRewriteModFileTest.java
      - copied, changed from r1426429, camel/trunk/components/camel-urlrewrite/src/test/java/org/apache/camel/component/urlrewrite/http/HttpUrlRewriteModFileTest.java
    camel/trunk/components/camel-urlrewrite/src/test/java/org/apache/camel/component/urlrewrite/http4/Http4UrlRewriteModTest.java
      - copied, changed from r1426441, camel/trunk/components/camel-urlrewrite/src/test/java/org/apache/camel/component/urlrewrite/http/HttpUrlRewriteModTest.java
    camel/trunk/components/camel-urlrewrite/src/test/java/org/apache/camel/component/urlrewrite/http4/Http4UrlRewritePingQueryTest.java
      - copied, changed from r1426429, camel/trunk/components/camel-urlrewrite/src/test/java/org/apache/camel/component/urlrewrite/http/HttpUrlRewritePingQueryTest.java
    camel/trunk/components/camel-urlrewrite/src/test/java/org/apache/camel/component/urlrewrite/http4/Http4UrlRewritePingTest.java
      - copied, changed from r1426429, camel/trunk/components/camel-urlrewrite/src/test/java/org/apache/camel/component/urlrewrite/http/HttpUrlRewritePingTest.java
    camel/trunk/components/camel-urlrewrite/src/test/java/org/apache/camel/component/urlrewrite/http4/Http4UrlRewriteTest.java
      - copied, changed from r1426429, camel/trunk/components/camel-urlrewrite/src/test/java/org/apache/camel/component/urlrewrite/http/HttpUrlRewriteTest.java
Removed:
    camel/trunk/components/camel-urlrewrite/src/main/java/org/apache/camel/component/urlrewrite/HttpUrlRewrite.java
Modified:
    camel/trunk/components/camel-http/src/main/java/org/apache/camel/component/http/CamelServlet.java
    camel/trunk/components/camel-http/src/main/java/org/apache/camel/component/http/HttpServletUrlRewrite.java
    camel/trunk/components/camel-http/src/main/java/org/apache/camel/component/http/UrlRewrite.java
    camel/trunk/components/camel-http/src/main/java/org/apache/camel/component/http/helper/HttpHelper.java
    camel/trunk/components/camel-http/src/test/java/org/apache/camel/component/http/GoogleUrlRewrite.java
    camel/trunk/components/camel-http/src/test/java/org/apache/camel/component/http/UrlRewriteTest.java
    camel/trunk/components/camel-http4/src/main/java/org/apache/camel/component/http4/CamelServlet.java
    camel/trunk/components/camel-http4/src/main/java/org/apache/camel/component/http4/HttpComponent.java
    camel/trunk/components/camel-http4/src/main/java/org/apache/camel/component/http4/HttpConsumer.java
    camel/trunk/components/camel-http4/src/main/java/org/apache/camel/component/http4/HttpEndpoint.java
    camel/trunk/components/camel-http4/src/main/java/org/apache/camel/component/http4/HttpProducer.java
    camel/trunk/components/camel-http4/src/main/java/org/apache/camel/component/http4/helper/HttpHelper.java
    camel/trunk/components/camel-http4/src/test/resources/log4j.properties
    camel/trunk/components/camel-jetty/src/main/java/org/apache/camel/component/jetty/CamelContinuationServlet.java
    camel/trunk/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/MyUrlRewrite.java
    camel/trunk/components/camel-urlrewrite/pom.xml
    camel/trunk/components/camel-urlrewrite/src/main/java/org/apache/camel/component/urlrewrite/UrlRewriteFilter.java
    camel/trunk/components/camel-urlrewrite/src/test/java/org/apache/camel/component/urlrewrite/http/HttpUrlRewriteModFileTest.java
    camel/trunk/components/camel-urlrewrite/src/test/java/org/apache/camel/component/urlrewrite/http/HttpUrlRewriteModTest.java
    camel/trunk/components/camel-urlrewrite/src/test/java/org/apache/camel/component/urlrewrite/http/HttpUrlRewritePingQueryTest.java
    camel/trunk/components/camel-urlrewrite/src/test/java/org/apache/camel/component/urlrewrite/http/HttpUrlRewritePingTest.java
    camel/trunk/components/camel-urlrewrite/src/test/java/org/apache/camel/component/urlrewrite/http/HttpUrlRewriteTest.java
    camel/trunk/components/camel-urlrewrite/src/test/java/org/apache/camel/component/urlrewrite/jetty/JettyUrlRewriteModTest.java
    camel/trunk/components/camel-urlrewrite/src/test/java/org/apache/camel/component/urlrewrite/jetty/JettyUrlRewriteTest.java
    camel/trunk/components/camel-urlrewrite/src/test/resources/log4j.properties

Modified: camel/trunk/components/camel-http/src/main/java/org/apache/camel/component/http/CamelServlet.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-http/src/main/java/org/apache/camel/component/http/CamelServlet.java?rev=1426462&r1=1426461&r2=1426462&view=diff
==============================================================================
--- camel/trunk/components/camel-http/src/main/java/org/apache/camel/component/http/CamelServlet.java (original)
+++ camel/trunk/components/camel-http/src/main/java/org/apache/camel/component/http/CamelServlet.java Fri Dec 28 11:33:13 2012
@@ -99,6 +99,10 @@ public class CamelServlet extends HttpSe
         HttpHelper.setCharsetFromContentType(request.getContentType(), exchange);
         exchange.setIn(new HttpMessage(exchange, request, response));
 
+        // set context path as header
+        String contextPath = consumer.getEndpoint().getPath();
+        exchange.getIn().setHeader("CamelServletContextPath", contextPath);
+
         try {
             log.trace("Processing request for exchangeId: {}", exchange.getExchangeId());
             // process the exchange

Modified: camel/trunk/components/camel-http/src/main/java/org/apache/camel/component/http/HttpServletUrlRewrite.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-http/src/main/java/org/apache/camel/component/http/HttpServletUrlRewrite.java?rev=1426462&r1=1426461&r2=1426462&view=diff
==============================================================================
--- camel/trunk/components/camel-http/src/main/java/org/apache/camel/component/http/HttpServletUrlRewrite.java (original)
+++ camel/trunk/components/camel-http/src/main/java/org/apache/camel/component/http/HttpServletUrlRewrite.java Fri Dec 28 11:33:13 2012
@@ -32,12 +32,14 @@ public interface HttpServletUrlRewrite e
     /**
      * Rewrite the url.
      *
-     * @param url  the url
+     * @param url  the absolute url (eg with scheme://host:port/path?query)
+     * @param relativeUrl optional relative url, if bridging endpoints, which then would be without the base path from the
+     *                    endpoint from the given producer.
      * @param producer the producer to use the rewritten url
      * @param request  the http servlet request
      * @return the rewritten url, or <tt>null</tt> to use the original url
      * @throws Exception is thrown if error rewriting the url
      */
-    String rewrite(String url, Producer producer, HttpServletRequest request) throws Exception;
+    String rewrite(String url, String relativeUrl, Producer producer, HttpServletRequest request) throws Exception;
 
 }

Modified: camel/trunk/components/camel-http/src/main/java/org/apache/camel/component/http/UrlRewrite.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-http/src/main/java/org/apache/camel/component/http/UrlRewrite.java?rev=1426462&r1=1426461&r2=1426462&view=diff
==============================================================================
--- camel/trunk/components/camel-http/src/main/java/org/apache/camel/component/http/UrlRewrite.java (original)
+++ camel/trunk/components/camel-http/src/main/java/org/apache/camel/component/http/UrlRewrite.java Fri Dec 28 11:33:13 2012
@@ -16,7 +16,6 @@
  */
 package org.apache.camel.component.http;
 
-import org.apache.camel.Endpoint;
 import org.apache.camel.Producer;
 
 /**
@@ -30,11 +29,13 @@ public interface UrlRewrite {
     /**
      * Rewrite the url.
      *
-     * @param url  the url
+     * @param url  the absolute url (eg with scheme://host:port/path?query)
+     * @param relativeUrl optional relative url, if bridging endpoints, which then would be without the base path from the
+     *                    endpoint from the given producer.
      * @param producer the producer to use the rewritten url
      * @return the rewritten url, or <tt>null</tt> to use the original url
      * @throws Exception is thrown if error rewriting the url
      */
-    String rewrite(String url, Producer producer) throws Exception;
+    String rewrite(String url, String relativeUrl, Producer producer) throws Exception;
 
 }

Modified: camel/trunk/components/camel-http/src/main/java/org/apache/camel/component/http/helper/HttpHelper.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-http/src/main/java/org/apache/camel/component/http/helper/HttpHelper.java?rev=1426462&r1=1426461&r2=1426462&view=diff
==============================================================================
--- camel/trunk/components/camel-http/src/main/java/org/apache/camel/component/http/helper/HttpHelper.java (original)
+++ camel/trunk/components/camel-http/src/main/java/org/apache/camel/component/http/helper/HttpHelper.java Fri Dec 28 11:33:13 2012
@@ -350,17 +350,21 @@ public final class HttpHelper {
     public static String urlRewrite(Exchange exchange, String url, HttpEndpoint endpoint, Producer producer) throws Exception {
         String answer = null;
 
+        String relativeUrl;
         if (endpoint.getUrlRewrite() != null) {
             // we should use the relative path if possible
-            String rewriteUrl;
             String baseUrl;
-            String relativeUri = endpoint.getHttpUri().toASCIIString();
-            if (url.startsWith(relativeUri)) {
-                baseUrl = url.substring(0, relativeUri.length());
-                rewriteUrl = url.substring(relativeUri.length());
+            relativeUrl = endpoint.getHttpUri().toASCIIString();
+            if (url.startsWith(relativeUrl)) {
+                baseUrl = url.substring(0, relativeUrl.length());
+                relativeUrl = url.substring(relativeUrl.length());
             } else {
                 baseUrl = null;
-                rewriteUrl = url;
+                relativeUrl = url;
+            }
+            // mark it as null if its empty
+            if (ObjectHelper.isEmpty(relativeUrl)) {
+                relativeUrl = null;
             }
 
             String newUrl;
@@ -379,17 +383,15 @@ public final class HttpHelper {
                 }
                 // we need to adapt the context-path to be the path from the endpoint, if it came from a http based endpoint
                 // as eg camel-jetty have hardcoded context-path as / for all its servlets/endpoints
-                String contextPath = null;
-                if (exchange.getFromEndpoint() instanceof HttpEndpoint) {
-                    contextPath = ((HttpEndpoint) exchange.getFromEndpoint()).getPath();
-                }
+                // we have the actual context-path stored as a header with the key CamelServletContextPath
+                String contextPath = exchange.getIn().getHeader("CamelServletContextPath", String.class);
                 request = new UrlRewriteHttpServletRequestAdapter(request, contextPath);
-                newUrl = ((HttpServletUrlRewrite) endpoint.getUrlRewrite()).rewrite(rewriteUrl, producer, request);
+                newUrl = ((HttpServletUrlRewrite) endpoint.getUrlRewrite()).rewrite(url, relativeUrl, producer, request);
             } else {
-                newUrl = endpoint.getUrlRewrite().rewrite(rewriteUrl, producer);
+                newUrl = endpoint.getUrlRewrite().rewrite(url, relativeUrl, producer);
             }
 
-            if (newUrl != null && newUrl != url) {
+            if (ObjectHelper.isNotEmpty(newUrl) && newUrl != url) {
                 // we got a new url back, that can either be a new absolute url
                 // or a new relative url
                 if (newUrl.startsWith("http:") || newUrl.startsWith("https:")) {
@@ -405,7 +407,10 @@ public final class HttpHelper {
                     // use the new url as is
                     answer = newUrl;
                 }
-                LOG.debug("Using url rewrite to rewrite from {} to {} -> {}", new Object[]{rewriteUrl, newUrl, answer});
+                if (LOG.isDebugEnabled()) {
+                    LOG.debug("Using url rewrite to rewrite from url {} to {} -> {}",
+                            new Object[]{relativeUrl != null ? relativeUrl : url, newUrl, answer});
+                }
             }
         }
 

Modified: camel/trunk/components/camel-http/src/test/java/org/apache/camel/component/http/GoogleUrlRewrite.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-http/src/test/java/org/apache/camel/component/http/GoogleUrlRewrite.java?rev=1426462&r1=1426461&r2=1426462&view=diff
==============================================================================
--- camel/trunk/components/camel-http/src/test/java/org/apache/camel/component/http/GoogleUrlRewrite.java (original)
+++ camel/trunk/components/camel-http/src/test/java/org/apache/camel/component/http/GoogleUrlRewrite.java Fri Dec 28 11:33:13 2012
@@ -27,7 +27,7 @@ import org.apache.camel.Producer;
 public class GoogleUrlRewrite implements UrlRewrite {
 
     @Override
-    public String rewrite(String url, Producer producer) {
+    public String rewrite(String url, String relativeUrl, Producer producer) {
         return url.replaceAll("yahoo", "google");
     }
 }

Modified: camel/trunk/components/camel-http/src/test/java/org/apache/camel/component/http/UrlRewriteTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-http/src/test/java/org/apache/camel/component/http/UrlRewriteTest.java?rev=1426462&r1=1426461&r2=1426462&view=diff
==============================================================================
--- camel/trunk/components/camel-http/src/test/java/org/apache/camel/component/http/UrlRewriteTest.java (original)
+++ camel/trunk/components/camel-http/src/test/java/org/apache/camel/component/http/UrlRewriteTest.java Fri Dec 28 11:33:13 2012
@@ -41,7 +41,7 @@ public class UrlRewriteTest extends Came
         MockEndpoint mock = getMockEndpoint("mock:result");
         mock.expectedMessageCount(1);
 
-        template.sendBody("direct:start", "null");
+        template.sendBody("direct:start", null);
 
         assertMockEndpointsSatisfied();
     }

Modified: camel/trunk/components/camel-http4/src/main/java/org/apache/camel/component/http4/CamelServlet.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-http4/src/main/java/org/apache/camel/component/http4/CamelServlet.java?rev=1426462&r1=1426461&r2=1426462&view=diff
==============================================================================
--- camel/trunk/components/camel-http4/src/main/java/org/apache/camel/component/http4/CamelServlet.java (original)
+++ camel/trunk/components/camel-http4/src/main/java/org/apache/camel/component/http4/CamelServlet.java Fri Dec 28 11:33:13 2012
@@ -33,6 +33,7 @@ import org.apache.camel.impl.DefaultExch
 /**
  * @version 
  */
+@Deprecated
 public class CamelServlet extends HttpServlet {
 
     private static final long serialVersionUID = -7061982839117697829L;
@@ -71,18 +72,16 @@ public class CamelServlet extends HttpSe
             }
             HttpHelper.setCharsetFromContentType(request.getContentType(), exchange);
             exchange.setIn(new HttpMessage(exchange, request, response));
-            consumer.getProcessor().process(exchange);
+            // set context path as header
+            String contextPath = consumer.getEndpoint().getPath();
+            exchange.getIn().setHeader("CamelServletContextPath", contextPath);
 
-            // HC: The getBinding() is interesting because it illustrates the
-            // impedance miss-match between
-            // HTTP's stream oriented protocol, and Camels more message oriented
-            // protocol exchanges.
+            consumer.getProcessor().process(exchange);
 
             // now lets output to the response
             consumer.getBinding().writeResponse(exchange, response);
 
         } catch (Exception e) {
-            e.printStackTrace();
             throw new ServletException(e);
         }
     }

Modified: camel/trunk/components/camel-http4/src/main/java/org/apache/camel/component/http4/HttpComponent.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-http4/src/main/java/org/apache/camel/component/http4/HttpComponent.java?rev=1426462&r1=1426461&r2=1426462&view=diff
==============================================================================
--- camel/trunk/components/camel-http4/src/main/java/org/apache/camel/component/http4/HttpComponent.java (original)
+++ camel/trunk/components/camel-http4/src/main/java/org/apache/camel/component/http4/HttpComponent.java Fri Dec 28 11:33:13 2012
@@ -196,7 +196,8 @@ public class HttpComponent extends Heade
         String httpMethodRestrict = getAndRemoveParameter(parameters, "httpMethodRestrict", String.class);
         
         HeaderFilterStrategy headerFilterStrategy = resolveAndRemoveReferenceParameter(parameters, "headerFilterStrategy", HeaderFilterStrategy.class);
-        
+        UrlRewrite urlRewrite = resolveAndRemoveReferenceParameter(parameters, "urlRewrite", UrlRewrite.class);
+
         boolean secure = HttpHelper.isSecureConnection(uri);
 
         // create the configurer to use for this endpoint
@@ -204,6 +205,12 @@ public class HttpComponent extends Heade
         URI endpointUri = URISupport.createRemainingURI(new URI(addressUri), httpClientParameters);
         // create the endpoint and set the http uri to be null
         HttpEndpoint endpoint = new HttpEndpoint(endpointUri.toString(), this, clientParams, clientConnectionManager, configurer);
+        if (urlRewrite != null) {
+            // let CamelContext deal with the lifecycle of the url rewrite
+            // this ensures its being shutdown when Camel shutdown etc.
+            getCamelContext().addService(urlRewrite);
+            endpoint.setUrlRewrite(urlRewrite);
+        }
         // configure the endpoint
         setProperties(endpoint, parameters);
         // The httpUri should be start with http or https

Modified: camel/trunk/components/camel-http4/src/main/java/org/apache/camel/component/http4/HttpConsumer.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-http4/src/main/java/org/apache/camel/component/http4/HttpConsumer.java?rev=1426462&r1=1426461&r2=1426462&view=diff
==============================================================================
--- camel/trunk/components/camel-http4/src/main/java/org/apache/camel/component/http4/HttpConsumer.java (original)
+++ camel/trunk/components/camel-http4/src/main/java/org/apache/camel/component/http4/HttpConsumer.java Fri Dec 28 11:33:13 2012
@@ -22,6 +22,7 @@ import org.apache.camel.impl.DefaultCons
 /**
  * @version 
  */
+@Deprecated
 public class HttpConsumer extends DefaultConsumer {
 
     private final HttpEndpoint endpoint;

Modified: camel/trunk/components/camel-http4/src/main/java/org/apache/camel/component/http4/HttpEndpoint.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-http4/src/main/java/org/apache/camel/component/http4/HttpEndpoint.java?rev=1426462&r1=1426461&r2=1426462&view=diff
==============================================================================
--- camel/trunk/components/camel-http4/src/main/java/org/apache/camel/component/http4/HttpEndpoint.java (original)
+++ camel/trunk/components/camel-http4/src/main/java/org/apache/camel/component/http4/HttpEndpoint.java Fri Dec 28 11:33:13 2012
@@ -19,7 +19,9 @@ package org.apache.camel.component.http4
 import java.net.URI;
 import java.net.URISyntaxException;
 
+import org.apache.camel.Consumer;
 import org.apache.camel.PollingConsumer;
+import org.apache.camel.Processor;
 import org.apache.camel.Producer;
 import org.apache.camel.RuntimeCamelException;
 import org.apache.camel.component.http4.helper.HttpHelper;
@@ -63,8 +65,8 @@ public class HttpEndpoint extends Defaul
     private boolean transferException;
     private boolean traceEnabled;
     private String httpMethodRestrict;
+    private UrlRewrite urlRewrite;
 
-    
     public HttpEndpoint() {
     }
 
@@ -337,4 +339,12 @@ public class HttpEndpoint extends Defaul
     public void setHttpMethodRestrict(String httpMethodRestrict) {
         this.httpMethodRestrict = httpMethodRestrict;
     }
+
+    public UrlRewrite getUrlRewrite() {
+        return urlRewrite;
+    }
+
+    public void setUrlRewrite(UrlRewrite urlRewrite) {
+        this.urlRewrite = urlRewrite;
+    }
 }

Modified: camel/trunk/components/camel-http4/src/main/java/org/apache/camel/component/http4/HttpProducer.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-http4/src/main/java/org/apache/camel/component/http4/HttpProducer.java?rev=1426462&r1=1426461&r2=1426462&view=diff
==============================================================================
--- camel/trunk/components/camel-http4/src/main/java/org/apache/camel/component/http4/HttpProducer.java (original)
+++ camel/trunk/components/camel-http4/src/main/java/org/apache/camel/component/http4/HttpProducer.java Fri Dec 28 11:33:13 2012
@@ -319,12 +319,10 @@ public class HttpProducer extends Defaul
             return cos.getWrappedInputStream();
         } catch (IOException ex) {
             // try to close the CachedOutputStream when we get the IOException
-            if (cos != null) {
-                try { 
-                    cos.close(); 
-                } catch (IOException ignore) { 
-                    //do nothing here
-                }
+            try {
+                cos.close();
+            } catch (IOException ignore) {
+                //do nothing here
             }
             throw ex;
         } finally {
@@ -338,59 +336,44 @@ public class HttpProducer extends Defaul
      * @param exchange the exchange
      * @return the created method as either GET or POST
      * @throws URISyntaxException is thrown if the URI is invalid
-     * @throws CamelExchangeException is thrown if error creating RequestEntity
+     * @throws Exception is thrown if error creating RequestEntity
      */
-    protected HttpRequestBase createMethod(Exchange exchange) throws URISyntaxException, CamelExchangeException {
+    protected HttpRequestBase createMethod(Exchange exchange) throws Exception {
+        // creating the url to use takes 2-steps
         String url = HttpHelper.createURL(exchange, getEndpoint());
-        URI uri = new URI(url);
+        URI uri = HttpHelper.createURI(exchange, url, getEndpoint());
+        // get the url from the uri
+        url = uri.toASCIIString();
+
+        // execute any custom url rewrite
+        String rewriteUrl = HttpHelper.urlRewrite(exchange, url, getEndpoint(), this);
+        if (rewriteUrl != null) {
+            // update url and query string from the rewritten url
+            url = rewriteUrl;
+            uri = new URI(url);
+        }
 
+        // create http holder objects for the request
         HttpEntity requestEntity = createRequestEntity(exchange);
         HttpMethods methodToUse = HttpHelper.createMethod(exchange, getEndpoint(), requestEntity != null);
+        HttpRequestBase method = methodToUse.createMethod(url);
 
-        // is a query string provided in the endpoint URI or in a header (header overrules endpoint)
-        String queryString = exchange.getIn().getHeader(Exchange.HTTP_QUERY, String.class);
-        // We should user the query string from the HTTP_URI header
-        if (queryString == null) {
-            queryString = uri.getQuery();
-        }
-        
-        if (queryString == null) {
-            queryString = getEndpoint().getHttpUri().getRawQuery();
-        }
-
-        if (uri.getScheme() == null || uri.getHost() == null) {
-            throw new IllegalArgumentException("Invalid uri: " + uri
-                    + ". If you are forwarding/bridging http endpoints, then enable the bridgeEndpoint option on the endpoint: " + getEndpoint());
-        }
-        
-        StringBuilder builder = new StringBuilder(uri.getScheme()).append("://").append(uri.getHost());
-
-        if (uri.getPort() != -1) {
-            builder.append(":").append(uri.getPort());
-        }
-
-        if (uri.getPath() != null) {
-            builder.append(uri.getRawPath());
-        }
-
-        if (queryString != null) {
-            builder.append('?');
-            builder.append(queryString);
-        }
-        
-        LOG.debug(" The uri used by http request is " + builder.toString());
-       
-
-        HttpRequestBase httpRequest = methodToUse.createMethod(builder.toString());
+        LOG.trace("Using URL: {} with method: {}", url, method);
 
         if (methodToUse.isEntityEnclosing()) {
-            ((HttpEntityEnclosingRequestBase) httpRequest).setEntity(requestEntity);
+            ((HttpEntityEnclosingRequestBase) method).setEntity(requestEntity);
             if (requestEntity != null && requestEntity.getContentType() == null) {
                 LOG.debug("No Content-Type provided for URL: {} with exchange: {}", url, exchange);
             }
         }
 
-        return httpRequest;
+        // there must be a host on the method
+        if (method.getURI().getScheme() == null || method.getURI().getHost() == null) {
+            throw new IllegalArgumentException("Invalid uri: " + uri
+                    + ". If you are forwarding/bridging http endpoints, then enable the bridgeEndpoint option on the endpoint: " + getEndpoint());
+        }
+
+        return method;
     }
 
     /**

Added: camel/trunk/components/camel-http4/src/main/java/org/apache/camel/component/http4/HttpServletUrlRewrite.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-http4/src/main/java/org/apache/camel/component/http4/HttpServletUrlRewrite.java?rev=1426462&view=auto
==============================================================================
--- camel/trunk/components/camel-http4/src/main/java/org/apache/camel/component/http4/HttpServletUrlRewrite.java (added)
+++ camel/trunk/components/camel-http4/src/main/java/org/apache/camel/component/http4/HttpServletUrlRewrite.java Fri Dec 28 11:33:13 2012
@@ -0,0 +1,45 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.http4;
+
+import javax.servlet.http.HttpServletRequest;
+
+import org.apache.camel.Producer;
+
+/**
+ * Extended {@link UrlRewrite} which leverages {@link HttpServletRequest}
+ * during the rewrite process.
+ * <p/>
+ * For example the camel-urlrewrite component supports
+ * {@link HttpServletUrlRewrite} implementations.
+ */
+public interface HttpServletUrlRewrite extends UrlRewrite {
+
+    /**
+     * Rewrite the url.
+     *
+     * @param url  the absolute url (eg with scheme://host:port/path?query)
+     * @param relativeUrl optional relative url, if bridging endpoints, which then would be without the base path from the
+     *                    endpoint from the given producer.
+     * @param producer the producer to use the rewritten url
+     * @param request  the http servlet request
+     * @return the rewritten url, or <tt>null</tt> to use the original url
+     * @throws Exception is thrown if error rewriting the url
+     */
+    String rewrite(String url, String relativeUrl, Producer producer, HttpServletRequest request) throws Exception;
+
+}

Propchange: camel/trunk/components/camel-http4/src/main/java/org/apache/camel/component/http4/HttpServletUrlRewrite.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: camel/trunk/components/camel-http4/src/main/java/org/apache/camel/component/http4/HttpServletUrlRewrite.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: camel/trunk/components/camel-http4/src/main/java/org/apache/camel/component/http4/UrlRewrite.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-http4/src/main/java/org/apache/camel/component/http4/UrlRewrite.java?rev=1426462&view=auto
==============================================================================
--- camel/trunk/components/camel-http4/src/main/java/org/apache/camel/component/http4/UrlRewrite.java (added)
+++ camel/trunk/components/camel-http4/src/main/java/org/apache/camel/component/http4/UrlRewrite.java Fri Dec 28 11:33:13 2012
@@ -0,0 +1,41 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.http4;
+
+import org.apache.camel.Producer;
+
+/**
+ * Allows to plugin custom strategy for rewriting url.
+ * <p/>
+ * This allows for example to proxy http services and plugin a url rewrite
+ * strategy such as the <a href="http://camel.apache.org/urlrewrite">url-rewrite</a> component.
+ */
+public interface UrlRewrite {
+
+    /**
+     * Rewrite the url.
+     *
+     * @param url  the absolute url (eg with scheme://host:port/path?query)
+     * @param relativeUrl optional relative url, if bridging endpoints, which then would be without the base path from the
+     *                    endpoint from the given producer.
+     * @param producer the producer to use the rewritten url
+     * @return the rewritten url, or <tt>null</tt> to use the original url
+     * @throws Exception is thrown if error rewriting the url
+     */
+    String rewrite(String url, String relativeUrl, Producer producer) throws Exception;
+
+}

Propchange: camel/trunk/components/camel-http4/src/main/java/org/apache/camel/component/http4/UrlRewrite.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: camel/trunk/components/camel-http4/src/main/java/org/apache/camel/component/http4/UrlRewrite.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Modified: camel/trunk/components/camel-http4/src/main/java/org/apache/camel/component/http4/helper/HttpHelper.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-http4/src/main/java/org/apache/camel/component/http4/helper/HttpHelper.java?rev=1426462&r1=1426461&r2=1426462&view=diff
==============================================================================
--- camel/trunk/components/camel-http4/src/main/java/org/apache/camel/component/http4/helper/HttpHelper.java (original)
+++ camel/trunk/components/camel-http4/src/main/java/org/apache/camel/component/http4/helper/HttpHelper.java Fri Dec 28 11:33:13 2012
@@ -30,20 +30,28 @@ import javax.servlet.ServletResponse;
 import javax.servlet.http.HttpServletRequest;
 
 import org.apache.camel.Exchange;
+import org.apache.camel.Producer;
 import org.apache.camel.RuntimeExchangeException;
 import org.apache.camel.component.http4.HttpConstants;
 import org.apache.camel.component.http4.HttpConverter;
 import org.apache.camel.component.http4.HttpEndpoint;
+import org.apache.camel.component.http4.HttpMessage;
 import org.apache.camel.component.http4.HttpMethods;
+import org.apache.camel.component.http4.HttpServletUrlRewrite;
 import org.apache.camel.converter.stream.CachedOutputStream;
 import org.apache.camel.util.IOHelper;
 import org.apache.camel.util.ObjectHelper;
+import org.apache.camel.util.URISupport;
 import org.apache.camel.util.UnsafeUriCharactersEncoder;
 import org.apache.http.HttpVersion;
 import org.apache.http.ProtocolException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 public final class HttpHelper {
 
+    private static final transient Logger LOG = LoggerFactory.getLogger(HttpHelper.class);
+
     private HttpHelper() {
         // Helper class
     }
@@ -217,6 +225,33 @@ public final class HttpHelper {
     }
 
     /**
+     * Creates the URI to invoke.
+     *
+     * @param exchange the exchange
+     * @param url      the url to invoke
+     * @param endpoint the endpoint
+     * @return the URI to invoke
+     */
+    public static URI createURI(Exchange exchange, String url, HttpEndpoint endpoint) throws URISyntaxException {
+        URI uri = new URI(url);
+        // is a query string provided in the endpoint URI or in a header (header overrules endpoint)
+        String queryString = exchange.getIn().getHeader(Exchange.HTTP_QUERY, String.class);
+        if (queryString == null) {
+            queryString = endpoint.getHttpUri().getRawQuery();
+        }
+        // We should user the query string from the HTTP_URI header
+        if (queryString == null) {
+            queryString = uri.getQuery();
+        }
+        if (queryString != null) {
+            // need to encode query string
+            queryString = UnsafeUriCharactersEncoder.encode(queryString);
+            uri = URISupport.createURIWithQuery(uri, queryString);
+        }
+        return uri;
+    }
+
+    /**
      * Creates the HttpMethod to use to call the remote server, often either its GET or POST.
      *
      * @param exchange the exchange
@@ -355,4 +390,84 @@ public final class HttpHelper {
         return value;
     }
 
+    /**
+     * Processes any custom {@link org.apache.camel.component.http4.UrlRewrite}.
+     *
+     * @param exchange    the exchange
+     * @param url         the url
+     * @param endpoint    the http endpoint
+     * @param producer    the producer
+     * @return            the rewritten url, or <tt>null</tt> to use original url
+     * @throws Exception is thrown if any error during rewriting url
+     */
+    public static String urlRewrite(Exchange exchange, String url, HttpEndpoint endpoint, Producer producer) throws Exception {
+        String answer = null;
+
+        String relativeUrl;
+        if (endpoint.getUrlRewrite() != null) {
+            // we should use the relative path if possible
+            String baseUrl;
+            relativeUrl = endpoint.getHttpUri().toASCIIString();
+            if (url.startsWith(relativeUrl)) {
+                baseUrl = url.substring(0, relativeUrl.length());
+                relativeUrl = url.substring(relativeUrl.length());
+            } else {
+                baseUrl = null;
+                relativeUrl = url;
+            }
+            // mark it as null if its empty
+            if (ObjectHelper.isEmpty(relativeUrl)) {
+                relativeUrl = null;
+            }
+
+            String newUrl;
+            if (endpoint.getUrlRewrite() instanceof HttpServletUrlRewrite) {
+                // its servlet based, so we need the servlet request
+                HttpServletRequest request = exchange.getIn().getBody(HttpServletRequest.class);
+                if (request == null) {
+                    HttpMessage msg = exchange.getIn(HttpMessage.class);
+                    if (msg != null) {
+                        request = msg.getRequest();
+                    }
+                }
+                if (request == null) {
+                    throw new IllegalArgumentException("UrlRewrite " + endpoint.getUrlRewrite() + " requires the message body to be a" +
+                            "HttpServletRequest instance, but was: " + ObjectHelper.className(exchange.getIn().getBody()));
+                }
+                // we need to adapt the context-path to be the path from the endpoint, if it came from a http based endpoint
+                // as eg camel-jetty have hardcoded context-path as / for all its servlets/endpoints
+                // we have the actual context-path stored as a header with the key CamelServletContextPath
+                String contextPath = exchange.getIn().getHeader("CamelServletContextPath", String.class);
+                request = new UrlRewriteHttpServletRequestAdapter(request, contextPath);
+                newUrl = ((HttpServletUrlRewrite) endpoint.getUrlRewrite()).rewrite(url, relativeUrl, producer, request);
+            } else {
+                newUrl = endpoint.getUrlRewrite().rewrite(url, relativeUrl, producer);
+            }
+
+            if (ObjectHelper.isNotEmpty(newUrl) && newUrl != url) {
+                // we got a new url back, that can either be a new absolute url
+                // or a new relative url
+                if (newUrl.startsWith("http:") || newUrl.startsWith("https:")) {
+                    answer = newUrl;
+                } else if (baseUrl != null) {
+                    // avoid double // when adding the urls
+                    if (baseUrl.endsWith("/") && newUrl.startsWith("/")) {
+                        answer = baseUrl + newUrl.substring(1);
+                    } else {
+                        answer = baseUrl + newUrl;
+                    }
+                } else {
+                    // use the new url as is
+                    answer = newUrl;
+                }
+                if (LOG.isDebugEnabled()) {
+                    LOG.debug("Using url rewrite to rewrite from url {} to {} -> {}",
+                            new Object[]{relativeUrl != null ? relativeUrl : url, newUrl, answer});
+                }
+            }
+        }
+
+        return answer;
+    }
+
 }

Added: camel/trunk/components/camel-http4/src/main/java/org/apache/camel/component/http4/helper/UrlRewriteHttpServletRequestAdapter.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-http4/src/main/java/org/apache/camel/component/http4/helper/UrlRewriteHttpServletRequestAdapter.java?rev=1426462&view=auto
==============================================================================
--- camel/trunk/components/camel-http4/src/main/java/org/apache/camel/component/http4/helper/UrlRewriteHttpServletRequestAdapter.java (added)
+++ camel/trunk/components/camel-http4/src/main/java/org/apache/camel/component/http4/helper/UrlRewriteHttpServletRequestAdapter.java Fri Dec 28 11:33:13 2012
@@ -0,0 +1,272 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.http4.helper;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.UnsupportedEncodingException;
+import java.security.Principal;
+import java.util.Enumeration;
+import java.util.Locale;
+import java.util.Map;
+import javax.servlet.RequestDispatcher;
+import javax.servlet.ServletInputStream;
+import javax.servlet.http.Cookie;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpSession;
+
+/**
+ * Special adapter when {@link org.apache.camel.component.http4.HttpServletUrlRewrite} is in use,
+ * and the route started from came-jetty/camel-serlvet.
+ * <p/>
+ * This adapter ensures that we can control the context-path returned from the
+ * {@link javax.servlet.http.HttpServletRequest#getContextPath()} method.
+ * This allows us to ensure the context-path is based on the endpoint path, as the
+ * camel-jetty/camel-servlet server implementation uses the root ("/") context-path
+ * for all the servlets/endpoints.
+ */
+public final class UrlRewriteHttpServletRequestAdapter implements HttpServletRequest {
+
+    private final HttpServletRequest delegate;
+    private final String contextPath;
+
+    /**
+     * Creates this adapter
+     * @param delegate    the real http servlet request to delegate.
+     * @param contextPath use to override and return this context-path
+     */
+    public UrlRewriteHttpServletRequestAdapter(HttpServletRequest delegate, String contextPath) {
+        this.delegate = delegate;
+        this.contextPath = contextPath;
+    }
+
+    public String getAuthType() {
+        return delegate.getAuthType();
+    }
+
+    public Enumeration getHeaderNames() {
+        return delegate.getHeaderNames();
+    }
+
+    public String getPathInfo() {
+        return delegate.getPathInfo();
+    }
+
+    public Object getAttribute(String name) {
+        return delegate.getAttribute(name);
+    }
+
+    public Enumeration getParameterNames() {
+        return delegate.getParameterNames();
+    }
+
+    public String getProtocol() {
+        return delegate.getProtocol();
+    }
+
+    public String getHeader(String name) {
+        return delegate.getHeader(name);
+    }
+
+    public String getQueryString() {
+        return delegate.getQueryString();
+    }
+
+    public Enumeration getHeaders(String name) {
+        return delegate.getHeaders(name);
+    }
+
+    public String getRemoteUser() {
+        return delegate.getRemoteUser();
+    }
+
+    public int getRemotePort() {
+        return delegate.getRemotePort();
+    }
+
+    public void removeAttribute(String name) {
+        delegate.removeAttribute(name);
+    }
+
+    public long getDateHeader(String name) {
+        return delegate.getDateHeader(name);
+    }
+
+    public HttpSession getSession() {
+        return delegate.getSession();
+    }
+
+    public boolean isSecure() {
+        return delegate.isSecure();
+    }
+
+    public int getContentLength() {
+        return delegate.getContentLength();
+    }
+
+    public BufferedReader getReader() throws IOException {
+        return delegate.getReader();
+    }
+
+    public Locale getLocale() {
+        return delegate.getLocale();
+    }
+
+    public Map getParameterMap() {
+        return delegate.getParameterMap();
+    }
+
+    public Enumeration getLocales() {
+        return delegate.getLocales();
+    }
+
+    public HttpSession getSession(boolean create) {
+        return delegate.getSession(create);
+    }
+
+    public int getLocalPort() {
+        return delegate.getLocalPort();
+    }
+
+    public String getServerName() {
+        return delegate.getServerName();
+    }
+
+    public void setAttribute(String name, Object o) {
+        delegate.setAttribute(name, o);
+    }
+
+    public void setCharacterEncoding(String env) throws UnsupportedEncodingException {
+        delegate.setCharacterEncoding(env);
+    }
+
+    public Enumeration getAttributeNames() {
+        return delegate.getAttributeNames();
+    }
+
+    public String getRequestedSessionId() {
+        return delegate.getRequestedSessionId();
+    }
+
+    public String getRemoteHost() {
+        return delegate.getRemoteHost();
+    }
+
+    public boolean isRequestedSessionIdValid() {
+        return delegate.isRequestedSessionIdValid();
+    }
+
+    public String getPathTranslated() {
+        return delegate.getPathTranslated();
+    }
+
+    public String getMethod() {
+        return delegate.getMethod();
+    }
+
+    public RequestDispatcher getRequestDispatcher(String path) {
+        return delegate.getRequestDispatcher(path);
+    }
+
+    public String getScheme() {
+        return delegate.getScheme();
+    }
+
+    public String getCharacterEncoding() {
+        return delegate.getCharacterEncoding();
+    }
+
+    public StringBuffer getRequestURL() {
+        return delegate.getRequestURL();
+    }
+
+    public int getServerPort() {
+        return delegate.getServerPort();
+    }
+
+    public boolean isRequestedSessionIdFromCookie() {
+        return delegate.isRequestedSessionIdFromCookie();
+    }
+
+    public String getLocalAddr() {
+        return delegate.getLocalAddr();
+    }
+
+    public boolean isRequestedSessionIdFromUrl() {
+        return delegate.isRequestedSessionIdFromUrl();
+    }
+
+    public Cookie[] getCookies() {
+        return delegate.getCookies();
+    }
+
+    public String getRemoteAddr() {
+        return delegate.getRemoteAddr();
+    }
+
+    public Principal getUserPrincipal() {
+        return delegate.getUserPrincipal();
+    }
+
+    public String[] getParameterValues(String name) {
+        return delegate.getParameterValues(name);
+    }
+
+    public String getContentType() {
+        return delegate.getContentType();
+    }
+
+    public String getParameter(String name) {
+        return delegate.getParameter(name);
+    }
+
+    public String getLocalName() {
+        return delegate.getLocalName();
+    }
+
+    public String getContextPath() {
+        return contextPath != null ? contextPath : delegate.getContextPath();
+    }
+
+    public String getRealPath(String path) {
+        return delegate.getRealPath(path);
+    }
+
+    public int getIntHeader(String name) {
+        return delegate.getIntHeader(name);
+    }
+
+    public boolean isUserInRole(String role) {
+        return delegate.isUserInRole(role);
+    }
+
+    public boolean isRequestedSessionIdFromURL() {
+        return delegate.isRequestedSessionIdFromURL();
+    }
+
+    public ServletInputStream getInputStream() throws IOException {
+        return delegate.getInputStream();
+    }
+
+    public String getRequestURI() {
+        return delegate.getRequestURI();
+    }
+
+    public String getServletPath() {
+        return delegate.getServletPath();
+    }
+}

Propchange: camel/trunk/components/camel-http4/src/main/java/org/apache/camel/component/http4/helper/UrlRewriteHttpServletRequestAdapter.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: camel/trunk/components/camel-http4/src/main/java/org/apache/camel/component/http4/helper/UrlRewriteHttpServletRequestAdapter.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: camel/trunk/components/camel-http4/src/test/java/org/apache/camel/component/http4/GoogleUrlRewrite.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-http4/src/test/java/org/apache/camel/component/http4/GoogleUrlRewrite.java?rev=1426462&view=auto
==============================================================================
--- camel/trunk/components/camel-http4/src/test/java/org/apache/camel/component/http4/GoogleUrlRewrite.java (added)
+++ camel/trunk/components/camel-http4/src/test/java/org/apache/camel/component/http4/GoogleUrlRewrite.java Fri Dec 28 11:33:13 2012
@@ -0,0 +1,34 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.http4;
+
+import org.apache.camel.Producer;
+
+// START SNIPPET: e1
+/**
+ * A very simple url rewrite that replaces yahoo with google in the url.
+ * <p/>
+ * This is only used for testing purposes.
+ */
+public class GoogleUrlRewrite implements UrlRewrite {
+
+    @Override
+    public String rewrite(String url, String relativeUrl, Producer producer) {
+        return url.replaceAll("yahoo", "google");
+    }
+}
+// END SNIPPET: e1

Propchange: camel/trunk/components/camel-http4/src/test/java/org/apache/camel/component/http4/GoogleUrlRewrite.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: camel/trunk/components/camel-http4/src/test/java/org/apache/camel/component/http4/GoogleUrlRewrite.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: camel/trunk/components/camel-http4/src/test/java/org/apache/camel/component/http4/UrlRewriteTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-http4/src/test/java/org/apache/camel/component/http4/UrlRewriteTest.java?rev=1426462&view=auto
==============================================================================
--- camel/trunk/components/camel-http4/src/test/java/org/apache/camel/component/http4/UrlRewriteTest.java (added)
+++ camel/trunk/components/camel-http4/src/test/java/org/apache/camel/component/http4/UrlRewriteTest.java Fri Dec 28 11:33:13 2012
@@ -0,0 +1,62 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.http4;
+
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.apache.camel.impl.JndiRegistry;
+import org.apache.camel.test.junit4.CamelTestSupport;
+import org.junit.Ignore;
+import org.junit.Test;
+
+/**
+ *
+ */
+public class UrlRewriteTest extends CamelTestSupport {
+
+    @Override
+    protected JndiRegistry createRegistry() throws Exception {
+        JndiRegistry jndi = super.createRegistry();
+        jndi.bind("fooRewrite", new GoogleUrlRewrite());
+        return jndi;
+    }
+
+    @Test
+    @Ignore
+    public void testUrlRewrite() throws Exception {
+        MockEndpoint mock = getMockEndpoint("mock:result");
+        mock.expectedMessageCount(1);
+
+        template.sendBody("direct:start", null);
+
+        assertMockEndpointsSatisfied();
+    }
+
+    @Override
+    protected RouteBuilder createRouteBuilder() throws Exception {
+        return new RouteBuilder() {
+            public void configure() {
+                from("direct:start")
+                        .to("http4://www.yahoo.com?q=camel&urlRewrite=#fooRewrite")
+                        .convertBodyTo(String.class)
+                        .to("log:result", "mock:result");
+            }
+        };
+    }
+
+
+}

Propchange: camel/trunk/components/camel-http4/src/test/java/org/apache/camel/component/http4/UrlRewriteTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: camel/trunk/components/camel-http4/src/test/java/org/apache/camel/component/http4/UrlRewriteTest.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Modified: camel/trunk/components/camel-http4/src/test/resources/log4j.properties
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-http4/src/test/resources/log4j.properties?rev=1426462&r1=1426461&r2=1426462&view=diff
==============================================================================
--- camel/trunk/components/camel-http4/src/test/resources/log4j.properties (original)
+++ camel/trunk/components/camel-http4/src/test/resources/log4j.properties Fri Dec 28 11:33:13 2012
@@ -21,7 +21,7 @@
 log4j.rootLogger=INFO, file
 
 # uncomment the following to enable camel debugging
-log4j.logger.org.apache.camel.component.http=DEBUG
+#log4j.logger.org.apache.camel.component.http4=DEBUG
 
 # CONSOLE appender not used by default
 log4j.appender.out=org.apache.log4j.ConsoleAppender

Modified: camel/trunk/components/camel-jetty/src/main/java/org/apache/camel/component/jetty/CamelContinuationServlet.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-jetty/src/main/java/org/apache/camel/component/jetty/CamelContinuationServlet.java?rev=1426462&r1=1426461&r2=1426462&view=diff
==============================================================================
--- camel/trunk/components/camel-jetty/src/main/java/org/apache/camel/component/jetty/CamelContinuationServlet.java (original)
+++ camel/trunk/components/camel-jetty/src/main/java/org/apache/camel/component/jetty/CamelContinuationServlet.java Fri Dec 28 11:33:13 2012
@@ -110,6 +110,10 @@ public class CamelContinuationServlet ex
             HttpHelper.setCharsetFromContentType(request.getContentType(), exchange);
             exchange.setIn(new HttpMessage(exchange, request, response));
 
+            // set context path as header
+            String contextPath = consumer.getEndpoint().getPath();
+            exchange.getIn().setHeader("CamelServletContextPath", contextPath);
+
             log.trace("Suspending continuation of exchangeId: {}", exchange.getExchangeId());
             continuation.setAttribute(EXCHANGE_ATTRIBUTE_ID, exchange.getExchangeId());
             // must suspend before we process the exchange

Modified: camel/trunk/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/MyUrlRewrite.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/MyUrlRewrite.java?rev=1426462&r1=1426461&r2=1426462&view=diff
==============================================================================
--- camel/trunk/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/MyUrlRewrite.java (original)
+++ camel/trunk/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/MyUrlRewrite.java Fri Dec 28 11:33:13 2012
@@ -25,7 +25,7 @@ import org.apache.camel.component.http.U
 public class MyUrlRewrite implements UrlRewrite {
 
     @Override
-    public String rewrite(String url, Producer producer) {
+    public String rewrite(String url, String relativeUrl, Producer producer) {
         return url.replaceAll("foo", "bar");
     }
 }

Modified: camel/trunk/components/camel-urlrewrite/pom.xml
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-urlrewrite/pom.xml?rev=1426462&r1=1426461&r2=1426462&view=diff
==============================================================================
--- camel/trunk/components/camel-urlrewrite/pom.xml (original)
+++ camel/trunk/components/camel-urlrewrite/pom.xml Fri Dec 28 11:33:13 2012
@@ -57,6 +57,11 @@
       <artifactId>camel-http</artifactId>
       <scope>provided</scope>
     </dependency>
+    <dependency>
+      <groupId>org.apache.camel</groupId>
+      <artifactId>camel-http4</artifactId>
+      <scope>provided</scope>
+    </dependency>
 
     <!-- test dependencies -->
     <dependency>

Modified: camel/trunk/components/camel-urlrewrite/src/main/java/org/apache/camel/component/urlrewrite/UrlRewriteFilter.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-urlrewrite/src/main/java/org/apache/camel/component/urlrewrite/UrlRewriteFilter.java?rev=1426462&r1=1426461&r2=1426462&view=diff
==============================================================================
--- camel/trunk/components/camel-urlrewrite/src/main/java/org/apache/camel/component/urlrewrite/UrlRewriteFilter.java (original)
+++ camel/trunk/components/camel-urlrewrite/src/main/java/org/apache/camel/component/urlrewrite/UrlRewriteFilter.java Fri Dec 28 11:33:13 2012
@@ -40,7 +40,6 @@ public abstract class UrlRewriteFilter e
 
     private static final Logger LOG = LoggerFactory.getLogger(UrlRewriteFilter.class);
 
-    // TODO: Find a better way of starting/stopping this without adding as service to CamelContext
     // TODO: Add support in camel-http4 and camel-ahc
 
     protected CamelContext camelContext;

Copied: camel/trunk/components/camel-urlrewrite/src/main/java/org/apache/camel/component/urlrewrite/http/HttpUrlRewrite.java (from r1426429, camel/trunk/components/camel-urlrewrite/src/main/java/org/apache/camel/component/urlrewrite/HttpUrlRewrite.java)
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-urlrewrite/src/main/java/org/apache/camel/component/urlrewrite/http/HttpUrlRewrite.java?p2=camel/trunk/components/camel-urlrewrite/src/main/java/org/apache/camel/component/urlrewrite/http/HttpUrlRewrite.java&p1=camel/trunk/components/camel-urlrewrite/src/main/java/org/apache/camel/component/urlrewrite/HttpUrlRewrite.java&r1=1426429&r2=1426462&rev=1426462&view=diff
==============================================================================
--- camel/trunk/components/camel-urlrewrite/src/main/java/org/apache/camel/component/urlrewrite/HttpUrlRewrite.java (original)
+++ camel/trunk/components/camel-urlrewrite/src/main/java/org/apache/camel/component/urlrewrite/http/HttpUrlRewrite.java Fri Dec 28 11:33:13 2012
@@ -14,12 +14,13 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.camel.component.urlrewrite;
+package org.apache.camel.component.urlrewrite.http;
 
 import javax.servlet.http.HttpServletRequest;
 
 import org.apache.camel.Producer;
 import org.apache.camel.component.http.HttpServletUrlRewrite;
+import org.apache.camel.component.urlrewrite.UrlRewriteFilter;
 
 /**
  * The camel-http component implementation of the {@link HttpServletUrlRewrite}.
@@ -27,12 +28,12 @@ import org.apache.camel.component.http.H
 public class HttpUrlRewrite extends UrlRewriteFilter implements HttpServletUrlRewrite {
 
     @Override
-    public String rewrite(String url, Producer producer, HttpServletRequest request) throws Exception {
-        return rewrite(url, request);
+    public String rewrite(String url, String relativeUrl, Producer producer, HttpServletRequest request) throws Exception {
+        return rewrite(relativeUrl, request);
     }
 
     @Override
-    public String rewrite(String url, Producer producer) throws Exception {
+    public String rewrite(String url, String relativeUrl, Producer producer) throws Exception {
         // not in use
         return null;
     }

Added: camel/trunk/components/camel-urlrewrite/src/main/java/org/apache/camel/component/urlrewrite/http4/Http4UrlRewrite.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-urlrewrite/src/main/java/org/apache/camel/component/urlrewrite/http4/Http4UrlRewrite.java?rev=1426462&view=auto
==============================================================================
--- camel/trunk/components/camel-urlrewrite/src/main/java/org/apache/camel/component/urlrewrite/http4/Http4UrlRewrite.java (added)
+++ camel/trunk/components/camel-urlrewrite/src/main/java/org/apache/camel/component/urlrewrite/http4/Http4UrlRewrite.java Fri Dec 28 11:33:13 2012
@@ -0,0 +1,40 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.urlrewrite.http4;
+
+import javax.servlet.http.HttpServletRequest;
+
+import org.apache.camel.Producer;
+import org.apache.camel.component.http4.HttpServletUrlRewrite;
+import org.apache.camel.component.urlrewrite.UrlRewriteFilter;
+
+/**
+ * The camel-http4 component implementation of the {@link org.apache.camel.component.http.HttpServletUrlRewrite}.
+ */
+public class Http4UrlRewrite extends UrlRewriteFilter implements HttpServletUrlRewrite {
+
+    @Override
+    public String rewrite(String url, String relativeUrl, Producer producer, HttpServletRequest request) throws Exception {
+        return rewrite(relativeUrl, request);
+    }
+
+    @Override
+    public String rewrite(String url, String relativeUrl, Producer producer) throws Exception {
+        // not in use
+        return null;
+    }
+}

Propchange: camel/trunk/components/camel-urlrewrite/src/main/java/org/apache/camel/component/urlrewrite/http4/Http4UrlRewrite.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: camel/trunk/components/camel-urlrewrite/src/main/java/org/apache/camel/component/urlrewrite/http4/Http4UrlRewrite.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Modified: camel/trunk/components/camel-urlrewrite/src/test/java/org/apache/camel/component/urlrewrite/http/HttpUrlRewriteModFileTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-urlrewrite/src/test/java/org/apache/camel/component/urlrewrite/http/HttpUrlRewriteModFileTest.java?rev=1426462&r1=1426461&r2=1426462&view=diff
==============================================================================
--- camel/trunk/components/camel-urlrewrite/src/test/java/org/apache/camel/component/urlrewrite/http/HttpUrlRewriteModFileTest.java (original)
+++ camel/trunk/components/camel-urlrewrite/src/test/java/org/apache/camel/component/urlrewrite/http/HttpUrlRewriteModFileTest.java Fri Dec 28 11:33:13 2012
@@ -18,7 +18,6 @@ package org.apache.camel.component.urlre
 
 import org.apache.camel.builder.RouteBuilder;
 import org.apache.camel.component.urlrewrite.BaseUrlRewriteTest;
-import org.apache.camel.component.urlrewrite.HttpUrlRewrite;
 import org.apache.camel.impl.JndiRegistry;
 import org.junit.Test;
 

Modified: camel/trunk/components/camel-urlrewrite/src/test/java/org/apache/camel/component/urlrewrite/http/HttpUrlRewriteModTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-urlrewrite/src/test/java/org/apache/camel/component/urlrewrite/http/HttpUrlRewriteModTest.java?rev=1426462&r1=1426461&r2=1426462&view=diff
==============================================================================
--- camel/trunk/components/camel-urlrewrite/src/test/java/org/apache/camel/component/urlrewrite/http/HttpUrlRewriteModTest.java (original)
+++ camel/trunk/components/camel-urlrewrite/src/test/java/org/apache/camel/component/urlrewrite/http/HttpUrlRewriteModTest.java Fri Dec 28 11:33:13 2012
@@ -18,7 +18,6 @@ package org.apache.camel.component.urlre
 
 import org.apache.camel.builder.RouteBuilder;
 import org.apache.camel.component.urlrewrite.BaseUrlRewriteTest;
-import org.apache.camel.component.urlrewrite.HttpUrlRewrite;
 import org.apache.camel.impl.JndiRegistry;
 import org.junit.Test;
 

Modified: camel/trunk/components/camel-urlrewrite/src/test/java/org/apache/camel/component/urlrewrite/http/HttpUrlRewritePingQueryTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-urlrewrite/src/test/java/org/apache/camel/component/urlrewrite/http/HttpUrlRewritePingQueryTest.java?rev=1426462&r1=1426461&r2=1426462&view=diff
==============================================================================
--- camel/trunk/components/camel-urlrewrite/src/test/java/org/apache/camel/component/urlrewrite/http/HttpUrlRewritePingQueryTest.java (original)
+++ camel/trunk/components/camel-urlrewrite/src/test/java/org/apache/camel/component/urlrewrite/http/HttpUrlRewritePingQueryTest.java Fri Dec 28 11:33:13 2012
@@ -18,7 +18,6 @@ package org.apache.camel.component.urlre
 
 import org.apache.camel.builder.RouteBuilder;
 import org.apache.camel.component.urlrewrite.BaseUrlRewriteTest;
-import org.apache.camel.component.urlrewrite.HttpUrlRewrite;
 import org.apache.camel.impl.JndiRegistry;
 import org.junit.Test;
 

Modified: camel/trunk/components/camel-urlrewrite/src/test/java/org/apache/camel/component/urlrewrite/http/HttpUrlRewritePingTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-urlrewrite/src/test/java/org/apache/camel/component/urlrewrite/http/HttpUrlRewritePingTest.java?rev=1426462&r1=1426461&r2=1426462&view=diff
==============================================================================
--- camel/trunk/components/camel-urlrewrite/src/test/java/org/apache/camel/component/urlrewrite/http/HttpUrlRewritePingTest.java (original)
+++ camel/trunk/components/camel-urlrewrite/src/test/java/org/apache/camel/component/urlrewrite/http/HttpUrlRewritePingTest.java Fri Dec 28 11:33:13 2012
@@ -18,7 +18,6 @@ package org.apache.camel.component.urlre
 
 import org.apache.camel.builder.RouteBuilder;
 import org.apache.camel.component.urlrewrite.BaseUrlRewriteTest;
-import org.apache.camel.component.urlrewrite.HttpUrlRewrite;
 import org.apache.camel.impl.JndiRegistry;
 import org.junit.Test;
 

Modified: camel/trunk/components/camel-urlrewrite/src/test/java/org/apache/camel/component/urlrewrite/http/HttpUrlRewriteTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-urlrewrite/src/test/java/org/apache/camel/component/urlrewrite/http/HttpUrlRewriteTest.java?rev=1426462&r1=1426461&r2=1426462&view=diff
==============================================================================
--- camel/trunk/components/camel-urlrewrite/src/test/java/org/apache/camel/component/urlrewrite/http/HttpUrlRewriteTest.java (original)
+++ camel/trunk/components/camel-urlrewrite/src/test/java/org/apache/camel/component/urlrewrite/http/HttpUrlRewriteTest.java Fri Dec 28 11:33:13 2012
@@ -18,7 +18,6 @@ package org.apache.camel.component.urlre
 
 import org.apache.camel.builder.RouteBuilder;
 import org.apache.camel.component.urlrewrite.BaseUrlRewriteTest;
-import org.apache.camel.component.urlrewrite.HttpUrlRewrite;
 import org.apache.camel.impl.JndiRegistry;
 import org.junit.Test;
 

Copied: camel/trunk/components/camel-urlrewrite/src/test/java/org/apache/camel/component/urlrewrite/http4/Http4UrlRewriteModFileTest.java (from r1426429, camel/trunk/components/camel-urlrewrite/src/test/java/org/apache/camel/component/urlrewrite/http/HttpUrlRewriteModFileTest.java)
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-urlrewrite/src/test/java/org/apache/camel/component/urlrewrite/http4/Http4UrlRewriteModFileTest.java?p2=camel/trunk/components/camel-urlrewrite/src/test/java/org/apache/camel/component/urlrewrite/http4/Http4UrlRewriteModFileTest.java&p1=camel/trunk/components/camel-urlrewrite/src/test/java/org/apache/camel/component/urlrewrite/http/HttpUrlRewriteModFileTest.java&r1=1426429&r2=1426462&rev=1426462&view=diff
==============================================================================
--- camel/trunk/components/camel-urlrewrite/src/test/java/org/apache/camel/component/urlrewrite/http/HttpUrlRewriteModFileTest.java (original)
+++ camel/trunk/components/camel-urlrewrite/src/test/java/org/apache/camel/component/urlrewrite/http4/Http4UrlRewriteModFileTest.java Fri Dec 28 11:33:13 2012
@@ -14,24 +14,23 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.camel.component.urlrewrite.http;
+package org.apache.camel.component.urlrewrite.http4;
 
 import org.apache.camel.builder.RouteBuilder;
 import org.apache.camel.component.urlrewrite.BaseUrlRewriteTest;
-import org.apache.camel.component.urlrewrite.HttpUrlRewrite;
 import org.apache.camel.impl.JndiRegistry;
 import org.junit.Test;
 
 /**
  *
  */
-public class HttpUrlRewriteModFileTest extends BaseUrlRewriteTest {
+public class Http4UrlRewriteModFileTest extends BaseUrlRewriteTest {
 
     @Override
     protected JndiRegistry createRegistry() throws Exception {
         JndiRegistry jndi = super.createRegistry();
 
-        HttpUrlRewrite myRewrite = new HttpUrlRewrite();
+        Http4UrlRewrite myRewrite = new Http4UrlRewrite();
         myRewrite.setModRewriteConfFile("example/modrewrite.cfg");
 
         jndi.bind("myRewrite", myRewrite);
@@ -41,7 +40,7 @@ public class HttpUrlRewriteModFileTest e
 
     @Test
     public void testHttpUriRewrite() throws Exception {
-        String out = template.requestBody("http://localhost:{{port}}/myapp/page/software/", null, String.class);
+        String out = template.requestBody("http4://localhost:{{port}}/myapp/page/software/", null, String.class);
         assertEquals("http://localhost:" + getPort2() + "/myapp2/index.php?page=software", out);
     }
 
@@ -51,7 +50,7 @@ public class HttpUrlRewriteModFileTest e
             @Override
             public void configure() throws Exception {
                 from("jetty:http://localhost:{{port}}/myapp?matchOnUriPrefix=true")
-                    .to("http://localhost:{{port2}}/myapp2?bridgeEndpoint=true&throwExceptionOnFailure=false&urlRewrite=#myRewrite");
+                    .to("http4://localhost:{{port2}}/myapp2?bridgeEndpoint=true&throwExceptionOnFailure=false&urlRewrite=#myRewrite");
 
                 from("jetty:http://localhost:{{port2}}/myapp2?matchOnUriPrefix=true")
                     .transform().simple("${header.CamelHttpUrl}?${header.CamelHttpQuery}");

Copied: camel/trunk/components/camel-urlrewrite/src/test/java/org/apache/camel/component/urlrewrite/http4/Http4UrlRewriteModTest.java (from r1426441, camel/trunk/components/camel-urlrewrite/src/test/java/org/apache/camel/component/urlrewrite/http/HttpUrlRewriteModTest.java)
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-urlrewrite/src/test/java/org/apache/camel/component/urlrewrite/http4/Http4UrlRewriteModTest.java?p2=camel/trunk/components/camel-urlrewrite/src/test/java/org/apache/camel/component/urlrewrite/http4/Http4UrlRewriteModTest.java&p1=camel/trunk/components/camel-urlrewrite/src/test/java/org/apache/camel/component/urlrewrite/http/HttpUrlRewriteModTest.java&r1=1426441&r2=1426462&rev=1426462&view=diff
==============================================================================
--- camel/trunk/components/camel-urlrewrite/src/test/java/org/apache/camel/component/urlrewrite/http/HttpUrlRewriteModTest.java (original)
+++ camel/trunk/components/camel-urlrewrite/src/test/java/org/apache/camel/component/urlrewrite/http4/Http4UrlRewriteModTest.java Fri Dec 28 11:33:13 2012
@@ -14,25 +14,24 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.camel.component.urlrewrite.http;
+package org.apache.camel.component.urlrewrite.http4;
 
 import org.apache.camel.builder.RouteBuilder;
 import org.apache.camel.component.urlrewrite.BaseUrlRewriteTest;
-import org.apache.camel.component.urlrewrite.HttpUrlRewrite;
 import org.apache.camel.impl.JndiRegistry;
 import org.junit.Test;
 
 /**
  *
  */
-public class HttpUrlRewriteModTest extends BaseUrlRewriteTest {
+public class Http4UrlRewriteModTest extends BaseUrlRewriteTest {
 
     @Override
     protected JndiRegistry createRegistry() throws Exception {
         JndiRegistry jndi = super.createRegistry();
 
         // START SNIPPET: e1
-        HttpUrlRewrite myRewrite = new HttpUrlRewrite();
+        Http4UrlRewrite myRewrite = new Http4UrlRewrite();
         myRewrite.setModRewriteConfText("RewriteRule page/([^/\\.]+)/?$ index.php?page=$1 [L]");
         // END SNIPPET: e1
 
@@ -43,7 +42,7 @@ public class HttpUrlRewriteModTest exten
 
     @Test
     public void testHttpUriRewrite() throws Exception {
-        String out = template.requestBody("http://localhost:{{port}}/myapp/page/software/", null, String.class);
+        String out = template.requestBody("http4://localhost:{{port}}/myapp/page/software/", null, String.class);
         assertEquals("http://localhost:" + getPort2() + "/myapp2/index.php?page=software", out);
     }
 
@@ -53,7 +52,7 @@ public class HttpUrlRewriteModTest exten
             @Override
             public void configure() throws Exception {
                 from("jetty:http://localhost:{{port}}/myapp?matchOnUriPrefix=true")
-                    .to("http://localhost:{{port2}}/myapp2?bridgeEndpoint=true&throwExceptionOnFailure=false&urlRewrite=#myRewrite");
+                    .to("http4://localhost:{{port2}}/myapp2?bridgeEndpoint=true&throwExceptionOnFailure=false&urlRewrite=#myRewrite");
 
                 from("jetty:http://localhost:{{port2}}/myapp2?matchOnUriPrefix=true")
                     .transform().simple("${header.CamelHttpUrl}?${header.CamelHttpQuery}");

Copied: camel/trunk/components/camel-urlrewrite/src/test/java/org/apache/camel/component/urlrewrite/http4/Http4UrlRewritePingQueryTest.java (from r1426429, camel/trunk/components/camel-urlrewrite/src/test/java/org/apache/camel/component/urlrewrite/http/HttpUrlRewritePingQueryTest.java)
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-urlrewrite/src/test/java/org/apache/camel/component/urlrewrite/http4/Http4UrlRewritePingQueryTest.java?p2=camel/trunk/components/camel-urlrewrite/src/test/java/org/apache/camel/component/urlrewrite/http4/Http4UrlRewritePingQueryTest.java&p1=camel/trunk/components/camel-urlrewrite/src/test/java/org/apache/camel/component/urlrewrite/http/HttpUrlRewritePingQueryTest.java&r1=1426429&r2=1426462&rev=1426462&view=diff
==============================================================================
--- camel/trunk/components/camel-urlrewrite/src/test/java/org/apache/camel/component/urlrewrite/http/HttpUrlRewritePingQueryTest.java (original)
+++ camel/trunk/components/camel-urlrewrite/src/test/java/org/apache/camel/component/urlrewrite/http4/Http4UrlRewritePingQueryTest.java Fri Dec 28 11:33:13 2012
@@ -14,24 +14,23 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.camel.component.urlrewrite.http;
+package org.apache.camel.component.urlrewrite.http4;
 
 import org.apache.camel.builder.RouteBuilder;
 import org.apache.camel.component.urlrewrite.BaseUrlRewriteTest;
-import org.apache.camel.component.urlrewrite.HttpUrlRewrite;
 import org.apache.camel.impl.JndiRegistry;
 import org.junit.Test;
 
 /**
  *
  */
-public class HttpUrlRewritePingQueryTest extends BaseUrlRewriteTest {
+public class Http4UrlRewritePingQueryTest extends BaseUrlRewriteTest {
 
     @Override
     protected JndiRegistry createRegistry() throws Exception {
         JndiRegistry jndi = super.createRegistry();
 
-        HttpUrlRewrite myRewrite = new HttpUrlRewrite();
+        Http4UrlRewrite myRewrite = new Http4UrlRewrite();
         myRewrite.setConfigFile("example/urlrewrite-ping.xml");
         myRewrite.setUseQueryString(true);
 
@@ -42,7 +41,7 @@ public class HttpUrlRewritePingQueryTest
 
     @Test
     public void testHttpUriRewrite() throws Exception {
-        String out = template.requestBody("http://localhost:{{port}}/ping?foo=bar", null, String.class);
+        String out = template.requestBody("http4://localhost:{{port}}/ping?foo=bar", null, String.class);
         assertEquals("http://localhost:" + getPort2() + "/proxy/ping?foo=bar", out);
     }
 
@@ -52,7 +51,7 @@ public class HttpUrlRewritePingQueryTest
             @Override
             public void configure() throws Exception {
                 from("jetty:http://localhost:{{port}}/?matchOnUriPrefix=true")
-                    .to("http://localhost:{{port2}}/?bridgeEndpoint=true&throwExceptionOnFailure=false&urlRewrite=#myRewrite");
+                    .to("http4://localhost:{{port2}}/?bridgeEndpoint=true&throwExceptionOnFailure=false&urlRewrite=#myRewrite");
 
                 from("jetty:http://localhost:{{port2}}/proxy/?matchOnUriPrefix=true")
                     .transform().simple("${header.CamelHttpUrl}?${header.CamelHttpQuery}");

Copied: camel/trunk/components/camel-urlrewrite/src/test/java/org/apache/camel/component/urlrewrite/http4/Http4UrlRewritePingTest.java (from r1426429, camel/trunk/components/camel-urlrewrite/src/test/java/org/apache/camel/component/urlrewrite/http/HttpUrlRewritePingTest.java)
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-urlrewrite/src/test/java/org/apache/camel/component/urlrewrite/http4/Http4UrlRewritePingTest.java?p2=camel/trunk/components/camel-urlrewrite/src/test/java/org/apache/camel/component/urlrewrite/http4/Http4UrlRewritePingTest.java&p1=camel/trunk/components/camel-urlrewrite/src/test/java/org/apache/camel/component/urlrewrite/http/HttpUrlRewritePingTest.java&r1=1426429&r2=1426462&rev=1426462&view=diff
==============================================================================
--- camel/trunk/components/camel-urlrewrite/src/test/java/org/apache/camel/component/urlrewrite/http/HttpUrlRewritePingTest.java (original)
+++ camel/trunk/components/camel-urlrewrite/src/test/java/org/apache/camel/component/urlrewrite/http4/Http4UrlRewritePingTest.java Fri Dec 28 11:33:13 2012
@@ -14,24 +14,23 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.camel.component.urlrewrite.http;
+package org.apache.camel.component.urlrewrite.http4;
 
 import org.apache.camel.builder.RouteBuilder;
 import org.apache.camel.component.urlrewrite.BaseUrlRewriteTest;
-import org.apache.camel.component.urlrewrite.HttpUrlRewrite;
 import org.apache.camel.impl.JndiRegistry;
 import org.junit.Test;
 
 /**
  *
  */
-public class HttpUrlRewritePingTest extends BaseUrlRewriteTest {
+public class Http4UrlRewritePingTest extends BaseUrlRewriteTest {
 
     @Override
     protected JndiRegistry createRegistry() throws Exception {
         JndiRegistry jndi = super.createRegistry();
 
-        HttpUrlRewrite myRewrite = new HttpUrlRewrite();
+        Http4UrlRewrite myRewrite = new Http4UrlRewrite();
         myRewrite.setConfigFile("example/urlrewrite-ping.xml");
         myRewrite.setUseQueryString(false);
 
@@ -42,7 +41,7 @@ public class HttpUrlRewritePingTest exte
 
     @Test
     public void testHttpUriRewrite() throws Exception {
-        String out = template.requestBody("http://localhost:{{port}}/ping", null, String.class);
+        String out = template.requestBody("http4://localhost:{{port}}/ping", null, String.class);
         assertEquals("http://localhost:" + getPort2() + "/proxy/ping", out);
     }
 
@@ -52,7 +51,7 @@ public class HttpUrlRewritePingTest exte
             @Override
             public void configure() throws Exception {
                 from("jetty:http://localhost:{{port}}/?matchOnUriPrefix=true")
-                    .to("http://localhost:{{port2}}/?bridgeEndpoint=true&throwExceptionOnFailure=false&urlRewrite=#myRewrite");
+                    .to("http4://localhost:{{port2}}/?bridgeEndpoint=true&throwExceptionOnFailure=false&urlRewrite=#myRewrite");
 
                 from("jetty:http://localhost:{{port2}}/proxy/?matchOnUriPrefix=true")
                     .transform().simple("${header.CamelHttpUrl}");

Copied: camel/trunk/components/camel-urlrewrite/src/test/java/org/apache/camel/component/urlrewrite/http4/Http4UrlRewriteTest.java (from r1426429, camel/trunk/components/camel-urlrewrite/src/test/java/org/apache/camel/component/urlrewrite/http/HttpUrlRewriteTest.java)
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-urlrewrite/src/test/java/org/apache/camel/component/urlrewrite/http4/Http4UrlRewriteTest.java?p2=camel/trunk/components/camel-urlrewrite/src/test/java/org/apache/camel/component/urlrewrite/http4/Http4UrlRewriteTest.java&p1=camel/trunk/components/camel-urlrewrite/src/test/java/org/apache/camel/component/urlrewrite/http/HttpUrlRewriteTest.java&r1=1426429&r2=1426462&rev=1426462&view=diff
==============================================================================
--- camel/trunk/components/camel-urlrewrite/src/test/java/org/apache/camel/component/urlrewrite/http/HttpUrlRewriteTest.java (original)
+++ camel/trunk/components/camel-urlrewrite/src/test/java/org/apache/camel/component/urlrewrite/http4/Http4UrlRewriteTest.java Fri Dec 28 11:33:13 2012
@@ -14,24 +14,23 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.camel.component.urlrewrite.http;
+package org.apache.camel.component.urlrewrite.http4;
 
 import org.apache.camel.builder.RouteBuilder;
 import org.apache.camel.component.urlrewrite.BaseUrlRewriteTest;
-import org.apache.camel.component.urlrewrite.HttpUrlRewrite;
 import org.apache.camel.impl.JndiRegistry;
 import org.junit.Test;
 
 /**
  *
  */
-public class HttpUrlRewriteTest extends BaseUrlRewriteTest {
+public class Http4UrlRewriteTest extends BaseUrlRewriteTest {
 
     @Override
     protected JndiRegistry createRegistry() throws Exception {
         JndiRegistry jndi = super.createRegistry();
 
-        HttpUrlRewrite myRewrite = new HttpUrlRewrite();
+        Http4UrlRewrite myRewrite = new Http4UrlRewrite();
         myRewrite.setConfigFile("example/urlrewrite2.xml");
 
         jndi.bind("myRewrite", myRewrite);
@@ -41,7 +40,7 @@ public class HttpUrlRewriteTest extends 
 
     @Test
     public void testHttpUriRewrite() throws Exception {
-        String out = template.requestBody("http://localhost:{{port}}/myapp/products/1234", null, String.class);
+        String out = template.requestBody("http4://localhost:{{port}}/myapp/products/1234", null, String.class);
         assertEquals("http://localhost:" + getPort2() + "/myapp2/products/index.jsp?product_id=1234", out);
     }
 
@@ -51,7 +50,7 @@ public class HttpUrlRewriteTest extends 
             @Override
             public void configure() throws Exception {
                 from("jetty:http://localhost:{{port}}/myapp?matchOnUriPrefix=true")
-                    .to("http://localhost:{{port2}}/myapp2?bridgeEndpoint=true&throwExceptionOnFailure=false&urlRewrite=#myRewrite");
+                    .to("http4://localhost:{{port2}}/myapp2?bridgeEndpoint=true&throwExceptionOnFailure=false&urlRewrite=#myRewrite");
 
                 from("jetty:http://localhost:{{port2}}/myapp2?matchOnUriPrefix=true")
                     .transform().simple("${header.CamelHttpUrl}?${header.CamelHttpQuery}");

Modified: camel/trunk/components/camel-urlrewrite/src/test/java/org/apache/camel/component/urlrewrite/jetty/JettyUrlRewriteModTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-urlrewrite/src/test/java/org/apache/camel/component/urlrewrite/jetty/JettyUrlRewriteModTest.java?rev=1426462&r1=1426461&r2=1426462&view=diff
==============================================================================
--- camel/trunk/components/camel-urlrewrite/src/test/java/org/apache/camel/component/urlrewrite/jetty/JettyUrlRewriteModTest.java (original)
+++ camel/trunk/components/camel-urlrewrite/src/test/java/org/apache/camel/component/urlrewrite/jetty/JettyUrlRewriteModTest.java Fri Dec 28 11:33:13 2012
@@ -18,7 +18,7 @@ package org.apache.camel.component.urlre
 
 import org.apache.camel.builder.RouteBuilder;
 import org.apache.camel.component.urlrewrite.BaseUrlRewriteTest;
-import org.apache.camel.component.urlrewrite.HttpUrlRewrite;
+import org.apache.camel.component.urlrewrite.http.HttpUrlRewrite;
 import org.apache.camel.impl.JndiRegistry;
 import org.junit.Test;
 

Modified: camel/trunk/components/camel-urlrewrite/src/test/java/org/apache/camel/component/urlrewrite/jetty/JettyUrlRewriteTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-urlrewrite/src/test/java/org/apache/camel/component/urlrewrite/jetty/JettyUrlRewriteTest.java?rev=1426462&r1=1426461&r2=1426462&view=diff
==============================================================================
--- camel/trunk/components/camel-urlrewrite/src/test/java/org/apache/camel/component/urlrewrite/jetty/JettyUrlRewriteTest.java (original)
+++ camel/trunk/components/camel-urlrewrite/src/test/java/org/apache/camel/component/urlrewrite/jetty/JettyUrlRewriteTest.java Fri Dec 28 11:33:13 2012
@@ -18,7 +18,7 @@ package org.apache.camel.component.urlre
 
 import org.apache.camel.builder.RouteBuilder;
 import org.apache.camel.component.urlrewrite.BaseUrlRewriteTest;
-import org.apache.camel.component.urlrewrite.HttpUrlRewrite;
+import org.apache.camel.component.urlrewrite.http.HttpUrlRewrite;
 import org.apache.camel.impl.JndiRegistry;
 import org.junit.Test;
 

Modified: camel/trunk/components/camel-urlrewrite/src/test/resources/log4j.properties
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-urlrewrite/src/test/resources/log4j.properties?rev=1426462&r1=1426461&r2=1426462&view=diff
==============================================================================
--- camel/trunk/components/camel-urlrewrite/src/test/resources/log4j.properties (original)
+++ camel/trunk/components/camel-urlrewrite/src/test/resources/log4j.properties Fri Dec 28 11:33:13 2012
@@ -21,7 +21,7 @@
 log4j.rootLogger=INFO, file
 
 # uncomment the following to enable camel debugging
-log4j.logger.org.apache.camel.component.urlrewrite=DEBUG
+#log4j.logger.org.apache.camel.component.urlrewrite=DEBUG
 
 # CONSOLE appender not used by default
 log4j.appender.out=org.apache.log4j.ConsoleAppender



Mime
View raw message