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 2019/05/24 09:59:38 UTC
[camel] 06/06: CAMEL-13557: Camel main can configure properties on
camel context also
This is an automated email from the ASF dual-hosted git repository.
davsclaus pushed a commit to branch 13557
in repository https://gitbox.apache.org/repos/asf/camel.git
commit 82a5987e7712db9ec1b8dddca10fa952cef004e9
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Fri May 24 11:52:16 2019 +0200
CAMEL-13557: Camel main can configure properties on camel context also
---
.../src/main/java/org/apache/camel/main/MainSupport.java | 16 ++++++++++++++++
.../src/main/resources/application.properties | 4 ++++
2 files changed, 20 insertions(+)
diff --git a/core/camel-core/src/main/java/org/apache/camel/main/MainSupport.java b/core/camel-core/src/main/java/org/apache/camel/main/MainSupport.java
index a20623b..1866caf 100644
--- a/core/camel-core/src/main/java/org/apache/camel/main/MainSupport.java
+++ b/core/camel-core/src/main/java/org/apache/camel/main/MainSupport.java
@@ -976,6 +976,22 @@ public abstract class MainSupport extends ServiceSupport {
// additional advanced configuration which is not configured using CamelConfigurationProperties
afterPropertiesSet(camelContext.getRegistry(), camelContext);
+
+ // now configure context with additional properties
+ Properties prop = camelContext.getPropertiesComponent().loadProperties();
+ Map<String, Object> properties = new LinkedHashMap<>();
+ for (String key : prop.stringPropertyNames()) {
+ if (key.startsWith("camel.context.")) {
+ // grab the value
+ String value = prop.getProperty(key);
+ String option = key.substring(14);
+ properties.put(option, value);
+ }
+ }
+ if (!properties.isEmpty()) {
+ LOG.info("Auto configuring CamelContext from loaded properties: {}", properties.size());
+ }
+ setCamelProperties(camelContext, camelContext, properties, true);
}
/**
diff --git a/examples/camel-example-main/src/main/resources/application.properties b/examples/camel-example-main/src/main/resources/application.properties
index ddbb5a6..8bb5863 100644
--- a/examples/camel-example-main/src/main/resources/application.properties
+++ b/examples/camel-example-main/src/main/resources/application.properties
@@ -20,6 +20,9 @@
camel.main.name = MyCoolCamel
camel.main.jmx-enabled = false
+# you can also configure camel context directly
+# camel.context.shutdown-strategy.shutdown-now-on-timeout = false
+
# load additional property placeholders from this folder
camel.main.file-configurations=src/main/data/*.properties
@@ -27,6 +30,7 @@ camel.main.file-configurations=src/main/data/*.properties
# here we can configure the options on the component level (and we can use dash-naming-style)
camel.component.quartz2.start-delayed-seconds = 3
+
# you can configure whether OS environment should override (=2 which is default) or as fallback (=1)
### camel.component.properties.environment-variable-mode=1