You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by da...@apache.org on 2015/09/28 07:42:35 UTC

[1/4] camel git commit: Enable the user of contextPath() parameter for netty4-http rest configuration. It will just prepend it to the path really but this should make drop in replacement between different rest components (e.g. servlet) more seamless and

Repository: camel
Updated Branches:
  refs/heads/master 473942a4f -> bc9260414


Enable the user of contextPath() parameter for netty4-http rest configuration. It will just prepend it to the path really but this should make drop in replacement between different rest components (e.g. servlet) more seamless and intuitive.


Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/bd04ab1d
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/bd04ab1d
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/bd04ab1d

Branch: refs/heads/master
Commit: bd04ab1dfbe1902ff7db6cae33846c7aa4b89288
Parents: 473942a
Author: Askannon <as...@flexarc.com>
Authored: Sun Sep 27 13:12:26 2015 +0200
Committer: Claus Ibsen <da...@apache.org>
Committed: Mon Sep 28 07:19:08 2015 +0200

----------------------------------------------------------------------
 .../netty4/http/NettyHttpComponent.java         | 10 ++-
 ...stNettyHttpContextPathConfigurationTest.java | 68 ++++++++++++++++++++
 2 files changed, 77 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/bd04ab1d/components/camel-netty4-http/src/main/java/org/apache/camel/component/netty4/http/NettyHttpComponent.java
----------------------------------------------------------------------
diff --git a/components/camel-netty4-http/src/main/java/org/apache/camel/component/netty4/http/NettyHttpComponent.java b/components/camel-netty4-http/src/main/java/org/apache/camel/component/netty4/http/NettyHttpComponent.java
index ae8e78c..7e2cbc2 100644
--- a/components/camel-netty4-http/src/main/java/org/apache/camel/component/netty4/http/NettyHttpComponent.java
+++ b/components/camel-netty4-http/src/main/java/org/apache/camel/component/netty4/http/NettyHttpComponent.java
@@ -41,6 +41,7 @@ import org.apache.camel.util.ObjectHelper;
 import org.apache.camel.util.ServiceHelper;
 import org.apache.camel.util.URISupport;
 import org.apache.camel.util.UnsafeUriCharactersEncoder;
+import org.apache.commons.lang3.StringUtils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -249,7 +250,7 @@ public class NettyHttpComponent extends NettyComponent implements HeaderFilterSt
             }
         }
         path = FileUtil.stripLeadingSeparator(path);
-
+        
         String scheme = "http";
         String host = "";
         int port = 0;
@@ -270,6 +271,13 @@ public class NettyHttpComponent extends NettyComponent implements HeaderFilterSt
             port = num;
         }
 
