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 2022/04/14 16:13:21 UTC
[camel] branch main updated: CAMEL-17969: camel-main - Property-placeholder summary
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 549f94a65d0 CAMEL-17969: camel-main - Property-placeholder summary
549f94a65d0 is described below
commit 549f94a65d064f72a8ff099a4125bc5760cde7db
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Thu Apr 14 18:13:07 2022 +0200
CAMEL-17969: camel-main - Property-placeholder summary
---
.../apache/camel/main/MainCommandLineSupport.java | 28 ++++++++++++++++++++--
1 file changed, 26 insertions(+), 2 deletions(-)
diff --git a/core/camel-main/src/main/java/org/apache/camel/main/MainCommandLineSupport.java b/core/camel-main/src/main/java/org/apache/camel/main/MainCommandLineSupport.java
index 25bb1ef60b8..b0afbf5a2c7 100644
--- a/core/camel-main/src/main/java/org/apache/camel/main/MainCommandLineSupport.java
+++ b/core/camel-main/src/main/java/org/apache/camel/main/MainCommandLineSupport.java
@@ -22,11 +22,12 @@ import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Properties;
+import java.util.function.Predicate;
import org.apache.camel.CamelConfiguration;
import org.apache.camel.CamelContext;
+import org.apache.camel.spi.LoadablePropertiesSource;
import org.apache.camel.spi.PropertiesComponent;
-import org.apache.camel.spi.PropertiesSource;
import org.apache.camel.util.OrderedProperties;
/**
@@ -225,7 +226,30 @@ public abstract class MainCommandLineSupport extends MainSupport {
PropertiesComponent pc = camelContext.getPropertiesComponent();
if (argumentProperties != null && !argumentProperties.isEmpty()) {
// register source for command line arguments to be used for property placeholders
- pc.addPropertiesSource(new PropertiesSource() {
+ pc.addPropertiesSource(new LoadablePropertiesSource() {
+ @Override
+ public Properties loadProperties() {
+ return argumentProperties;
+ }
+
+ @Override
+ public Properties loadProperties(Predicate<String> filter) {
+ Properties answer = new OrderedProperties();
+
+ for (String name : argumentProperties.stringPropertyNames()) {
+ if (filter.test(name)) {
+ answer.put(name, argumentProperties.get(name));
+ }
+ }
+
+ return answer;
+ }
+
+ @Override
+ public void reloadProperties(String location) {
+ // noop
+ }
+
@Override
public String getName() {
return "CLI";