Repository: karaf
Updated Branches:
  refs/heads/master ae930b392 -> 94fd17e3d


[KARAF-4803] Turn off Karaf configuration persistence manager


Project: http://git-wip-us.apache.org/repos/asf/karaf/repo
Commit: http://git-wip-us.apache.org/repos/asf/karaf/commit/1df3ce30
Tree: http://git-wip-us.apache.org/repos/asf/karaf/tree/1df3ce30
Diff: http://git-wip-us.apache.org/repos/asf/karaf/diff/1df3ce30

Branch: refs/heads/master
Commit: 1df3ce30e564e6b13bd459c4d1df446c4ce6b69a
Parents: ae930b3
Author: Dominik Przybysz <d...@touk.pl>
Authored: Sun Oct 23 18:42:45 2016 +0200
Committer: Jean-Baptiste Onofré <jbono...@apache.org>
Committed: Thu Aug 10 07:40:27 2017 +0200

----------------------------------------------------------------------
 .../karaf/config/core/impl/osgi/Activator.java       | 15 ++++++++++++++-
 .../src/main/asciidoc/user-guide/configuration.adoc  |  6 +++++-
 2 files changed, 19 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/karaf/blob/1df3ce30/config/src/main/java/org/apache/karaf/config/core/impl/osgi/Activator.java
----------------------------------------------------------------------
diff --git 
a/config/src/main/java/org/apache/karaf/config/core/impl/osgi/Activator.java 
b/config/src/main/java/org/apache/karaf/config/core/impl/osgi/Activator.java
index 8ea04c5..cef9527 100644
--- a/config/src/main/java/org/apache/karaf/config/core/impl/osgi/Activator.java
+++ b/config/src/main/java/org/apache/karaf/config/core/impl/osgi/Activator.java
@@ -23,9 +23,11 @@ import org.apache.karaf.util.tracker.BaseActivator;
 import org.apache.karaf.util.tracker.annotation.ProvideService;
 import org.apache.karaf.util.tracker.annotation.RequireService;
 import org.apache.karaf.util.tracker.annotation.Services;
+import org.osgi.service.cm.Configuration;
 import org.osgi.service.cm.ConfigurationAdmin;
 
 import java.io.File;
+import java.io.IOException;
 
 @Services(
         requires = @RequireService(ConfigurationAdmin.class),
@@ -39,7 +41,9 @@ public class Activator extends BaseActivator {
             return;
         }
 
-        ConfigRepository configRepository = new 
ConfigRepositoryImpl(configurationAdmin, new 
File(System.getProperty("karaf.etc")));
+        File persistenceStorage = getPersistenceStorage(configurationAdmin);
+
+        ConfigRepository configRepository = new 
ConfigRepositoryImpl(configurationAdmin, persistenceStorage);
         register(ConfigRepository.class, configRepository);
 
         ConfigMBeanImpl configMBean = new ConfigMBeanImpl();
@@ -47,4 +51,13 @@ public class Activator extends BaseActivator {
         registerMBean(configMBean, "type=config");
     }
 
+    private File getPersistenceStorage(ConfigurationAdmin configurationAdmin) 
throws IOException {
+        Configuration configuration = 
configurationAdmin.getConfiguration("org.apache.karaf.config");
+        if(configuration.getProperties() == null){
+            return new File(System.getProperty("karaf.etc"));
+        }
+        String storage = (String) configuration.getProperties().get("storage");
+        return storage == null || storage.trim().isEmpty() ? null : new 
File(storage);
+    }
+
 }

http://git-wip-us.apache.org/repos/asf/karaf/blob/1df3ce30/manual/src/main/asciidoc/user-guide/configuration.adoc
----------------------------------------------------------------------
diff --git a/manual/src/main/asciidoc/user-guide/configuration.adoc 
b/manual/src/main/asciidoc/user-guide/configuration.adoc
index 3217f3f..7625bf2 100644
--- a/manual/src/main/asciidoc/user-guide/configuration.adoc
+++ b/manual/src/main/asciidoc/user-guide/configuration.adoc
@@ -73,7 +73,7 @@ felix.fileinstall.log.default = jul
 * `felix.fileinstall.enableConfigSave` flush back in the configuration file 
the changes performed directly on the
 configuration service (ConfigAdmin). If `true`, any change (using `config:*` 
commands, MBeans, OSGi service) is
 persisted back in the configuration false. Default is `true`.
-* `felix.fileinstall.dir` is the directory where Apache Karaf is looking for 
configuration files. Default is `${karaf.etc`}
+* `felix.fileinstall.dir` is the directory where Apache Karaf is looking for 
configuration files. Default is `${karaf.etc}`
 meaning the value of the `KARAF_ETC` variable.
 * `felix.fileinstall.filter` is the file name pattern used to load only some 
configuration files. Only files matching
 the pattern will be loaded. Default value is `.*\\.(cfg|config)` meaning *.cfg 
and *.config files.
@@ -90,6 +90,10 @@ You can change the configuration at runtime by directly 
editing the configuratio
 
 You can also do the same using the `config:*` commands or the ConfigMBean.
 
+Apache Karaf persists configuration using own persistence manager in case of 
when available persistence managers do not support that.
+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 karaf persistence manager, set storage variable to 
empty string (`storage=`).
+
 ==== `config:*` commands
 
 Apache Karaf provides a set of commands to manage the configuration.

Reply via email to