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 2019/08/09 13:24:50 UTC

[camel] 02/02: CAMEL-13792: Fixed issue with camel-rest-swagger and renaming http components and some flaws with settign up rest configuration

This is an automated email from the ASF dual-hosted git repository.

davsclaus pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/camel.git

commit 1a5f8b26fccfe578e3d7029bde2c7ac1c0e1aa01
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Fri Aug 9 15:15:16 2019 +0200

    CAMEL-13792: Fixed issue with camel-rest-swagger and renaming http components and some flaws with settign up rest configuration
---
 .../java/org/apache/camel/component/http4/HttpComponent.java     | 8 +++++++-
 .../apache/camel/component/netty4/http/NettyHttpComponent.java   | 9 ++++++---
 .../java/org/apache/camel/component/rest/RestApiEndpoint.java    | 9 +++++++--
 .../main/java/org/apache/camel/component/rest/RestEndpoint.java  | 8 +++++++-
 .../org/apache/camel/component/undertow/UndertowComponent.java   | 9 ++++++---
 5 files changed, 33 insertions(+), 10 deletions(-)

diff --git a/components/camel-http/src/main/java/org/apache/camel/component/http4/HttpComponent.java b/components/camel-http/src/main/java/org/apache/camel/component/http4/HttpComponent.java
index ab4ec4d..2c90ba9 100644
--- a/components/camel-http/src/main/java/org/apache/camel/component/http4/HttpComponent.java
+++ b/components/camel-http/src/main/java/org/apache/camel/component/http4/HttpComponent.java
@@ -432,7 +432,13 @@ public class HttpComponent extends HttpCommonComponent implements RestProducerFa
 
         RestConfiguration config = configuration;
         if (config == null) {
-            config = camelContext.getRestConfiguration("http", true);
+            config = camelContext.getRestConfiguration("http", false);
+            if (config == null) {
+                camelContext.getRestConfiguration();
+            }
+            if (config == null) {
+                config = camelContext.getRestConfiguration("http", true);
+            }
         }
 
         Map<String, Object> map = new HashMap<>();
diff --git a/components/camel-netty-http/src/main/java/org/apache/camel/component/netty4/http/NettyHttpComponent.java b/components/camel-netty-http/src/main/java/org/apache/camel/component/netty4/http/NettyHttpComponent.java
index 8eadd9f..af59ab2 100644
--- a/components/camel-netty-http/src/main/java/org/apache/camel/component/netty4/http/NettyHttpComponent.java
+++ b/components/camel-netty-http/src/main/java/org/apache/camel/component/netty4/http/NettyHttpComponent.java
@@ -440,10 +440,13 @@ public class NettyHttpComponent extends NettyComponent implements HeaderFilterSt
         if (!ObjectHelper.isEmpty(uriTemplate)) {
             url += "/" + uriTemplate;
         }
-        
-        RestConfiguration config = configuration;
+
+        RestConfiguration config = getCamelContext().getRestConfiguration("netty-http", false);
         if (config == null) {
-            config = camelContext.getRestConfiguration("netty-http", true);
+            config = getCamelContext().getRestConfiguration();
+        }
+        if (config == null) {
+            config = getCamelContext().getRestConfiguration("netty-http", true);
         }
 
         Map<String, Object> map = new HashMap<>();
diff --git a/components/camel-rest/src/main/java/org/apache/camel/component/rest/RestApiEndpoint.java b/components/camel-rest/src/main/java/org/apache/camel/component/rest/RestApiEndpoint.java
index b393aa7..69bc559 100644
--- a/components/camel-rest/src/main/java/org/apache/camel/component/rest/RestApiEndpoint.java
+++ b/components/camel-rest/src/main/java/org/apache/camel/component/rest/RestApiEndpoint.java
@@ -24,7 +24,6 @@ import org.apache.camel.Component;
 import org.apache.camel.Consumer;
 import org.apache.camel.ExchangePattern;
 import org.apache.camel.ExtendedCamelContext;
-import org.apache.camel.NoFactoryAvailableException;
 import org.apache.camel.NoSuchBeanException;
 import org.apache.camel.Processor;
 import org.apache.camel.Producer;
@@ -134,7 +133,13 @@ public class RestApiEndpoint extends DefaultEndpoint {
     public Producer createProducer() throws Exception {
         RestApiProcessorFactory factory = null;
 
-        RestConfiguration config = getCamelContext().getRestConfiguration(consumerComponentName, true);
+        RestConfiguration config = getCamelContext().getRestConfiguration(consumerComponentName, false);
+        if (config == null) {
+            config = getCamelContext().getRestConfiguration();
+        }
+        if (config == null) {
+            config = getCamelContext().getRestConfiguration(consumerComponentName, true);
+        }
 
         // lookup in registry
         Set<RestApiProcessorFactory> factories = getCamelContext().getRegistry().findByType(RestApiProcessorFactory.class);
diff --git a/components/camel-rest/src/main/java/org/apache/camel/component/rest/RestEndpoint.java b/components/camel-rest/src/main/java/org/apache/camel/component/rest/RestEndpoint.java
index f2aab6f..4658f4b 100644
--- a/components/camel-rest/src/main/java/org/apache/camel/component/rest/RestEndpoint.java
+++ b/components/camel-rest/src/main/java/org/apache/camel/component/rest/RestEndpoint.java
@@ -378,7 +378,13 @@ public class RestEndpoint extends DefaultEndpoint {
         if (factory != null) {
             log.debug("Using RestProducerFactory: {}", factory);
 
-            RestConfiguration config = getCamelContext().getRestConfiguration(pname, true);
+            RestConfiguration config = getCamelContext().getRestConfiguration(pname, false);
+            if (config == null) {
+                config = getCamelContext().getRestConfiguration();
+            }
+            if (config == null) {
+                config = getCamelContext().getRestConfiguration(pname, true);
+            }
 
             Producer producer;
             if (apiDocFactory != null) {
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 2b5a5bc..57f9ec4 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
@@ -275,10 +275,13 @@ public class UndertowComponent extends DefaultComponent implements RestConsumerF
         if (!ObjectHelper.isEmpty(uriTemplate)) {
             url += "/" + uriTemplate;
         }
-        
-        RestConfiguration config = configuration;
+
+        RestConfiguration config = getCamelContext().getRestConfiguration(getComponentName(), false);
         if (config == null) {
-            config = camelContext.getRestConfiguration(getComponentName(), true);
+            config = getCamelContext().getRestConfiguration();
+        }
+        if (config == null) {
+            config = getCamelContext().getRestConfiguration(getComponentName(), true);
         }
 
         Map<String, Object> map = new HashMap<>();