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 2020/10/14 06:20:17 UTC

[camel] branch master updated: CAMEL-15622: Prefer bean instance in endpoint DSL. Do not search in registry using wrong string representation of a bean, return the bean directly instead

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


The following commit(s) were added to refs/heads/master by this push:
     new 615fe60  CAMEL-15622: Prefer bean instance in endpoint DSL. Do not search in registry using wrong string representation of a bean, return the bean directly instead
615fe60 is described below

commit 615fe603124a2722e1a8d4d3e13539d35fefe496
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Wed Oct 14 07:38:22 2020 +0200

    CAMEL-15622: Prefer bean instance in endpoint DSL. Do not search in registry using wrong string representation of a bean, return the bean directly instead
---
 .../org/apache/camel/support/DefaultComponent.java    | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)

diff --git a/core/camel-support/src/main/java/org/apache/camel/support/DefaultComponent.java b/core/camel-support/src/main/java/org/apache/camel/support/DefaultComponent.java
index bd73c59..e950c45 100644
--- a/core/camel-support/src/main/java/org/apache/camel/support/DefaultComponent.java
+++ b/core/camel-support/src/main/java/org/apache/camel/support/DefaultComponent.java
@@ -516,6 +516,12 @@ public abstract class DefaultComponent extends ServiceSupport implements Compone
             Map<String, Object> parameters, String key, Class<T> type, T defaultValue) {
         // the parameter may be the the type already (such as from endpoint-dsl)
         Object value = parameters.remove(key);
+        if (value instanceof String) {
+            String str = (String) value;
+            if (EndpointHelper.isReferenceParameter(str)) {
+                return EndpointHelper.resolveReferenceParameter(getCamelContext(), str, type);
+            }
+        }
         if (type.isInstance(value)) {
             // special for string references
             if (String.class == type) {
@@ -567,7 +573,20 @@ public abstract class DefaultComponent extends ServiceSupport implements Compone
     public <T> T resolveAndRemoveReferenceParameter(Map<String, Object> parameters, String key, Class<T> type, T defaultValue) {
         // the parameter may be the the type already (such as from endpoint-dsl)
         Object value = parameters.remove(key);
+        if (value instanceof String) {
+            String str = (String) value;
+            if (EndpointHelper.isReferenceParameter(str)) {
+                return EndpointHelper.resolveReferenceParameter(getCamelContext(), str, type);
+            }
+        }
         if (type.isInstance(value)) {
+            // special for string references
+            if (String.class == type) {
+                String str = value.toString();
+                if (EndpointHelper.isReferenceParameter(str)) {
+                    value = EndpointHelper.resolveReferenceParameter(getCamelContext(), str, type);
+                }
+            }
             return type.cast(value);
         } else if (value == null) {
             return defaultValue;