You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@karaf.apache.org by jb...@apache.org on 2020/09/30 07:14:15 UTC
[karaf] branch master updated: Update configuration user guide
about system properties
This is an automated email from the ASF dual-hosted git repository.
jbonofre pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/karaf.git
The following commit(s) were added to refs/heads/master by this push:
new 4c33fd1 Update configuration user guide about system properties
4c33fd1 is described below
commit 4c33fd1596c2b81febc213b193f544274fad2937
Author: jbonofre <jb...@apache.org>
AuthorDate: Wed Sep 30 09:13:59 2020 +0200
Update configuration user guide about system properties
---
config/pom.xml | 10 +++++++---
.../karaf/config/core/impl/KarafConfigurationPlugin.java | 2 ++
manual/src/main/asciidoc/user-guide/configuration.adoc | 8 ++++++++
3 files changed, 17 insertions(+), 3 deletions(-)
diff --git a/config/pom.xml b/config/pom.xml
index 83910e8..5ce31e3 100644
--- a/config/pom.xml
+++ b/config/pom.xml
@@ -59,6 +59,10 @@
<groupId>org.apache.karaf</groupId>
<artifactId>org.apache.karaf.util</artifactId>
</dependency>
+ <dependency>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>org.apache.felix.utils</artifactId>
+ </dependency>
<dependency>
<groupId>org.apache.karaf.shell</groupId>
@@ -101,8 +105,7 @@
<instructions>
<Export-Package>
org.apache.karaf.config.command*,
- org.apache.karaf.config.core,
- org.apache.felix.utils.properties;version="${felix.utils.version}"
+ org.apache.karaf.config.core
</Export-Package>
<Import-Package>
org.osgi.service.metatype;resolution:=optional,
@@ -112,7 +115,8 @@
<Private-Package>
org.apache.karaf.config.core.impl,
org.apache.karaf.config.core.impl.osgi,
- org.apache.karaf.util
+ org.apache.karaf.util,
+ org.apache.felix.utils*
</Private-Package>
</instructions>
</configuration>
diff --git a/config/src/main/java/org/apache/karaf/config/core/impl/KarafConfigurationPlugin.java b/config/src/main/java/org/apache/karaf/config/core/impl/KarafConfigurationPlugin.java
index 913bcab..e3ca937 100644
--- a/config/src/main/java/org/apache/karaf/config/core/impl/KarafConfigurationPlugin.java
+++ b/config/src/main/java/org/apache/karaf/config/core/impl/KarafConfigurationPlugin.java
@@ -16,6 +16,7 @@
*/
package org.apache.karaf.config.core.impl;
+import org.apache.felix.utils.properties.InterpolationHelper;
import org.osgi.framework.Constants;
import org.osgi.framework.ServiceReference;
import org.osgi.service.cm.ConfigurationPlugin;
@@ -41,6 +42,7 @@ public class KarafConfigurationPlugin implements ConfigurationPlugin {
String env = (pid + "." + key).toUpperCase().replaceAll("\\.", "_");
String sys = pid + "." + key;
if (System.getenv(env) != null) {
+ Object value = InterpolationHelper.performSubstitution();
if (properties.get(key) != null && (properties.get(key) instanceof Number)) {
properties.put(key, Integer.parseInt(System.getenv(env)));
} else {
diff --git a/manual/src/main/asciidoc/user-guide/configuration.adoc b/manual/src/main/asciidoc/user-guide/configuration.adoc
index 764becb..fe50808 100644
--- a/manual/src/main/asciidoc/user-guide/configuration.adoc
+++ b/manual/src/main/asciidoc/user-guide/configuration.adoc
@@ -68,6 +68,14 @@ property3=${existing_property:-bar} # "baz"
property4=${existing_property:+bar} # "bar"
----
+Apache Karaf will look for system property as well. For instance, the following:
+
+----
+key=${foo}
+----
+
+means that `key` will contain `bar` if you start Karaf with `-Dfoo=bar`.
+
Environment variables can be referenced inside configuration files using the syntax `${env:<name>}` (e.g.
`property=${env:FOO}` will set "property" to the value of the enviroment variable "FOO"). Default and alternate
values can be defined for them as well using the same syntax as above.