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/12/11 07:44:24 UTC

[camel] branch camel-3.0.x updated (f3db196 -> 75c9b25)

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

davsclaus pushed a change to branch camel-3.0.x
in repository https://gitbox.apache.org/repos/asf/camel.git.


    from f3db196  CAMEL-14268: Component auto configuration fails in Java 11
     new 27eb205  CAMEL-14287: getComponent on CamelContext should initialize component
     new 25a24db  CAMEL-14288: Endpoint configurer should deal better with list types
     new 75c9b25  CAMEL-14288: Endpoint configurer should deal better with list types

The 3 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../camel/impl/engine/AbstractCamelContext.java    | 22 +++++++++----------
 .../org/apache/camel/support/EndpointHelper.java   |  3 ++-
 .../component/PropertyConfigurerSupport.java       | 25 ++++++++++++++++------
 3 files changed, 30 insertions(+), 20 deletions(-)


[camel] 03/03: CAMEL-14288: Endpoint configurer should deal better with list types

Posted by da...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit 75c9b251e3f545925e14085bd7c6f257c718b3cf
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Wed Dec 11 08:22:07 2019 +0100

    CAMEL-14288: Endpoint configurer should deal better with list types
---
 .../org/apache/camel/support/component/PropertyConfigurerSupport.java  | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/core/camel-support/src/main/java/org/apache/camel/support/component/PropertyConfigurerSupport.java b/core/camel-support/src/main/java/org/apache/camel/support/component/PropertyConfigurerSupport.java
index 349ea15..9b8612c 100644
--- a/core/camel-support/src/main/java/org/apache/camel/support/component/PropertyConfigurerSupport.java
+++ b/core/camel-support/src/main/java/org/apache/camel/support/component/PropertyConfigurerSupport.java
@@ -56,9 +56,6 @@ public abstract class PropertyConfigurerSupport {
                     // no bean found so throw an exception
                     throw new NoSuchBeanException(text, type.getName());
                 }
-            } else if (type == List.class) {
-                // its a list but we have a string, where we support splitting via comma
-                obj = Arrays.asList(text.split(","));
             }
             if (obj != null) {
                 value = obj;


[camel] 01/03: CAMEL-14287: getComponent on CamelContext should initialize component

Posted by da...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit 27eb20548fe32f11d6ed244725e77fd292a635c3
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Wed Dec 11 05:40:27 2019 +0100

    CAMEL-14287: getComponent on CamelContext should initialize component
---
 .../camel/impl/engine/AbstractCamelContext.java    | 22 ++++++++++------------
 1 file changed, 10 insertions(+), 12 deletions(-)

diff --git a/core/camel-base/src/main/java/org/apache/camel/impl/engine/AbstractCamelContext.java b/core/camel-base/src/main/java/org/apache/camel/impl/engine/AbstractCamelContext.java
index 9c3681c..43dd4da 100644
--- a/core/camel-base/src/main/java/org/apache/camel/impl/engine/AbstractCamelContext.java
+++ b/core/camel-base/src/main/java/org/apache/camel/impl/engine/AbstractCamelContext.java
@@ -475,10 +475,10 @@ public abstract class AbstractCamelContext extends ServiceSupport implements Ext
 
     @Override
     public Component getComponent(String name, boolean autoCreateComponents, boolean autoStart) {
+        // ensure CamelContext are initialized before we can get a component
         init();
 
-        // Check if the named component is already being created, that would
-        // mean
+        // Check if the named component is already being created, that would mean
         // that the initComponent has triggered a new getComponent
         if (componentsInCreation.get().contains(name)) {
             throw new IllegalStateException("Circular dependency detected, the component " + name + " is already being created");
@@ -497,10 +497,8 @@ public abstract class AbstractCamelContext extends ServiceSupport implements Ext
                 }
             });
 
