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

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


The following commit(s) were added to refs/heads/main by this push:
     new 975c6dfc07f CAMEL-19772: camel-core - Dump routes to include custom 
beans
975c6dfc07f is described below

commit 975c6dfc07fb2bfdd91ca0e99964dc3e704eb35f
Author: Claus Ibsen <claus.ib...@gmail.com>
AuthorDate: Mon Aug 28 13:12:58 2023 +0200

    CAMEL-19772: camel-core - Dump routes to include custom beans
---
 .../main/java/org/apache/camel/main/KameletMain.java   | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

diff --git 
a/dsl/camel-kamelet-main/src/main/java/org/apache/camel/main/KameletMain.java 
b/dsl/camel-kamelet-main/src/main/java/org/apache/camel/main/KameletMain.java
index 2071bd54077..7addb94edac 100644
--- 
a/dsl/camel-kamelet-main/src/main/java/org/apache/camel/main/KameletMain.java
+++ 
b/dsl/camel-kamelet-main/src/main/java/org/apache/camel/main/KameletMain.java
@@ -29,6 +29,7 @@ import java.util.List;
 import java.util.Map;
 import java.util.Objects;
 import java.util.Set;
+import java.util.StringJoiner;
 import java.util.TreeMap;
 import java.util.function.Supplier;
 
@@ -98,6 +99,7 @@ import org.springframework.beans.factory.SmartFactoryBean;
 import org.springframework.beans.factory.SmartInitializingSingleton;
 import org.springframework.beans.factory.config.BeanDefinition;
 import org.springframework.beans.factory.config.BeanReference;
+import org.springframework.beans.factory.config.ConstructorArgumentValues;
 import org.springframework.beans.factory.config.TypedStringValue;
 import org.springframework.beans.factory.support.AbstractBeanDefinition;
 import org.springframework.beans.factory.support.DefaultListableBeanFactory;
@@ -838,6 +840,22 @@ public class KameletMain extends MainCommandLineSupport {
                 rrd.setType(def.getBeanClassName());
                 rrd.setName(name);
                 model.addRegistryBean(rrd);
+
+                // constructor arguments
+                ConstructorArgumentValues ctr = 
def.getConstructorArgumentValues();
+                StringJoiner sj = new StringJoiner(", ");
+                for (ConstructorArgumentValues.ValueHolder v : 
ctr.getIndexedArgumentValues().values()) {
+                    Object val = v.getValue();
+                    if (val instanceof TypedStringValue tsv) {
+                        sj.add("'" + tsv.getValue() + "'");
+                    } else if (val instanceof BeanReference br) {
+                        sj.add("'#bean:" + br.getBeanName() + "'");
+                    }
+                }
+                if (sj.length() > 0) {
+                    rrd.setType("#class:" + def.getBeanClassName() + "(" + sj 
+ ")");
+                }
+                // property values
                 if (def.hasPropertyValues()) {
                     Map<String, Object> properties = new LinkedHashMap<>();
                     rrd.setProperties(properties);

Reply via email to