This is an automated email from the ASF dual-hosted git repository. davsclaus pushed a commit to branch feature/CAMEL-23897-runtime-properties-provider in repository https://gitbox.apache.org/repos/asf/camel-spring-boot.git
commit f83f18d7fbcdf8f201f652e9b3f2d38e1d6c3ef2 Author: Claus Ibsen <[email protected]> AuthorDate: Sat Jul 4 10:20:55 2026 +0200 CAMEL-23897: Add SpringBootRuntimePropertiesProvider for PropertiesDevConsole Co-Authored-By: Claude Opus 4.6 <[email protected]> Signed-off-by: Claus Ibsen <[email protected]> --- .../camel/spring/boot/CamelAutoConfiguration.java | 7 ++ .../boot/SpringBootRuntimePropertiesProvider.java | 75 ++++++++++++++++++++++ 2 files changed, 82 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..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. + * <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. + */ +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 String getSource() { + return "Spring Boot"; + } + + @Override + public Map<String, Object> getProperties() { + Map<String, Object> 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; + } +}