-            // Start the component after its creation as if it is a component
-            // proxy
-            // that creates/start a delegated component, we may end up in a
-            // deadlock
+            // Start the component after its creation as if it is a component proxy
+            // that creates/start a delegated component, we may end up in a deadlock
             if (component != null && created.get() && autoStart && (isStarted() || isStarting())) {
                 // If the component is looked up after the context is started,
                 // lets start it up.
@@ -532,12 +530,10 @@ public abstract class AbstractCamelContext extends ServiceSupport implements Ext
                 // requests.
                 //
                 // In spring apps, the component resolver may trigger a new
-                // getComponent
-                // because of the underlying bean factory and as the endpoints
-                // are
-                // registered as singleton, the spring factory creates the bean
-                // and then check the type so the getComponent is always
-                // triggered.
+                // getComponent because of the underlying bean factory and as
+                // the endpoints are registered as singleton, the spring factory
+                // creates the bean and then check the type so the getComponent
+                // is always triggered.
                 //
                 // Simple circular dependency:
                 //
@@ -568,6 +564,7 @@ public abstract class AbstractCamelContext extends ServiceSupport implements Ext
                 component = getComponentResolver().resolveComponent(name, this);
                 if (component != null) {
                     component.setCamelContext(this);
+                    ServiceHelper.initService(component);
                     postInitComponent(name, component);
                 }
             } catch (Exception e) {
@@ -708,6 +705,7 @@ public abstract class AbstractCamelContext extends ServiceSupport implements Ext
 
     @Override
     public Endpoint getEndpoint(String uri) {
+        // ensure CamelContext are initialized before we can get an endpoint
         init();
 
         StringHelper.notEmpty(uri, "uri");


[camel] 02/03: CAMEL-14288: Endpoint configurer should deal better with list types

Posted by da...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit 25a24db2136757d2ea29aac8346de15e36504913
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Wed Dec 11 06:21:53 2019 +0100

    CAMEL-14288: Endpoint configurer should deal better with list types
---
 .../org/apache/camel/support/EndpointHelper.java   |  3 ++-
 .../component/PropertyConfigurerSupport.java       | 28 ++++++++++++++++------
 2 files changed, 23 insertions(+), 8 deletions(-)

diff --git a/core/camel-support/src/main/java/org/apache/camel/support/EndpointHelper.java b/core/camel-support/src/main/java/org/apache/camel/support/EndpointHelper.java
index fd0a829..675cd85 100644
--- a/core/camel-support/src/main/java/org/apache/camel/support/EndpointHelper.java
+++ b/core/camel-support/src/main/java/org/apache/camel/support/EndpointHelper.java
@@ -245,7 +245,8 @@ public final class EndpointHelper {
      *                                  <code>mandatory</code> is <code>true</code>.
      */
     public static <T> T resolveReferenceParameter(CamelContext context, String value, Class<T> type, boolean mandatory) {
-        String valueNoHash = StringHelper.replaceAll(value, "#", "");
+        String valueNoHash = StringHelper.replaceAll(value, "#bean:", "");
+        valueNoHash = StringHelper.replaceAll(valueNoHash, "#", "");
         if (mandatory) {
             return CamelContextHelper.mandatoryLookupAndConvert(context, valueNoHash, type);
         } else {
diff --git a/core/camel-support/src/main/java/org/apache/camel/support/component/PropertyConfigurerSupport.java b/core/camel-support/src/main/java/org/apache/camel/support/component/PropertyConfigurerSupport.java
index 4cdc655..349ea15 100644
--- a/core/camel-support/src/main/java/org/apache/camel/support/component/PropertyConfigurerSupport.java
+++ b/core/camel-support/src/main/java/org/apache/camel/support/component/PropertyConfigurerSupport.java
@@ -16,8 +16,12 @@
  */
 package org.apache.camel.support.component;
 
+import java.util.Arrays;
+import java.util.List;
+
 import org.apache.camel.CamelContext;
 import org.apache.camel.NoSuchBeanException;
+import org.apache.camel.support.EndpointHelper;
 
 /**
  * Base class used by the camel-apt compiler plugin when it generates source code for fast
@@ -37,17 +41,27 @@ public abstract class PropertyConfigurerSupport {
         // if the type is not string based and the value is a bean reference, then we need to lookup
         // the bean from the registry
         if (value instanceof String && String.class != type) {
-            // is it a reference parameter
+            Object obj = null;
+
             String text = value.toString();
-            if (text.startsWith("#")) {
-                String ref = text.startsWith("#bean:") ? text.substring(6) : text.substring(1);
-                Object obj = camelContext.getRegistry().lookupByName(ref);
-                if (obj != null) {
-                    value = obj;
+            if (EndpointHelper.isReferenceParameter(text)) {
+                // special for a list where we refer to beans which can be either a list or a single element
+                // so use Object.class as type
+                if (type == List.class) {
+                    obj = EndpointHelper.resolveReferenceListParameter(camelContext, text, Object.class);
                 } else {
+                    obj = EndpointHelper.resolveReferenceParameter(camelContext, text, type);
+                }
+                if (obj == null) {
                     // no bean found so throw an exception
-                    throw new NoSuchBeanException(ref, type.getName());
+                    throw new NoSuchBeanException(text, type.getName());
                 }
+            } else if (type == List.class) {
+                // its a list but we have a string, where we support splitting via comma
+                obj = Arrays.asList(text.split(","));
+            }
+            if (obj != null) {
+                value = obj;
             }
         }