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 2022/06/12 06:03:28 UTC
[karaf] branch main updated: [KARAF-7447] Add env variable and system property to change json config extension
This is an automated email from the ASF dual-hosted git repository.
jbonofre pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/karaf.git
The following commit(s) were added to refs/heads/main by this push:
new 1183d4ad09 [KARAF-7447] Add env variable and system property to change json config extension
new f56092437d Merge pull request #1548 from jbonofre/KARAF-7447
1183d4ad09 is described below
commit 1183d4ad09a1dfa6197191585687857f16b323ba
Author: Jean-Baptiste Onofré <jb...@apache.org>
AuthorDate: Mon Jun 6 07:57:09 2022 +0200
[KARAF-7447] Add env variable and system property to change json config extension
---
.../karaf/config/core/impl/JsonConfigInstaller.java | 10 +++++++++-
manual/src/main/asciidoc/user-guide/configuration.adoc | 15 +++++++++++++++
2 files changed, 24 insertions(+), 1 deletion(-)
diff --git a/config/src/main/java/org/apache/karaf/config/core/impl/JsonConfigInstaller.java b/config/src/main/java/org/apache/karaf/config/core/impl/JsonConfigInstaller.java
index 8fd38707d3..13991ec4ec 100644
--- a/config/src/main/java/org/apache/karaf/config/core/impl/JsonConfigInstaller.java
+++ b/config/src/main/java/org/apache/karaf/config/core/impl/JsonConfigInstaller.java
@@ -43,6 +43,9 @@ import java.util.Objects;
public class JsonConfigInstaller implements ArtifactInstaller, ConfigurationListener {
+ public final static String EXT_ENV_VAR = "KARAF_JSON_CONFIG_EXTENSION";
+ public final static String EXT_SYS_PROP = "karaf.json.config.extension";
+
private final static Logger LOGGER = LoggerFactory.getLogger(JsonConfigInstaller.class);
private final ConfigurationAdmin configurationAdmin;
@@ -53,7 +56,12 @@ public class JsonConfigInstaller implements ArtifactInstaller, ConfigurationList
@Override
public boolean canHandle(File artifact) {
- return artifact.getName().endsWith(".json");
+ String extension = (System.getenv(EXT_ENV_VAR) != null) ? System.getenv(EXT_ENV_VAR) : null;
+ extension = (System.getProperty(EXT_SYS_PROP) != null) ? System.getProperty(EXT_SYS_PROP) : extension;
+ if (extension == null) {
+ extension = ".json";
+ }
+ return artifact.getName().endsWith(extension);
}
@Override
diff --git a/manual/src/main/asciidoc/user-guide/configuration.adoc b/manual/src/main/asciidoc/user-guide/configuration.adoc
index 0747fc7e24..45c2437b0c 100644
--- a/manual/src/main/asciidoc/user-guide/configuration.adoc
+++ b/manual/src/main/asciidoc/user-guide/configuration.adoc
@@ -196,6 +196,21 @@ Apache Karaf persists configuration using its own persistence manager in the cas
Configuration files are placed by default in `KARAF_ETC`, but it could be overridden via variable `storage` in `etc/org.apache.karaf.config.cfg`.
If you want to disable the Karaf persistence manager, set the storage variable to an empty string (`storage=`).
+===== json files
+
+You can also use config files wiht json format.
+
+By default, Apache Karaf loads all `*.json` files from the `etc` folder.
+
+You can change the file extension using `KARAF_JSON_CONFIG_EXTENSION` environment variable or `karaf.json.config.extension` system property.
+
+For instance, you can use `.myjson` extension using:
+
+----
+export KARAF_JSON_CONFIG_EXTENSION=.myjson
+./bin/karaf
+----
+
==== `config:*` commands
Apache Karaf provides a set of commands to manage the configuration.