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 8b924c681bf fixes CAMEL-21582, makes CamelMicroProfilePropertiesSource
to extends LoadablePropertiesSource when using
org.eclipse.microprofile.config.ConfigProvider (#16689)
8b924c681bf is described below
commit 8b924c681bf16a225ea3d51bada4cd373548b172
Author: JiriOndrusek <[email protected]>
AuthorDate: Fri Jan 3 16:48:25 2025 +0100
fixes CAMEL-21582, makes CamelMicroProfilePropertiesSource to extends
LoadablePropertiesSource when using
org.eclipse.microprofile.config.ConfigProvider (#16689)
---
.../config/CamelMicroProfilePropertiesSource.java | 34 ++++++++++++++++++++--
1 file changed, 32 insertions(+), 2 deletions(-)
diff --git
a/components/camel-microprofile/camel-microprofile-config/src/main/java/org/apache/camel/component/microprofile/config/CamelMicroProfilePropertiesSource.java
b/components/camel-microprofile/camel-microprofile-config/src/main/java/org/apache/camel/component/microprofile/config/CamelMicroProfilePropertiesSource.java
index 3eaadc78f79..ac3df7e3f94 100644
---
a/components/camel-microprofile/camel-microprofile-config/src/main/java/org/apache/camel/component/microprofile/config/CamelMicroProfilePropertiesSource.java
+++
b/components/camel-microprofile/camel-microprofile-config/src/main/java/org/apache/camel/component/microprofile/config/CamelMicroProfilePropertiesSource.java
@@ -16,8 +16,12 @@
*/
package org.apache.camel.component.microprofile.config;
-import org.apache.camel.spi.PropertiesSource;
+import java.util.Properties;
+import java.util.function.Predicate;
+
+import org.apache.camel.spi.LoadablePropertiesSource;
import org.apache.camel.spi.annotations.JdkService;
+import org.apache.camel.util.OrderedProperties;
import org.eclipse.microprofile.config.ConfigProvider;
/**
@@ -25,7 +29,7 @@ import org.eclipse.microprofile.config.ConfigProvider;
* This allows using configuration management from MicroProfile with Camel.
*/
@JdkService("properties-source-factory")
-public class CamelMicroProfilePropertiesSource implements PropertiesSource {
+public class CamelMicroProfilePropertiesSource implements
LoadablePropertiesSource {
@Override
public String getName() {
@@ -37,6 +41,32 @@ public class CamelMicroProfilePropertiesSource implements
PropertiesSource {
return ConfigProvider.getConfig().getOptionalValue(name,
String.class).orElse(null);
}
+ @Override
+ public Properties loadProperties() {
+ return loadProperties(s -> true);
+ }
+
+ @Override
+ public Properties loadProperties(Predicate<String> filter) {
+ Properties answer = new OrderedProperties();
+
+ for (String name : ConfigProvider.getConfig().getPropertyNames()) {
+ if (filter.test(name)) {
+ var value = getProperty(name);
+ if (value != null) {
+ answer.put(name, getProperty(name));
+ }
+ }
+ }
+
+ return answer;
+ }
+
+ @Override
+ public void reloadProperties(String location) {
+ // noop
+ }
+
@Override
public String toString() {
return "camel-microprofile-config";