Repository: camel
Updated Branches:
  refs/heads/master 29b862b0c -> b40d713cf


Update the rest of the rest components to use the new APIs.


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

Branch: refs/heads/master
Commit: b40d713cf0ecb0be3d67e024d67109e78a28d488
Parents: 29b862b
Author: Daniel Kulp <dk...@apache.org>
Authored: Fri Jul 24 12:46:23 2015 -0400
Committer: Daniel Kulp <dk...@apache.org>
Committed: Fri Jul 24 12:46:23 2015 -0400

----------------------------------------------------------------------
 .../camel/component/rest/RestEndpoint.java      |  6 ++--
 .../netty/http/NettyHttpComponent.java          | 22 +++++++-------
 .../component/servlet/ServletComponent.java     | 11 +++----
 .../component/sparkrest/SparkComponent.java     | 30 ++++++++------------
 .../component/undertow/UndertowComponent.java   | 22 +++++++-------
 5 files changed, 40 insertions(+), 51 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/b40d713c/camel-core/src/main/java/org/apache/camel/component/rest/RestEndpoint.java
----------------------------------------------------------------------
diff --git 
a/camel-core/src/main/java/org/apache/camel/component/rest/RestEndpoint.java 
b/camel-core/src/main/java/org/apache/camel/component/rest/RestEndpoint.java
index 3c6dbcb..adb5f49 100644
--- a/camel-core/src/main/java/org/apache/camel/component/rest/RestEndpoint.java
+++ b/camel-core/src/main/java/org/apache/camel/component/rest/RestEndpoint.java
@@ -202,7 +202,7 @@ public class RestEndpoint extends DefaultEndpoint {
     @Override
     public Consumer createConsumer(Processor processor) throws Exception {
         RestConsumerFactory factory = null;
-
+        String cname = null;
         if (getComponentName() != null) {
             Object comp = 
getCamelContext().getRegistry().lookupByName(getComponentName());
             if (comp != null && comp instanceof RestConsumerFactory) {
@@ -221,6 +221,7 @@ public class RestEndpoint extends DefaultEndpoint {
                     throw new NoSuchBeanException(getComponentName(), 
RestConsumerFactory.class.getName());
                 }
             }
+            cname = getComponentName();
         }
 
         // try all components
@@ -229,6 +230,7 @@ public class RestEndpoint extends DefaultEndpoint {
                 Component comp = getCamelContext().getComponent(name);
                 if (comp != null && comp instanceof RestConsumerFactory) {
                     factory = (RestConsumerFactory) comp;
+                    cname = name;
                     break;
                 }
             }
@@ -251,7 +253,7 @@ public class RestEndpoint extends DefaultEndpoint {
             String host = "";
             int port = 80;
 
-            RestConfiguration config = 
getCamelContext().getRestConfiguration();
+            RestConfiguration config = 
getCamelContext().getRestConfiguration(cname, true);
             if (config.getScheme() != null) {
                 scheme = config.getScheme();
             }

http://git-wip-us.apache.org/repos/asf/camel/blob/b40d713c/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 5d9a6c9..23b1460 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
@@ -243,18 +243,16 @@ public class NettyHttpComponent extends NettyComponent 
implements HeaderFilterSt
         int port = 0;
 
         // if no explicit port/host configured, then use port from rest 
configuration
-        RestConfiguration config = getCamelContext().getRestConfiguration();
-        if (config.getComponent() == null || 
config.getComponent().equals("netty-http")) {
-            if (config.getScheme() != null) {
-                scheme = config.getScheme();
-            }
-            if (config.getHost() != null) {
-                host = config.getHost();
-            }
-            int num = config.getPort();
-            if (num > 0) {
-                port = num;
-            }
+        RestConfiguration config = 
getCamelContext().getRestConfiguration("netty-http", true);
+        if (config.getScheme() != null) {
+            scheme = config.getScheme();
+        }
+        if (config.getHost() != null) {
+            host = config.getHost();
+        }
+        int num = config.getPort();
+        if (num > 0) {
+            port = num;
         }
 
         // if no explicit hostname set then resolve the hostname

http://git-wip-us.apache.org/repos/asf/camel/blob/b40d713c/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 2bbf00f..b84bce2 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
@@ -172,15 +172,12 @@ public class ServletComponent extends HttpCommonComponent 
implements RestConsume
         path = FileUtil.stripLeadingSeparator(path);
 
         // if no explicit port/host configured, then use port from rest 
configuration
-        RestConfiguration config = getCamelContext().getRestConfiguration();
+        RestConfiguration config = 
getCamelContext().getRestConfiguration("servlet", true);
 
         Map<String, Object> map = new HashMap<String, Object>();
-        // build query string, and append any endpoint configuration properties
-        if (config.getComponent() == null || 
config.getComponent().equals("servlet")) {
-            // setup endpoint options
-            if (config.getEndpointProperties() != null && 
!config.getEndpointProperties().isEmpty()) {
-                map.putAll(config.getEndpointProperties());
-            }
+        // setup endpoint options
+        if (config.getEndpointProperties() != null && 
!config.getEndpointProperties().isEmpty()) {
+            map.putAll(config.getEndpointProperties());
         }
 
         String query = URISupport.createQueryString(map);

http://git-wip-us.apache.org/repos/asf/camel/blob/b40d713c/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 45cf59e..eb5cba8 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
@@ -121,12 +121,10 @@ public class SparkComponent extends UriEndpointComponent 
implements RestConsumer
             SparkBase.setPort(getPort());
         } else {
             // if no explicit port configured, then use port from rest 
configuration
-            RestConfiguration config = 
getCamelContext().getRestConfiguration();
-            if (config.getComponent() == null || 
config.getComponent().equals("spark-rest")) {
-                int port = config.getPort();
-                if (port > 0) {
-                    SparkBase.setPort(port);
-                }
+            RestConfiguration config = 
getCamelContext().getRestConfiguration("spark-rest", true);
+            int port = config.getPort();
+            if (port > 0) {
+                SparkBase.setPort(port);
             }
         }
         if (getIpAddress() != null) {
@@ -134,12 +132,10 @@ public class SparkComponent extends UriEndpointComponent 
implements RestConsumer
         }
 
         // configure component options
-        RestConfiguration config = getCamelContext().getRestConfiguration();
-        if (config.getComponent() == null || 
config.getComponent().equals("spark-rest")) {
-            // configure additional options on spark configuration
-            if (config.getComponentProperties() != null && 
!config.getComponentProperties().isEmpty()) {
-                setProperties(sparkConfiguration, 
config.getComponentProperties());
-            }
+        RestConfiguration config = 
getCamelContext().getRestConfiguration("spark-rest", true);
+        // configure additional options on spark configuration
+        if (config.getComponentProperties() != null && 
!config.getComponentProperties().isEmpty()) {
+            setProperties(sparkConfiguration, config.getComponentProperties());
         }
     }
 
@@ -178,12 +174,10 @@ public class SparkComponent extends UriEndpointComponent 
implements RestConsumer
         }
 
         // build query string, and append any endpoint configuration properties
-        RestConfiguration config = getCamelContext().getRestConfiguration();
-        if (config.getComponent() == null || 
config.getComponent().equals("spark-rest")) {
-            // setup endpoint options
-            if (config.getEndpointProperties() != null && 
!config.getEndpointProperties().isEmpty()) {
-                map.putAll(config.getEndpointProperties());
-            }
+        RestConfiguration config = 
getCamelContext().getRestConfiguration("spark-rest", true);
+        // setup endpoint options
+        if (config.getEndpointProperties() != null && 
!config.getEndpointProperties().isEmpty()) {
+            map.putAll(config.getEndpointProperties());
         }
 
         String query = URISupport.createQueryString(map);

http://git-wip-us.apache.org/repos/asf/camel/blob/b40d713c/components/camel-undertow/src/main/java/org/apache/camel/component/undertow/UndertowComponent.java
----------------------------------------------------------------------
diff --git 
a/components/camel-undertow/src/main/java/org/apache/camel/component/undertow/UndertowComponent.java
 
b/components/camel-undertow/src/main/java/org/apache/camel/component/undertow/UndertowComponent.java
index 84676b8..8f83680 100644
--- 
a/components/camel-undertow/src/main/java/org/apache/camel/component/undertow/UndertowComponent.java
+++ 
b/components/camel-undertow/src/main/java/org/apache/camel/component/undertow/UndertowComponent.java
@@ -92,18 +92,16 @@ public class UndertowComponent extends UriEndpointComponent 
implements RestConsu
         String scheme = "http";
         String host = "";
         int port = 0;
-        RestConfiguration config = getCamelContext().getRestConfiguration();
-        if (config.getComponent() == null || 
config.getComponent().equals("undertow")) {
-            if (config.getScheme() != null) {
-                scheme = config.getScheme();
-            }
-            if (config.getHost() != null) {
-                host = config.getHost();
-            }
-            int num = config.getPort();
-            if (num > 0) {
-                port = num;
-            }
+        RestConfiguration config = 
getCamelContext().getRestConfiguration("undertow", true);
+        if (config.getScheme() != null) {
+            scheme = config.getScheme();
+        }
+        if (config.getHost() != null) {
+            host = config.getHost();
+        }
+        int num = config.getPort();
+        if (num > 0) {
+            port = num;
         }
 
         Map<String, Object> map = new HashMap<String, Object>();

Reply via email to