+        String contextPath = config.getContextPath();
+        if(StringUtils.isNotEmpty(contextPath)) {
+        	contextPath = FileUtil.stripTrailingSeparator(contextPath);
+        	contextPath = FileUtil.stripLeadingSeparator(contextPath);
+        	path =  contextPath + "/" + path;
+        }
+        
         // if no explicit hostname set then resolve the hostname
         if (ObjectHelper.isEmpty(host)) {
             if (config.getRestHostNameResolver() == RestConfiguration.RestHostNameResolver.localHostName) {

http://git-wip-us.apache.org/repos/asf/camel/blob/bd04ab1d/components/camel-netty4-http/src/test/java/org/apache/camel/component/netty4/http/rest/RestNettyHttpContextPathConfigurationTest.java
----------------------------------------------------------------------
diff --git a/components/camel-netty4-http/src/test/java/org/apache/camel/component/netty4/http/rest/RestNettyHttpContextPathConfigurationTest.java b/components/camel-netty4-http/src/test/java/org/apache/camel/component/netty4/http/rest/RestNettyHttpContextPathConfigurationTest.java
new file mode 100644
index 0000000..87c0750
--- /dev/null
+++ b/components/camel-netty4-http/src/test/java/org/apache/camel/component/netty4/http/rest/RestNettyHttpContextPathConfigurationTest.java
@@ -0,0 +1,68 @@
+/**
+ * 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.netty4.http.rest;
+
+import org.apache.camel.Exchange;
+import org.apache.camel.Processor;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.netty4.http.BaseNettyTest;
+import org.junit.Test;
+
+public class RestNettyHttpContextPathConfigurationTest extends BaseNettyTest {
+
+    @Test
+    public void testProducerGet() throws Exception {
+        String out = template.requestBody("netty4-http:http://localhost:{{port}}/rest/users/123", null, String.class);
+        assertEquals("123;Donald Duck", out);
+
+        out = template.requestBody("netty4-http:http://localhost:{{port}}/rest/users/list", null, String.class);
+        assertEquals("123;Donald Duck\n456;John Doe", out);
+    }
+
+    @Override
+    protected RouteBuilder createRouteBuilder() throws Exception {
+        return new RouteBuilder() {
+            @Override
+            public void configure() throws Exception {
+                // configure to use netty4-http on localhost with the given port
+                restConfiguration().component("netty4-http").contextPath("/rest").host("localhost").port(getPort());
+
+                // use the rest DSL to define the rest services
+                rest("/users/")
+                    .get("{id}")
+                        .route()
+                        .to("mock:input")
+                        .process(new Processor() {
+                            public void process(Exchange exchange) throws Exception {
+                                String id = exchange.getIn().getHeader("id", String.class);
+                                exchange.getOut().setBody(id + ";Donald Duck");
+                            }
+                        })
+                    .endRest()
+                    .get("list")
+                        .route()
+                        .to("mock:input")
+                        .process(new Processor() {
+                            public void process(Exchange exchange) throws Exception {
+                                exchange.getOut().setBody("123;Donald Duck\n456;John Doe");
+                            }
+                        });
+            }
+        };
+    }
+
+}


[3/4] camel git commit: Fixed CS. This closes #624.

Posted by da...@apache.org.
Fixed CS. This closes #624.


Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/6ffcaccc
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/6ffcaccc
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/6ffcaccc

Branch: refs/heads/master
Commit: 6ffcaccc3dfae27cb3465509738952b33e3c5315
Parents: 91812a5
Author: Claus Ibsen <da...@apache.org>
Authored: Mon Sep 28 07:22:29 2015 +0200
Committer: Claus Ibsen <da...@apache.org>
Committed: Mon Sep 28 07:22:29 2015 +0200

----------------------------------------------------------------------
 .../camel/component/netty/http/NettyHttpComponent.java       | 8 ++++----
 .../camel/component/netty4/http/NettyHttpComponent.java      | 8 ++++----
 2 files changed, 8 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/6ffcaccc/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/NettyHttpComponent.java
----------------------------------------------------------------------
diff --git a/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/NettyHttpComponent.java b/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/NettyHttpComponent.java
index 2763256..370c6c8 100644
--- a/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/NettyHttpComponent.java
+++ b/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/NettyHttpComponent.java
@@ -272,10 +272,10 @@ public class NettyHttpComponent extends NettyComponent implements HeaderFilterSt
         }
 
         String contextPath = config.getContextPath();
-        if(ObjectHelper.isNotEmpty(contextPath)) {
-        	contextPath = FileUtil.stripTrailingSeparator(contextPath);
-        	contextPath = FileUtil.stripLeadingSeparator(contextPath);
-        	path =  contextPath + "/" + path;
+        if (ObjectHelper.isNotEmpty(contextPath)) {
+            contextPath = FileUtil.stripTrailingSeparator(contextPath);
+            contextPath = FileUtil.stripLeadingSeparator(contextPath);
+            path = contextPath + "/" + path;
         }
         
         // if no explicit hostname set then resolve the hostname

http://git-wip-us.apache.org/repos/asf/camel/blob/6ffcaccc/components/camel-netty4-http/src/main/java/org/apache/camel/component/netty4/http/NettyHttpComponent.java
----------------------------------------------------------------------
diff --git a/components/camel-netty4-http/src/main/java/org/apache/camel/component/netty4/http/NettyHttpComponent.java b/components/camel-netty4-http/src/main/java/org/apache/camel/component/netty4/http/NettyHttpComponent.java
index bf104c4..1f8e397 100644
--- a/components/camel-netty4-http/src/main/java/org/apache/camel/component/netty4/http/NettyHttpComponent.java
+++ b/components/camel-netty4-http/src/main/java/org/apache/camel/component/netty4/http/NettyHttpComponent.java
@@ -271,10 +271,10 @@ public class NettyHttpComponent extends NettyComponent implements HeaderFilterSt
         }
 
         String contextPath = config.getContextPath();
-        if(ObjectHelper.isNotEmpty(contextPath)) {
-        	contextPath = FileUtil.stripTrailingSeparator(contextPath);
-        	contextPath = FileUtil.stripLeadingSeparator(contextPath);
-        	path =  contextPath + "/" + path;
+        if (ObjectHelper.isNotEmpty(contextPath)) {
+            contextPath = FileUtil.stripTrailingSeparator(contextPath);
+            contextPath = FileUtil.stripLeadingSeparator(contextPath);
+            path = contextPath + "/" + path;
         }
         
         // if no explicit hostname set then resolve the hostname


[2/4] camel git commit: Removed commons-lang3 dependency and added same functionality to camel-netty-http component

Posted by da...@apache.org.
Removed commons-lang3 dependency and added same functionality to camel-netty-http component


Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/91812a56
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/91812a56
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/91812a56

Branch: refs/heads/master
Commit: 91812a5658d2a401eaa7b19618ac17a8c0343dde
Parents: bd04ab1
Author: Askannon <as...@flexarc.com>
Authored: Sun Sep 27 22:36:32 2015 +0200
Committer: Claus Ibsen <da...@apache.org>
Committed: Mon Sep 28 07:19:09 2015 +0200

----------------------------------------------------------------------
 .../netty/http/NettyHttpComponent.java          |  7 ++
 ...stNettyHttpContextPathConfigurationTest.java | 68 ++++++++++++++++++++
 .../netty4/http/NettyHttpComponent.java         |  3 +-
 3 files changed, 76 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/91812a56/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/NettyHttpComponent.java
----------------------------------------------------------------------
diff --git a/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/NettyHttpComponent.java b/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/NettyHttpComponent.java
index 0ce17c6..2763256 100644
--- a/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/NettyHttpComponent.java
+++ b/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/NettyHttpComponent.java
@@ -271,6 +271,13 @@ public class NettyHttpComponent extends NettyComponent implements HeaderFilterSt
             port = num;
         }
 
+        String contextPath = config.getContextPath();
+        if(ObjectHelper.isNotEmpty(contextPath)) {
+        	contextPath = FileUtil.stripTrailingSeparator(contextPath);
+        	contextPath = FileUtil.stripLeadingSeparator(contextPath);
+        	path =  contextPath + "/" + path;
+        }
+        
         // if no explicit hostname set then resolve the hostname
         if (ObjectHelper.isEmpty(host)) {
             if (config.getRestHostNameResolver() == RestConfiguration.RestHostNameResolver.localHostName) {

http://git-wip-us.apache.org/repos/asf/camel/blob/91812a56/components/camel-netty-http/src/test/java/org/apache/camel/component/netty/http/rest/RestNettyHttpContextPathConfigurationTest.java
----------------------------------------------------------------------
diff --git a/components/camel-netty-http/src/test/java/org/apache/camel/component/netty/http/rest/RestNettyHttpContextPathConfigurationTest.java b/components/camel-netty-http/src/test/java/org/apache/camel/component/netty/http/rest/RestNettyHttpContextPathConfigurationTest.java
new file mode 100644
index 0000000..4a7c559
--- /dev/null
+++ b/components/camel-netty-http/src/test/java/org/apache/camel/component/netty/http/rest/RestNettyHttpContextPathConfigurationTest.java
@@ -0,0 +1,68 @@
+/**
+ * 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.netty.http.rest;
+
+import org.apache.camel.Exchange;
+import org.apache.camel.Processor;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.netty.http.BaseNettyTest;
+import org.junit.Test;
+
+public class RestNettyHttpContextPathConfigurationTest extends BaseNettyTest {
+
+    @Test
+    public void testProducerGet() throws Exception {
+        String out = template.requestBody("netty-http:http://localhost:{{port}}/rest/users/123", null, String.class);
+        assertEquals("123;Donald Duck", out);
+
+        out = template.requestBody("netty-http:http://localhost:{{port}}/rest/users/list", null, String.class);
+        assertEquals("123;Donald Duck\n456;John Doe", out);
+    }
+
+    @Override
+    protected RouteBuilder createRouteBuilder() throws Exception {
+        return new RouteBuilder() {
+            @Override
+            public void configure() throws Exception {
+                // configure to use netty-http on localhost with the given port
+                restConfiguration().component("netty-http").host("localhost").contextPath("/rest").port(getPort());
+
+                // use the rest DSL to define the rest services
+                rest("/users/")
+                    .get("{id}")
+                        .route()
+                        .to("mock:input")
+                        .process(new Processor() {
+                            public void process(Exchange exchange) throws Exception {
+                                String id = exchange.getIn().getHeader("id", String.class);
+                                exchange.getOut().setBody(id + ";Donald Duck");
+                            }
+                        })
+                    .endRest()
+                    .get("list")
+                        .route()
+                        .to("mock:input")
+                        .process(new Processor() {
+                            public void process(Exchange exchange) throws Exception {
+                                exchange.getOut().setBody("123;Donald Duck\n456;John Doe");
+                            }
+                        });
+            }
+        };
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/91812a56/components/camel-netty4-http/src/main/java/org/apache/camel/component/netty4/http/NettyHttpComponent.java
----------------------------------------------------------------------
diff --git a/components/camel-netty4-http/src/main/java/org/apache/camel/component/netty4/http/NettyHttpComponent.java b/components/camel-netty4-http/src/main/java/org/apache/camel/component/netty4/http/NettyHttpComponent.java
index 7e2cbc2..bf104c4 100644
--- a/components/camel-netty4-http/src/main/java/org/apache/camel/component/netty4/http/NettyHttpComponent.java
+++ b/components/camel-netty4-http/src/main/java/org/apache/camel/component/netty4/http/NettyHttpComponent.java
@@ -41,7 +41,6 @@ import org.apache.camel.util.ObjectHelper;
 import org.apache.camel.util.ServiceHelper;
 import org.apache.camel.util.URISupport;
 import org.apache.camel.util.UnsafeUriCharactersEncoder;
-import org.apache.commons.lang3.StringUtils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -272,7 +271,7 @@ public class NettyHttpComponent extends NettyComponent implements HeaderFilterSt
         }
 
         String contextPath = config.getContextPath();
-        if(StringUtils.isNotEmpty(contextPath)) {
+        if(ObjectHelper.isNotEmpty(contextPath)) {
         	contextPath = FileUtil.stripTrailingSeparator(contextPath);
         	contextPath = FileUtil.stripLeadingSeparator(contextPath);
         	path =  contextPath + "/" + path;


[4/4] camel git commit: rest-dsl - Components should use context-path configuration so you can configure this in the rest-dsl.

Posted by da...@apache.org.
rest-dsl - Components should use context-path configuration so you can configure this in the rest-dsl.


Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/bc926041
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/bc926041
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/bc926041

Branch: refs/heads/master
Commit: bc9260414d77e873841d1cce7ae47742707af236
Parents: 6ffcacc
Author: Claus Ibsen <da...@apache.org>
Authored: Mon Sep 28 07:44:15 2015 +0200
Committer: Claus Ibsen <da...@apache.org>
Committed: Mon Sep 28 07:44:15 2015 +0200

----------------------------------------------------------------------
 .../model/rest/RestConfigurationDefinition.java | 10 ++++--
 .../org/apache/camel/spi/RestConfiguration.java |  3 +-
 .../component/jetty/JettyHttpComponent.java     | 10 ++++++
 .../netty/http/NettyHttpComponent.java          |  5 ++-
 .../netty4/http/NettyHttpComponent.java         |  5 ++-
 .../component/restlet/RestletComponent.java     | 10 ++++++
 .../component/servlet/ServletComponent.java     |  2 ++
 .../component/sparkrest/SparkComponent.java     | 32 +++++++++++++-------
 8 files changed, 60 insertions(+), 17 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/bc926041/camel-core/src/main/java/org/apache/camel/model/rest/RestConfigurationDefinition.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/model/rest/RestConfigurationDefinition.java b/camel-core/src/main/java/org/apache/camel/model/rest/RestConfigurationDefinition.java
index 2854eb2..7429fb1 100644
--- a/camel-core/src/main/java/org/apache/camel/model/rest/RestConfigurationDefinition.java
+++ b/camel-core/src/main/java/org/apache/camel/model/rest/RestConfigurationDefinition.java
@@ -174,7 +174,10 @@ public class RestConfigurationDefinition {
 
     /**
      * Sets a leading context-path the REST services will be using.
-     * This can be used when using components such as SERVLET where the deployed web application is deployed using a context-path.
+     * <p/>
+     * This can be used when using components such as <tt>camel-servlet</tt> where the deployed web application
+     * is deployed using a context-path. Or for components such as <tt>camel-jetty</tt> or <tt>camel-netty4-http</tt>
+     * that includes a HTTP server.
      */
     public void setContextPath(String contextPath) {
         this.contextPath = contextPath;
@@ -429,10 +432,11 @@ public class RestConfigurationDefinition {
     }
 
     /**
-     * Sets a leading API context-path the REST API services will be using.
+     * Sets a leading context-path the REST services will be using.
      * <p/>
      * This can be used when using components such as <tt>camel-servlet</tt> where the deployed web application
-     * is deployed using a context-path.
+     * is deployed using a context-path. Or for components such as <tt>camel-jetty</tt> or <tt>camel-netty4-http</tt>
+     * that includes a HTTP server.
      */
     public RestConfigurationDefinition apiContextPath(String contextPath) {
         setApiContextPath(contextPath);

http://git-wip-us.apache.org/repos/asf/camel/blob/bc926041/camel-core/src/main/java/org/apache/camel/spi/RestConfiguration.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/spi/RestConfiguration.java b/camel-core/src/main/java/org/apache/camel/spi/RestConfiguration.java
index 4c78a39..8c057ea 100644
--- a/camel-core/src/main/java/org/apache/camel/spi/RestConfiguration.java
+++ b/camel-core/src/main/java/org/apache/camel/spi/RestConfiguration.java
@@ -162,7 +162,8 @@ public class RestConfiguration {
      * Sets a leading context-path the REST services will be using.
      * <p/>
      * This can be used when using components such as <tt>camel-servlet</tt> where the deployed web application
-     * is deployed using a context-path.
+     * is deployed using a context-path. Or for components such as <tt>camel-jetty</tt> or <tt>camel-netty4-http</tt>
+     * that includes a HTTP server.
      *
      * @param contextPath the context path
      */

http://git-wip-us.apache.org/repos/asf/camel/blob/bc926041/components/camel-jetty-common/src/main/java/org/apache/camel/component/jetty/JettyHttpComponent.java
----------------------------------------------------------------------
diff --git a/components/camel-jetty-common/src/main/java/org/apache/camel/component/jetty/JettyHttpComponent.java b/components/camel-jetty-common/src/main/java/org/apache/camel/component/jetty/JettyHttpComponent.java
index 03b5d17..bcaea1b 100644
--- a/components/camel-jetty-common/src/main/java/org/apache/camel/component/jetty/JettyHttpComponent.java
+++ b/components/camel-jetty-common/src/main/java/org/apache/camel/component/jetty/JettyHttpComponent.java
@@ -1036,6 +1036,16 @@ public abstract class JettyHttpComponent extends HttpCommonComponent implements
             port = num;
         }
 
+        // prefix path with context-path if configured in rest-dsl configuration
+        String contextPath = config.getContextPath();
+        if (ObjectHelper.isNotEmpty(contextPath)) {
+            contextPath = FileUtil.stripTrailingSeparator(contextPath);
+            contextPath = FileUtil.stripLeadingSeparator(contextPath);
+            if (ObjectHelper.isNotEmpty(contextPath)) {
+                path = contextPath + "/" + path;
+            }
+        }
+
         // if no explicit hostname set then resolve the hostname
         if (ObjectHelper.isEmpty(host)) {
             if (config.getRestHostNameResolver() == RestConfiguration.RestHostNameResolver.localHostName) {

http://git-wip-us.apache.org/repos/asf/camel/blob/bc926041/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/NettyHttpComponent.java
----------------------------------------------------------------------
diff --git a/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/NettyHttpComponent.java b/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/NettyHttpComponent.java
index 370c6c8..a9d8c27 100644
--- a/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/NettyHttpComponent.java
+++ b/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/NettyHttpComponent.java
@@ -271,11 +271,14 @@ public class NettyHttpComponent extends NettyComponent implements HeaderFilterSt
             port = num;
         }
 
+        // prefix path with context-path if configured in rest-dsl configuration
         String contextPath = config.getContextPath();
         if (ObjectHelper.isNotEmpty(contextPath)) {
             contextPath = FileUtil.stripTrailingSeparator(contextPath);
             contextPath = FileUtil.stripLeadingSeparator(contextPath);
-            path = contextPath + "/" + path;
+            if (ObjectHelper.isNotEmpty(contextPath)) {
+                path = contextPath + "/" + path;
+            }
         }
         
         // if no explicit hostname set then resolve the hostname

http://git-wip-us.apache.org/repos/asf/camel/blob/bc926041/components/camel-netty4-http/src/main/java/org/apache/camel/component/netty4/http/NettyHttpComponent.java
----------------------------------------------------------------------
diff --git a/components/camel-netty4-http/src/main/java/org/apache/camel/component/netty4/http/NettyHttpComponent.java b/components/camel-netty4-http/src/main/java/org/apache/camel/component/netty4/http/NettyHttpComponent.java
index 1f8e397..989d2ee 100644
--- a/components/camel-netty4-http/src/main/java/org/apache/camel/component/netty4/http/NettyHttpComponent.java
+++ b/components/camel-netty4-http/src/main/java/org/apache/camel/component/netty4/http/NettyHttpComponent.java
@@ -270,11 +270,14 @@ public class NettyHttpComponent extends NettyComponent implements HeaderFilterSt
             port = num;
         }
 
+        // prefix path with context-path if configured in rest-dsl configuration
         String contextPath = config.getContextPath();
         if (ObjectHelper.isNotEmpty(contextPath)) {
             contextPath = FileUtil.stripTrailingSeparator(contextPath);
             contextPath = FileUtil.stripLeadingSeparator(contextPath);
-            path = contextPath + "/" + path;
+            if (ObjectHelper.isNotEmpty(contextPath)) {
+                path = contextPath + "/" + path;
+            }
         }
         
         // if no explicit hostname set then resolve the hostname

http://git-wip-us.apache.org/repos/asf/camel/blob/bc926041/components/camel-restlet/src/main/java/org/apache/camel/component/restlet/RestletComponent.java
----------------------------------------------------------------------
diff --git a/components/camel-restlet/src/main/java/org/apache/camel/component/restlet/RestletComponent.java b/components/camel-restlet/src/main/java/org/apache/camel/component/restlet/RestletComponent.java
index 9b91d90..4b809ea 100644
--- a/components/camel-restlet/src/main/java/org/apache/camel/component/restlet/RestletComponent.java
+++ b/components/camel-restlet/src/main/java/org/apache/camel/component/restlet/RestletComponent.java
@@ -698,6 +698,16 @@ public class RestletComponent extends HeaderFilterStrategyComponent implements R
             port = num;
         }
 
+        // prefix path with context-path if configured in rest-dsl configuration
+        String contextPath = config.getContextPath();
+        if (ObjectHelper.isNotEmpty(contextPath)) {
+            contextPath = FileUtil.stripTrailingSeparator(contextPath);
+            contextPath = FileUtil.stripLeadingSeparator(contextPath);
+            if (ObjectHelper.isNotEmpty(contextPath)) {
+                path = contextPath + "/" + path;
+            }
+        }
+
         // if no explicit hostname set then resolve the hostname
         if (ObjectHelper.isEmpty(host)) {
             if (config.getRestHostNameResolver() == RestConfiguration.RestHostNameResolver.localHostName) {

http://git-wip-us.apache.org/repos/asf/camel/blob/bc926041/components/camel-servlet/src/main/java/org/apache/camel/component/servlet/ServletComponent.java
----------------------------------------------------------------------
diff --git a/components/camel-servlet/src/main/java/org/apache/camel/component/servlet/ServletComponent.java b/components/camel-servlet/src/main/java/org/apache/camel/component/servlet/ServletComponent.java
index 9aa1300..5aca6a6 100644
--- a/components/camel-servlet/src/main/java/org/apache/camel/component/servlet/ServletComponent.java
+++ b/components/camel-servlet/src/main/java/org/apache/camel/component/servlet/ServletComponent.java
@@ -197,6 +197,8 @@ public class ServletComponent extends HttpCommonComponent implements RestConsume
             map.putAll(config.getEndpointProperties());
         }
 
+        // do not append with context-path as the servlet path should be without context-path
+
         String query = URISupport.createQueryString(map);
 
         String url;

http://git-wip-us.apache.org/repos/asf/camel/blob/bc926041/components/camel-spark-rest/src/main/java/org/apache/camel/component/sparkrest/SparkComponent.java
----------------------------------------------------------------------
diff --git a/components/camel-spark-rest/src/main/java/org/apache/camel/component/sparkrest/SparkComponent.java b/components/camel-spark-rest/src/main/java/org/apache/camel/component/sparkrest/SparkComponent.java
index 826db58..8850346 100644
--- a/components/camel-spark-rest/src/main/java/org/apache/camel/component/sparkrest/SparkComponent.java
+++ b/components/camel-spark-rest/src/main/java/org/apache/camel/component/sparkrest/SparkComponent.java
@@ -159,29 +159,39 @@ public class SparkComponent extends UriEndpointComponent implements RestConsumer
         }
         path = FileUtil.stripLeadingSeparator(path);
 
-        if (ObjectHelper.isNotEmpty(path)) {
-            // spark-rest uses :name syntax instead of {name} so we need to replace those
-            Matcher matcher = pattern.matcher(path);
-            path = matcher.replaceAll(":$1");
+        RestConfiguration config = configuration;
+        if (config == null) {
+            config = getCamelContext().getRestConfiguration("spark-rest", true);
         }
 
-        String uri = String.format("spark-rest:%s:%s", verb, path);
-
         Map<String, Object> map = new HashMap<String, Object>();
         if (consumes != null) {
             map.put("accept", consumes);
         }
 
-        // build query string, and append any endpoint configuration properties
-        RestConfiguration config = configuration;
-        if (config == null) {
-            config = getCamelContext().getRestConfiguration("spark-rest", true);
-        }
         // setup endpoint options
         if (config.getEndpointProperties() != null && !config.getEndpointProperties().isEmpty()) {
             map.putAll(config.getEndpointProperties());
         }
 
+        if (ObjectHelper.isNotEmpty(path)) {
+            // spark-rest uses :name syntax instead of {name} so we need to replace those
+            Matcher matcher = pattern.matcher(path);
+            path = matcher.replaceAll(":$1");
+        }
+
+        // prefix path with context-path if configured in rest-dsl configuration
+        String contextPath = config.getContextPath();
+        if (ObjectHelper.isNotEmpty(contextPath)) {
+            contextPath = FileUtil.stripTrailingSeparator(contextPath);
+            contextPath = FileUtil.stripLeadingSeparator(contextPath);
+            if (ObjectHelper.isNotEmpty(contextPath)) {
+                path = contextPath + "/" + path;
+            }
+        }
+
+        String uri = String.format("spark-rest:%s:%s", verb, path);
+
         String query = URISupport.createQueryString(map);
 
         String url = uri;