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

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

commit 1c6d9e3d9cbd6b47443e85ff9870f4769fc225e7
Author: Claus Ibsen <[email protected]>
AuthorDate: Mon Mar 21 17:19:26 2022 +0100

    CAMEL-17831: camel-main - Auto configuration summary (show from where the 
option was taken)
---
 .../org/apache/camel/main/BaseMainSupport.java     | 57 ++++++++++++----------
 1 file changed, 30 insertions(+), 27 deletions(-)

diff --git 
a/core/camel-main/src/main/java/org/apache/camel/main/BaseMainSupport.java 
b/core/camel-main/src/main/java/org/apache/camel/main/BaseMainSupport.java
index 8c45d14..cb008f0 100644
--- a/core/camel-main/src/main/java/org/apache/camel/main/BaseMainSupport.java
+++ b/core/camel-main/src/main/java/org/apache/camel/main/BaseMainSupport.java
@@ -408,25 +408,11 @@ public abstract class BaseMainSupport extends BaseService 
{
         if (mainConfigurationProperties.isAutoConfigurationLogSummary() && 
!autoConfiguredProperties.isEmpty()) {
             LOG.info("Auto-configuration summary");
             for (var entry : autoConfiguredProperties.entrySet()) {
-                Object k = entry.getKey();
+                String k = entry.getKey().toString();
                 Object v = entry.getValue();
+                String loc = locationSummary(autoConfiguredProperties, k);
 
-                String loc = autoConfiguredProperties.getLocation(k);
-                if (loc == null) {
-                    loc = "";
-                }
-                // remove scheme to make it shorter
-                if (loc.contains(":")) {
-                    loc = StringHelper.after(loc, ":");
-                }
-                if (loc.length() > 28) {
-                    int pos = loc.length() - 28;
-                    loc = loc.substring(pos);
-                }
-                loc = "[" + loc + "]";
-                loc = String.format("%-30s", loc);
-
-                if (SensitiveUtils.containsSensitive(k.toString())) {
+                if (SensitiveUtils.containsSensitive(k)) {
                     LOG.info("    {} {}=xxxxxx", loc, k);
                 } else {
                     LOG.info("    {} {}={}", loc, k, v);
@@ -1093,8 +1079,6 @@ public abstract class BaseMainSupport extends BaseService 
{
 
         // and call after all properties are set
         DefaultConfigurationConfigurer.afterPropertiesSet(camelContext);
-
-        // TODO: record for each used configuration its source
     }
 
     private void setRouteTemplateProperties(
@@ -1541,8 +1525,6 @@ public abstract class BaseMainSupport extends BaseService 
{
                 });
             }
         }
-
-        // TODO: summary of location
     }
 
     protected void autowireWildcardProperties(CamelContext camelContext) {
@@ -1592,14 +1574,17 @@ public abstract class BaseMainSupport extends 
BaseService {
             // log summary of configurations
             if (mainConfigurationProperties.isAutoConfigurationLogSummary() && 
!autoConfiguredProperties.isEmpty()) {
                 LOG.info("Auto-configuration component {} summary", name);
-                autoConfiguredProperties.forEach((k, v) -> {
-                    // TOOD: summary
-                    if (SensitiveUtils.containsSensitive(k.toString())) {
-                        LOG.info("    {}=xxxxxx", k);
+                for (var entry : autoConfiguredProperties.entrySet()) {
+                    String k = entry.getKey().toString();
+                    Object v = entry.getValue();
+                    String loc = locationSummary(autoConfiguredProperties, k);
+
+                    if (SensitiveUtils.containsSensitive(k)) {
+                        LOG.info("    {} {}=xxxxxx", loc, k);
                     } else {
-                        LOG.info("    {}={}", k, v);
+                        LOG.info("    {} {}={}", loc, k, v);
                     }
-                });
+                }
             }
         } catch (Exception e) {
             throw RuntimeCamelException.wrapRuntimeException(e);
@@ -1621,4 +1606,22 @@ public abstract class BaseMainSupport extends 
BaseService {
         return answer;
     }
 
+    private static String locationSummary(OrderedLocationProperties 
autoConfiguredProperties, String key) {
+        String loc = autoConfiguredProperties.getLocation(key);
+        if (loc == null) {
+            loc = "";
+        }
+        // remove scheme to make it shorter
+        if (loc.contains(":")) {
+            loc = StringHelper.after(loc, ":");
+        }
+        if (loc.length() > 28) {
+            int pos = loc.length() - 28;
+            loc = loc.substring(pos);
+        }
+        loc = "[" + loc + "]";
+        loc = String.format("%-30s", loc);
+        return loc;
+    }
+
 }

Reply via email to