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-spring-boot.git


The following commit(s) were added to refs/heads/main by this push:
     new ef05798402d CAMEL-23897: Add SpringBootRuntimePropertiesProvider for 
PropertiesDevConsole (#1837)
ef05798402d is described below

commit ef05798402d08d7339699acd531c150f4e1f4944
Author: Claus Ibsen <[email protected]>
AuthorDate: Sat Jul 4 13:32:40 2026 +0200

    CAMEL-23897: Add SpringBootRuntimePropertiesProvider for 
PropertiesDevConsole (#1837)
    
    * CAMEL-23897: Add SpringBootRuntimePropertiesProvider for 
PropertiesDevConsole
    
    Co-Authored-By: Claude Opus 4.6 <[email protected]>
    Signed-off-by: Claus Ibsen <[email protected]>
    
    * CAMEL-23897: Per-property source labels (JVM/ENV/Spring Boot)
    
    Co-Authored-By: Claude Opus 4.6 <[email protected]>
    Signed-off-by: Claus Ibsen <[email protected]>
    
    ---------
    
    Signed-off-by: Claus Ibsen <[email protected]>
    Co-authored-by: Claude Opus 4.6 <[email protected]>
---
 .../camel/spring/boot/CamelAutoConfiguration.java  |  7 ++
 .../boot/SpringBootRuntimePropertiesProvider.java  | 97 ++++++++++++++++++++++
 2 files changed, 104 insertions(+)

diff --git 
a/core/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/CamelAutoConfiguration.java
 
b/core/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/CamelAutoConfiguration.java
index 047af95ba91..7dcb5965194 100644
--- 
a/core/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/CamelAutoConfiguration.java
+++ 
b/core/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/CamelAutoConfiguration.java
@@ -47,6 +47,7 @@ import org.apache.camel.spi.CliConnector;
 import org.apache.camel.spi.CliConnectorFactory;
 import org.apache.camel.spi.PackageScanClassResolver;
 import org.apache.camel.spi.PackageScanResourceResolver;
+import org.apache.camel.spi.RuntimePropertiesProvider;
 import org.apache.camel.spi.StartupConditionStrategy;
 import org.apache.camel.spi.StartupStepRecorder;
 import org.apache.camel.spi.VariableRepository;
@@ -405,6 +406,12 @@ public class CamelAutoConfiguration {
 
     // SpringCamelContext integration
 
+    @Bean
+    @ConditionalOnMissingBean(RuntimePropertiesProvider.class)
+    RuntimePropertiesProvider runtimePropertiesProvider(Environment env) {
+        return new 
SpringBootRuntimePropertiesProvider((ConfigurableEnvironment) env);
+    }
+
     @Bean
     @ConditionalOnMissingBean(PropertiesParser.class)
     PropertiesParser propertiesParser(Environment env) {
diff --git 
a/core/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/SpringBootRuntimePropertiesProvider.java
 
b/core/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/SpringBootRuntimePropertiesProvider.java
new file mode 100644
index 00000000000..c8bdf5c4ec4
--- /dev/null
+++ 
b/core/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/SpringBootRuntimePropertiesProvider.java
@@ -0,0 +1,97 @@
+/*
+ * 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.spring.boot;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.LinkedHashSet;
+import java.util.Set;
+
+import org.apache.camel.spi.RuntimePropertiesProvider;
+import org.springframework.core.env.ConfigurableEnvironment;
+import org.springframework.core.env.EnumerablePropertySource;
+
+/**
+ * {@link RuntimePropertiesProvider} that enumerates application properties 
from the Spring Boot {@link
+ * ConfigurableEnvironment}. These properties are used for display purposes 
only (e.g. the Properties dev console) and
+ * do not affect Camel's placeholder resolution.
+ * <p>
+ * Property sources that represent environment variables, JVM system 
properties, and Spring Boot internals are skipped
+ * to avoid noise — only application-level configuration is included. However, 
camel/spring/server/management keys from
+ * env/sys sources are still included since they represent application 
configuration.
+ */
+public class SpringBootRuntimePropertiesProvider implements 
RuntimePropertiesProvider {
+
+    private static final Set<String> SKIP_SOURCES = Set.of(
+            "systemProperties",
+            "systemEnvironment",
+            "configurationProperties",
+            "random");
+
+    private final ConfigurableEnvironment environment;
+
+    public SpringBootRuntimePropertiesProvider(ConfigurableEnvironment 
environment) {
+        this.environment = environment;
+    }
+
+    @Override
+    public Collection<Property> getProperties() {
+        Collection<Property> answer = new ArrayList<>();
+        Set<String> seen = new LinkedHashSet<>();
+        environment.getPropertySources().forEach(ps -> {
+            boolean skipped = SKIP_SOURCES.contains(ps.getName());
+            String source = toSourceLabel(ps.getName());
+            if (ps instanceof EnumerablePropertySource<?> eps) {
+                for (String name : eps.getPropertyNames()) {
+                    if (!seen.contains(name)) {
+                        if (skipped && !isApplicationKey(name)) {
+                            continue;
+                        }
+                        seen.add(name);
+                        try {
+                            Object value = environment.getProperty(name);
+                            answer.add(new Property(name, value, source));
+                        } catch (Exception e) {
+                            // ignore properties that cannot be resolved
+                        }
+                    }
+                }
+            }
+        });
+        return answer;
+    }
+
+    private static boolean isApplicationKey(String name) {
+        String lower = name.toLowerCase();
+        return lower.startsWith("camel.") || lower.startsWith("camel_")
+                || lower.startsWith("spring.") || lower.startsWith("spring_")
+                || lower.startsWith("server.") || lower.startsWith("server_")
+                || lower.startsWith("management.") || 
lower.startsWith("management_");
+    }
+
+    private static String toSourceLabel(String sourceName) {
+        if ("systemProperties".equals(sourceName)) {
+            return "JVM";
+        } else if ("systemEnvironment".equals(sourceName)) {
+            return "ENV";
+        } else if ("server.ports".equals(sourceName)) {
+            return "Spring Boot";
+        } else {
+            return "Spring Boot";
+        }
+    }
+}

Reply via email to