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:47:18 UTC
(camel) branch main updated: CAMEL-21168: Add startup configuration dev console and jbang command
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 560a5074f9a CAMEL-21168: Add startup configuration dev console and jbang command
560a5074f9a is described below
commit 560a5074f9a15fbf9027dc46e85dbaa87bd08f67
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Wed Sep 4 15:46:18 2024 +0200
CAMEL-21168: Add startup configuration dev console and jbang command
---
.../camel/impl/console/PropertiesDevConsole.java | 20 +++++---------------
.../camel/main/MainConfigurationDevConsole.java | 21 ++++++---------------
.../jbang/core/commands/process/ListProperties.java | 5 +++--
3 files changed, 14 insertions(+), 32 deletions(-)
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 f47f9213676..9b0884b3e67 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
@@ -22,10 +22,8 @@ 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;
@@ -83,13 +81,14 @@ public class PropertiesDevConsole extends AbstractDevConsole {
for (var entry : p.entrySet()) {
String k = entry.getKey().toString();
Object v = entry.getValue();
- String loc = olp != null ? sanitizeLocation(olp.getLocation(k)) : null;
+ String loc = olp != null ? olp.getLocation(k) : null;
JsonObject jo = new JsonObject();
jo.put("key", k);
jo.put("value", v);
if (loc != null) {
jo.put("location", loc);
+ jo.put("internal", isInternal(loc));
}
arr.add(jo);
}
@@ -100,20 +99,11 @@ public class PropertiesDevConsole extends AbstractDevConsole {
return root;
}
- private static String sanitizeLocation(String loc) {
+ private static boolean isInternal(String loc) {
if (loc == null) {
- return null;
+ return false;
}
- // 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;
+ return "initial".equals(loc) || "override".equals(loc);
}
}
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
index 47863fc98a0..e1a7dce07d7 100644
--- 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
@@ -20,10 +20,8 @@ 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;
@@ -76,13 +74,14 @@ public class MainConfigurationDevConsole extends AbstractDevConsole {
for (var entry : startupConfiguration.entrySet()) {
String k = entry.getKey().toString();
Object v = entry.getValue();
- String loc = sanitizeLocation(startupConfiguration.getLocation(k));
+ String loc = startupConfiguration.getLocation(k);
JsonObject jo = new JsonObject();
jo.put("key", k);
jo.put("value", v);
if (loc != null) {
jo.put("location", loc);
+ jo.put("internal", isInternal(loc));
}
arr.add(jo);
}
@@ -92,19 +91,11 @@ public class MainConfigurationDevConsole extends AbstractDevConsole {
return root;
}
- private static String sanitizeLocation(String loc) {
+ private static boolean isInternal(String loc) {
if (loc == null) {
- return null;
+ return false;
}
- // 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;
+ return "initial".equals(loc) || "override".equals(loc);
}
+
}
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
index fd01f20e215..3da48a218bf 100644
--- 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
@@ -109,9 +109,9 @@ public class ListProperties extends ProcessWatchCommand {
value = "xxxxxx";
}
row.value = value;
+ row.internalLoc = jo.getBooleanOrDefault("internal", false);
row.loc = sanitizeLocation(jo.getString("location"));
- // location camel-main means that it is an internal configuration
- boolean accept = internal || !row.loc.equals("camel-main");
+ boolean accept = internal || !row.internalLoc;
if (accept) {
rows.add(row);
}
@@ -163,6 +163,7 @@ public class ListProperties extends ProcessWatchCommand {
String key;
Object value;
String loc;
+ boolean internalLoc;
Row copy() {
try {