From f83f18d7fbcdf8f201f652e9b3f2d38e1d6c3ef2 Mon Sep 17 00:00:00 2001 From: Claus Ibsen Date: Sat, 4 Jul 2026 10:20:55 +0200 Subject: [PATCH 1/2] CAMEL-23897: Add SpringBootRuntimePropertiesProvider for PropertiesDevConsole Co-Authored-By: Claude Opus 4.6 Signed-off-by: Claus Ibsen --- .../spring/boot/CamelAutoConfiguration.java | 7 ++ .../SpringBootRuntimePropertiesProvider.java | 75 +++++++++++++++++++ 2 files changed, 82 insertions(+) create mode 100644 core/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/SpringBootRuntimePropertiesProvider.java 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.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 @@ ConsumerTemplate consumerTemplate(CamelContext camelContext, CamelConfigurationP // 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..8bacf99eead --- /dev/null +++ b/core/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/SpringBootRuntimePropertiesProvider.java @@ -0,0 +1,75 @@ +/* + * 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.LinkedHashMap; +import java.util.Map; +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. + *

+ * Property sources that represent environment variables, JVM system properties, and Spring Boot internals are skipped + * to avoid noise — only application-level configuration is included. + */ +public class SpringBootRuntimePropertiesProvider implements RuntimePropertiesProvider { + + private static final Set SKIP_SOURCES = Set.of( + "systemProperties", + "systemEnvironment", + "configurationProperties", + "random"); + + private final ConfigurableEnvironment environment; + + public SpringBootRuntimePropertiesProvider(ConfigurableEnvironment environment) { + this.environment = environment; + } + + @Override + public String getSource() { + return "Spring Boot"; + } + + @Override + public Map getProperties() { + Map answer = new LinkedHashMap<>(); + environment.getPropertySources().forEach(ps -> { + if (SKIP_SOURCES.contains(ps.getName())) { + return; + } + if (ps instanceof EnumerablePropertySource eps) { + for (String name : eps.getPropertyNames()) { + if (!answer.containsKey(name)) { + try { + answer.put(name, environment.getProperty(name)); + } catch (Exception e) { + // ignore properties that cannot be resolved + } + } + } + } + }); + return answer; + } +} From 27643e817aec25f41791a54a2564997978c00920 Mon Sep 17 00:00:00 2001 From: Claus Ibsen Date: Sat, 4 Jul 2026 10:29:53 +0200 Subject: [PATCH 2/2] CAMEL-23897: Per-property source labels (JVM/ENV/Spring Boot) Co-Authored-By: Claude Opus 4.6 Signed-off-by: Claus Ibsen --- .../SpringBootRuntimePropertiesProvider.java | 52 +++++++++++++------ 1 file changed, 37 insertions(+), 15 deletions(-) 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 index 8bacf99eead..c8bdf5c4ec4 100644 --- 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 @@ -16,8 +16,9 @@ */ package org.apache.camel.spring.boot; -import java.util.LinkedHashMap; -import java.util.Map; +import java.util.ArrayList; +import java.util.Collection; +import java.util.LinkedHashSet; import java.util.Set; import org.apache.camel.spi.RuntimePropertiesProvider; @@ -30,7 +31,8 @@ * do not affect Camel's placeholder resolution. *

* Property sources that represent environment variables, JVM system properties, and Spring Boot internals are skipped - * to avoid noise — only application-level configuration is included. + * 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 { @@ -47,22 +49,22 @@ public SpringBootRuntimePropertiesProvider(ConfigurableEnvironment environment) } @Override - public String getSource() { - return "Spring Boot"; - } - - @Override - public Map getProperties() { - Map answer = new LinkedHashMap<>(); + public Collection getProperties() { + Collection answer = new ArrayList<>(); + Set seen = new LinkedHashSet<>(); environment.getPropertySources().forEach(ps -> { - if (SKIP_SOURCES.contains(ps.getName())) { - return; - } + boolean skipped = SKIP_SOURCES.contains(ps.getName()); + String source = toSourceLabel(ps.getName()); if (ps instanceof EnumerablePropertySource eps) { for (String name : eps.getPropertyNames()) { - if (!answer.containsKey(name)) { + if (!seen.contains(name)) { + if (skipped && !isApplicationKey(name)) { + continue; + } + seen.add(name); try { - answer.put(name, environment.getProperty(name)); + Object value = environment.getProperty(name); + answer.add(new Property(name, value, source)); } catch (Exception e) { // ignore properties that cannot be resolved } @@ -72,4 +74,24 @@ public Map getProperties() { }); 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"; + } + } }