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 2024/09/04 13:34:43 UTC

(camel) branch main updated: CAMEL-21168: Add startup configuration dev console and jbang command (#15430)

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 e934d5b1ada CAMEL-21168: Add startup configuration dev console and jbang command (#15430)
e934d5b1ada is described below

commit e934d5b1adaedd5083c1c35467b742f64224a80c
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Wed Sep 4 15:34:37 2024 +0200

    CAMEL-21168: Add startup configuration dev console and jbang command (#15430)
    
    * CAMEL-21168: Add startup configuration dev console and jbang command
---
 .../apache/camel/catalog/dev-consoles.properties   |   1 +
 .../catalog/dev-consoles/main-configuration.json   |  15 ++
 .../camel/impl/console/PropertiesDevConsole.java   |  66 ++++++-
 .../camel/dev-console/main-configuration.json      |  15 ++
 .../apache/camel/dev-console/main-configuration    |   2 +
 .../org/apache/camel/dev-consoles.properties       |   7 +
 .../org/apache/camel/main/BaseMainSupport.java     |  23 ++-
 .../camel/main/MainConfigurationDevConsole.java    | 110 ++++++++++++
 .../java/org/apache/camel/main/MainHelper.java     |   8 +-
 .../camel/cli/connector/LocalCliConnector.java     |  14 ++
 .../dsl/jbang/core/commands/CamelJBangMain.java    |   1 +
 .../core/commands/process/ListProperties.java      | 192 +++++++++++++++++++++
 12 files changed, 441 insertions(+), 13 deletions(-)

diff --git a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/dev-consoles.properties b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/dev-consoles.properties
index 3c95c1b6ed1..d634e0271ec 100644
--- a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/dev-consoles.properties
+++ b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/dev-consoles.properties
@@ -19,6 +19,7 @@ java-security
 jvm
 kafka
 log
+main-configuration
 memory
 micrometer
 platform-http
diff --git a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/dev-consoles/main-configuration.json b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/dev-consoles/main-configuration.json
new file mode 100644
index 00000000000..cad6d7910c7
--- /dev/null
+++ b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/dev-consoles/main-configuration.json
@@ -0,0 +1,15 @@
+{
+  "console": {
+    "kind": "console",
+    "group": "camel",
+    "name": "main-configuration",
+    "title": "Main Configuration",
+    "description": "Display Camel startup configuration",
+    "deprecated": false,
+    "javaType": "org.apache.camel.main.MainConfigurationDevConsole",
+    "groupId": "org.apache.camel",
+    "artifactId": "camel-main",
+    "version": "4.8.0-SNAPSHOT"
+  }
+}
+
diff --git a/core/camel-console/src/main/java/org/apache/camel/impl/console/PropertiesDevConsole.java b/core/camel-console/src/main/java/org/apache/camel/impl/console/PropertiesDevConsole.java
index a539b893036..f47f9213676 100644
--- a/core/camel-console/src/main/java/org/apache/camel/impl/console/PropertiesDevConsole.java
+++ b/core/camel-console/src/main/java/org/apache/camel/impl/console/PropertiesDevConsole.java
@@ -17,12 +17,20 @@
 package org.apache.camel.impl.console;
 
 import java.util.Map;
+import java.util.Properties;
 
 import org.apache.camel.spi.PropertiesComponent;
 import org.apache.camel.spi.annotations.DevConsole;
 import org.apache.camel.support.console.AbstractDevConsole;
+import org.apache.camel.util.FileUtil;
+import org.apache.camel.util.OrderedLocationProperties;
+import org.apache.camel.util.SensitiveUtils;
+import org.apache.camel.util.StringHelper;
+import org.apache.camel.util.json.JsonArray;
 import org.apache.camel.util.json.JsonObject;
 
+import static org.apache.camel.util.LocationHelper.locationSummary;
+
 @DevConsole(name = "properties", description = "Displays the properties loaded by Camel")
 public class PropertiesDevConsole extends AbstractDevConsole {
 
@@ -38,10 +46,21 @@ public class PropertiesDevConsole extends AbstractDevConsole {
         String loc = String.join(", ", pc.getLocations());
         sb.append(String.format("Properties loaded from locations: %s", loc));
         sb.append("\n");
-        for (Map.Entry<Object, Object> entry : pc.loadProperties().entrySet()) {
-            Object k = entry.getKey();
+
+        Properties p = pc.loadProperties();
+        OrderedLocationProperties olp = null;
+        if (p instanceof OrderedLocationProperties) {
+            olp = (OrderedLocationProperties) p;
+        }
+        for (var entry : p.entrySet()) {
+            String k = entry.getKey().toString();
             Object v = entry.getValue();
-            sb.append(String.format("\n    %s = %s", k, v));
+            loc = olp != null ? locationSummary(olp, k) : null;
+            if (SensitiveUtils.containsSensitive(k)) {
+                sb.append(String.format("    %s %s = xxxxxx%n", loc, k));
+            } else {
+                sb.append(String.format("    %s %s = %s%n", loc, k, v));
+            }
         }
         sb.append("\n");
 
@@ -54,14 +73,47 @@ public class PropertiesDevConsole extends AbstractDevConsole {
 
         PropertiesComponent pc = getCamelContext().getPropertiesComponent();
         root.put("locations", pc.getLocations());
-        JsonObject props = new JsonObject();
-        root.put("properties", props);
-        for (Map.Entry<Object, Object> entry : pc.loadProperties().entrySet()) {
+
+        JsonArray arr = new JsonArray();
+        Properties p = pc.loadProperties();
+        OrderedLocationProperties olp = null;
+        if (p instanceof OrderedLocationProperties) {
+            olp = (OrderedLocationProperties) p;
+        }
+        for (var entry : p.entrySet()) {
             String k = entry.getKey().toString();
             Object v = entry.getValue();
-            props.put(k, v);
+            String loc = olp != null ? sanitizeLocation(olp.getLocation(k)) : null;
+
+            JsonObject jo = new JsonObject();
+            jo.put("key", k);
+            jo.put("value", v);
+            if (loc != null) {
+                jo.put("location", loc);
+            }
+            arr.add(jo);
+        }
+        if (!arr.isEmpty()) {
+            root.put("properties", arr);
         }
 
         return root;
     }
+
+    private static String sanitizeLocation(String loc) {
+        if (loc == null) {
+            return null;
+        }
+        // remove scheme to make it shorter
+        if (loc.contains(":")) {
+            loc = StringHelper.after(loc, ":");
+        }
+        // strip paths so location is only the name
+        loc = FileUtil.stripPath(loc);
+        if ("initial".equals(loc) || "override".equals(loc)) {
+            loc = "camel-main";
+        }
+        return loc;
+    }
+
 }
diff --git a/core/camel-main/src/generated/resources/META-INF/org/apache/camel/dev-console/main-configuration.json b/core/camel-main/src/generated/resources/META-INF/org/apache/camel/dev-console/main-configuration.json
new file mode 100644
index 00000000000..cad6d7910c7
--- /dev/null
+++ b/core/camel-main/src/generated/resources/META-INF/org/apache/camel/dev-console/main-configuration.json
@@ -0,0 +1,15 @@
+{
+  "console": {
+    "kind": "console",
+    "group": "camel",
+    "name": "main-configuration",
+    "title": "Main Configuration",
+    "description": "Display Camel startup configuration",
+    "deprecated": false,
+    "javaType": "org.apache.camel.main.MainConfigurationDevConsole",
+    "groupId": "org.apache.camel",
+    "artifactId": "camel-main",
+    "version": "4.8.0-SNAPSHOT"
+  }
+}
+
diff --git a/core/camel-main/src/generated/resources/META-INF/services/org/apache/camel/dev-console/main-configuration b/core/camel-main/src/generated/resources/META-INF/services/org/apache/camel/dev-console/main-configuration
new file mode 100644
index 00000000000..b7b011a85e5
--- /dev/null
+++ b/core/camel-main/src/generated/resources/META-INF/services/org/apache/camel/dev-console/main-configuration
@@ -0,0 +1,2 @@
+# Generated by camel build tools - do NOT edit this file!
+class=org.apache.camel.main.MainConfigurationDevConsole
diff --git a/core/camel-main/src/generated/resources/META-INF/services/org/apache/camel/dev-consoles.properties b/core/camel-main/src/generated/resources/META-INF/services/org/apache/camel/dev-consoles.properties
new file mode 100644
index 00000000000..ea5f8255a50
--- /dev/null
+++ b/core/camel-main/src/generated/resources/META-INF/services/org/apache/camel/dev-consoles.properties
@@ -0,0 +1,7 @@
+# Generated by camel build tools - do NOT edit this file!
+dev-consoles=main-configuration
+groupId=org.apache.camel
+artifactId=camel-main
+version=4.8.0-SNAPSHOT
+projectName=Camel :: Main
+projectDescription=Camel Main
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 e80b9e5ab0e..140f00b6026 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
@@ -552,6 +552,15 @@ public abstract class BaseMainSupport extends BaseService {
             camelContext.addService(new MainPropertiesReload(this));
         }
 
+        // capture startup configuration
+        DevConsoleRegistry dcr = camelContext.getCamelContextExtension().getContextPlugin(DevConsoleRegistry.class);
+        if (dcr != null) {
+            MainConfigurationDevConsole mc = (MainConfigurationDevConsole) dcr.resolveById("main-configuration");
+            if (mc != null) {
+                mc.addStartupConfiguration(autoConfiguredProperties);
+            }
+        }
+
         // log summary of configurations
         if (mainConfigurationProperties.isAutoConfigurationLogSummary() && !autoConfiguredProperties.isEmpty()) {
             logConfigurationSummary(autoConfiguredProperties);
@@ -2316,12 +2325,22 @@ public abstract class BaseMainSupport extends BaseService {
             }
             // log summary of configurations
             if (mainConfigurationProperties.isAutoConfigurationLogSummary() && !autoConfiguredProperties.isEmpty()) {
+                MainConfigurationDevConsole mc = null;
+                DevConsoleRegistry dcr = camelContext.getCamelContextExtension().getContextPlugin(DevConsoleRegistry.class);
+                if (dcr != null) {
+                    mc = (MainConfigurationDevConsole) dcr.resolveById("main-configuration");
+                }
                 boolean header = false;
                 for (var entry : autoConfiguredProperties.entrySet()) {
                     String k = entry.getKey().toString();
                     Object v = entry.getValue();
                     String loc = locationSummary(autoConfiguredProperties, k);
 
+                    if (mc != null) {
+                        // also capture autowired configuration
+                        mc.addStartupConfiguration(loc, k, v);
+                    }
+
                     // tone down logging noise for our own internal configurations
                     boolean debug = loc.contains("[camel-main]");
                     if (debug && !LOG.isDebugEnabled()) {
@@ -2444,9 +2463,9 @@ public abstract class BaseMainSupport extends BaseService {
                         }
                         String loc = locationSummary(propertyPlaceholders, k);
                         if (SensitiveUtils.containsSensitive(k)) {
-                            LOG.info("    {} {}=xxxxxx", loc, k);
+                            LOG.info("    {} {} = xxxxxx", loc, k);
                         } else {
-                            LOG.info("    {} {}={}", loc, k, v);
+                            LOG.info("    {} {} = {}", loc, k, v);
                         }
                     }
                 }
diff --git a/core/camel-main/src/main/java/org/apache/camel/main/MainConfigurationDevConsole.java b/core/camel-main/src/main/java/org/apache/camel/main/MainConfigurationDevConsole.java
new file mode 100644
index 00000000000..47863fc98a0
--- /dev/null
+++ b/core/camel-main/src/main/java/org/apache/camel/main/MainConfigurationDevConsole.java
@@ -0,0 +1,110 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.main;
+
+import java.util.Map;
+
+import org.apache.camel.spi.annotations.DevConsole;
+import org.apache.camel.support.console.AbstractDevConsole;
+import org.apache.camel.util.FileUtil;
+import org.apache.camel.util.OrderedLocationProperties;
+import org.apache.camel.util.SensitiveUtils;
+import org.apache.camel.util.StringHelper;
+import org.apache.camel.util.json.JsonArray;
+import org.apache.camel.util.json.JsonObject;
+
+import static org.apache.camel.util.LocationHelper.locationSummary;
+
+@DevConsole(name = "main-configuration", displayName = "Main Configuration",
+            description = "Display Camel startup configuration")
+public class MainConfigurationDevConsole extends AbstractDevConsole {
+
+    private final OrderedLocationProperties startupConfiguration = new OrderedLocationProperties();
+
+    public MainConfigurationDevConsole() {
+        super("camel", "main-configuration", "Main Configuration", "Display Camel startup configuration");
+    }
+
+    public void addStartupConfiguration(OrderedLocationProperties startupConfiguration) {
+        this.startupConfiguration.putAll(startupConfiguration);
+    }
+
+    public void addStartupConfiguration(String loc, Object key, Object value) {
+        startupConfiguration.put(loc, key, value);
+    }
+
+    @Override
+    protected String doCallText(Map<String, Object> options) {
+        StringBuilder sb = new StringBuilder();
+
+        if (!startupConfiguration.isEmpty()) {
+            sb.append("Camel Main Configuration:\n");
+            for (var entry : startupConfiguration.entrySet()) {
+                String k = entry.getKey().toString();
+                Object v = entry.getValue();
+                String loc = locationSummary(startupConfiguration, k);
+                if (SensitiveUtils.containsSensitive(k)) {
+                    sb.append(String.format("    %s %s = xxxxxx%n", loc, k));
+                } else {
+                    sb.append(String.format("    %s %s = %s%n", loc, k, v));
+                }
+            }
+        }
+
+        return sb.toString();
+    }
+
+    @Override
+    protected Map<String, Object> doCallJson(Map<String, Object> options) {
+        JsonObject root = new JsonObject();
+        if (!startupConfiguration.isEmpty()) {
+            JsonArray arr = new JsonArray();
+            for (var entry : startupConfiguration.entrySet()) {
+                String k = entry.getKey().toString();
+                Object v = entry.getValue();
+                String loc = sanitizeLocation(startupConfiguration.getLocation(k));
+
+                JsonObject jo = new JsonObject();
+                jo.put("key", k);
+                jo.put("value", v);
+                if (loc != null) {
+                    jo.put("location", loc);
+                }
+                arr.add(jo);
+            }
+            root.put("configurations", arr);
+        }
+
+        return root;
+    }
+
+    private static String sanitizeLocation(String loc) {
+        if (loc == null) {
+            return null;
+        }
+        // remove scheme to make it shorter
+        if (loc.contains(":")) {
+            loc = StringHelper.after(loc, ":");
+        }
+        // strip paths so location is only the name
+        loc = FileUtil.stripPath(loc);
+        if ("initial".equals(loc) || "override".equals(loc)) {
+            loc = "camel-main";
+        }
+        return loc;
+    }
+}
diff --git a/core/camel-main/src/main/java/org/apache/camel/main/MainHelper.java b/core/camel-main/src/main/java/org/apache/camel/main/MainHelper.java
index 2eef2577a6b..c4647e982c2 100644
--- a/core/camel-main/src/main/java/org/apache/camel/main/MainHelper.java
+++ b/core/camel-main/src/main/java/org/apache/camel/main/MainHelper.java
@@ -596,15 +596,15 @@ public final class MainHelper {
         }
         if (SensitiveUtils.containsSensitive(k)) {
             if (debug) {
-                log.debug("    {} {}=xxxxxx", loc, k);
+                log.debug("    {} {} = xxxxxx", loc, k);
             } else {
-                log.info("    {} {}=xxxxxx", loc, k);
+                log.info("    {} {} = xxxxxx", loc, k);
             }
         } else {
             if (debug) {
-                log.debug("    {} {}={}", loc, k, v);
+                log.debug("    {} {} = {}", loc, k, v);
             } else {
-                log.info("    {} {}={}", loc, k, v);
+                log.info("    {} {} = {}", loc, k, v);
             }
         }
     }
diff --git a/dsl/camel-cli-connector/src/main/java/org/apache/camel/cli/connector/LocalCliConnector.java b/dsl/camel-cli-connector/src/main/java/org/apache/camel/cli/connector/LocalCliConnector.java
index 31b30118cd8..1efcede4b85 100644
--- a/dsl/camel-cli-connector/src/main/java/org/apache/camel/cli/connector/LocalCliConnector.java
+++ b/dsl/camel-cli-connector/src/main/java/org/apache/camel/cli/connector/LocalCliConnector.java
@@ -1060,6 +1060,20 @@ public class LocalCliConnector extends ServiceSupport implements CliConnector, C
                         root.put("kafka", json);
                     }
                 }
+                DevConsole dc21 = dcr.resolveById("properties");
+                if (dc21 != null) {
+                    JsonObject json = (JsonObject) dc21.call(DevConsole.MediaType.JSON);
+                    if (json != null && !json.isEmpty()) {
+                        root.put("properties", json);
+                    }
+                }
+                DevConsole dc22 = dcr.resolveById("main-configuration");
+                if (dc22 != null) {
+                    JsonObject json = (JsonObject) dc22.call(DevConsole.MediaType.JSON);
+                    if (json != null && !json.isEmpty()) {
+                        root.put("main-configuration", json);
+                    }
+                }
             }
             // various details
             JsonObject mem = collectMemory();
diff --git a/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/CamelJBangMain.java b/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/CamelJBangMain.java
index 32346bf5032..c7627b3897a 100644
--- a/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/CamelJBangMain.java
+++ b/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/CamelJBangMain.java
@@ -89,6 +89,7 @@ public class CamelJBangMain implements Callable<Integer> {
                         .addSubcommand("processor", new CommandLine(new CamelProcessorStatus(main)))
                         .addSubcommand("count", new CommandLine(new CamelCount(main)))
                         .addSubcommand("health", new CommandLine(new ListHealth(main)))
+                        .addSubcommand("properties", new CommandLine(new ListProperties(main)))
                         .addSubcommand("variable", new CommandLine(new ListVariable(main)))
                         .addSubcommand("consumer", new CommandLine(new ListConsumer(main)))
                         .addSubcommand("endpoint", new CommandLine(new ListEndpoint(main)))
diff --git a/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/process/ListProperties.java b/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/process/ListProperties.java
new file mode 100644
index 00000000000..fd01f20e215
--- /dev/null
+++ b/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/process/ListProperties.java
@@ -0,0 +1,192 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.dsl.jbang.core.commands.process;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Iterator;
+import java.util.List;
+
+import com.github.freva.asciitable.AsciiTable;
+import com.github.freva.asciitable.Column;
+import com.github.freva.asciitable.HorizontalAlign;
+import com.github.freva.asciitable.OverflowBehaviour;
+import org.apache.camel.dsl.jbang.core.commands.CamelJBangMain;
+import org.apache.camel.dsl.jbang.core.common.ProcessHelper;
+import org.apache.camel.util.SensitiveUtils;
+import org.apache.camel.util.json.JsonArray;
+import org.apache.camel.util.json.JsonObject;
+import picocli.CommandLine;
+import picocli.CommandLine.Command;
+
+@Command(name = "properties", description = "List configuration properties", sortOptions = false)
+public class ListProperties extends ProcessWatchCommand {
+
+    public static class PidNameKeyCompletionCandidates implements Iterable<String> {
+
+        public PidNameKeyCompletionCandidates() {
+        }
+
+        @Override
+        public Iterator<String> iterator() {
+            return List.of("pid", "name", "key").iterator();
+        }
+
+    }
+
+    @CommandLine.Parameters(description = "Name or pid of running Camel integration", arity = "0..1")
+    String name = "*";
+
+    @CommandLine.Option(names = { "--sort" }, completionCandidates = PidNameKeyCompletionCandidates.class,
+                        description = "Sort by pid, name or key", defaultValue = "pid")
+    String sort;
+
+    @CommandLine.Option(names = { "--startup" }, description = "List only startup configuration")
+    boolean startup;
+
+    @CommandLine.Option(names = { "--internal" }, description = "Whether to include internal configuration")
+    boolean internal;
+
+    @CommandLine.Option(names = { "--mask" },
+                        description = "Whether to mask configuration values to avoid printing sensitive information such as password or access keys",
+                        defaultValue = "true")
+    boolean mask = true;
+
+    public ListProperties(CamelJBangMain main) {
+        super(main);
+    }
+
+    @Override
+    public Integer doProcessWatchCall() throws Exception {
+        List<Row> rows = new ArrayList<>();
+
+        List<Long> pids = findPids(name);
+        ProcessHandle.allProcesses()
+                .filter(ph -> pids.contains(ph.pid()))
+                .forEach(ph -> {
+                    JsonObject root = loadStatus(ph.pid());
+                    // there must be a status file for the running Camel integration
+                    if (root != null) {
+                        Row row = new Row();
+                        JsonObject context = (JsonObject) root.get("context");
+                        if (context == null) {
+                            return;
+                        }
+                        row.name = context.getString("name");
+                        if ("CamelJBang".equals(row.name)) {
+                            row.name = ProcessHelper.extractName(root, ph);
+                        }
+                        row.pid = Long.toString(ph.pid());
+
+                        JsonArray arr;
+                        if (startup) {
+                            JsonObject jv = (JsonObject) root.get("main-configuration");
+                            arr = jv.getCollectionOrDefault("configurations", null);
+                        } else {
+                            JsonObject jv = (JsonObject) root.get("properties");
+                            arr = jv.getCollectionOrDefault("properties", null);
+                        }
+                        for (int i = 0; arr != null && i < arr.size(); i++) {
+                            row = row.copy();
+                            JsonObject jo = (JsonObject) arr.get(i);
+                            row.key = jo.getString("key");
+                            String value = jo.getString("value");
+                            if (mask && SensitiveUtils.containsSensitive(row.key)) {
+                                value = "xxxxxx";
+                            }
+                            row.value = value;
+                            row.loc = sanitizeLocation(jo.getString("location"));
+                            // location camel-main means that it is an internal configuration
+                            boolean accept = internal || !row.loc.equals("camel-main");
+                            if (accept) {
+                                rows.add(row);
+                            }
+                        }
+                    }
+                });
+
+        // sort rows
+        rows.sort(this::sortRow);
+
+        if (!rows.isEmpty()) {
+            printer().println(AsciiTable.getTable(AsciiTable.NO_BORDERS, rows, Arrays.asList(
+                    new Column().header("PID").headerAlign(HorizontalAlign.CENTER).with(r -> r.pid),
+                    new Column().header("NAME").dataAlign(HorizontalAlign.LEFT).maxWidth(30, OverflowBehaviour.ELLIPSIS_RIGHT)
+                            .with(r -> r.name),
+                    new Column().header("LOCATION").dataAlign(HorizontalAlign.LEFT).maxWidth(80, OverflowBehaviour.NEWLINE)
+                            .with(r -> r.loc),
+                    new Column().header("KEY").dataAlign(HorizontalAlign.LEFT).maxWidth(50, OverflowBehaviour.ELLIPSIS_RIGHT)
+                            .with(r -> r.key),
+                    new Column().header("VALUE").dataAlign(HorizontalAlign.LEFT).maxWidth(80, OverflowBehaviour.NEWLINE)
+                            .with(r -> "" + r.value))));
+        }
+
+        return 0;
+    }
+
+    protected int sortRow(Row o1, Row o2) {
+        String s = sort;
+        int negate = 1;
+        if (s.startsWith("-")) {
+            s = s.substring(1);
+            negate = -1;
+        }
+        switch (s) {
+            case "pid":
+                return Long.compare(Long.parseLong(o1.pid), Long.parseLong(o2.pid)) * negate;
+            case "name":
+                return o1.name.compareToIgnoreCase(o2.name) * negate;
+            case "key":
+                return o1.key.compareToIgnoreCase(o2.key) * negate;
+            default:
+                return 0;
+        }
+    }
+
+    private static class Row implements Cloneable {
+        String pid;
+        String name;
+        String key;
+        Object value;
+        String loc;
+
+        Row copy() {
+            try {
+                return (Row) clone();
+            } catch (CloneNotSupportedException e) {
+                return null;
+            }
+        }
+    }
+
+    private static String sanitizeLocation(String loc) {
+        if (loc == null) {
+            return "";
+        }
+        if ("initial".equals(loc) || "override".equals(loc)) {
+            loc = "camel-main";
+        } else if ("SYS".equals(loc)) {
+            loc = "JVM System Property";
+        } else if ("ENV".equals(loc)) {
+            loc = "OS Environment Variable";
+        } else if ("arguments".equals(loc) || "CLI".equals(loc)) {
+            loc = "Command Line";
+        }
+        return loc;
+    }
+
+}