karaf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jbono...@apache.org
Subject karaf git commit: [KARAF-4803] Turn off Karaf configuration persistence manager
Date Thu, 10 Aug 2017 09:24:02 GMT
Repository: karaf
Updated Branches:
  refs/heads/karaf-4.1.x 6fabd5262 -> 31e38f8f6


[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/31e38f8f
Tree: http://git-wip-us.apache.org/repos/asf/karaf/tree/31e38f8f
Diff: http://git-wip-us.apache.org/repos/asf/karaf/diff/31e38f8f

Branch: refs/heads/karaf-4.1.x
Commit: 31e38f8f6643bfeed88887642f680f20370ad846
Parents: 6fabd52
Author: Dominik Przybysz <dpr@touk.pl>
Authored: Sun Oct 23 18:42:45 2016 +0200
Committer: Jean-Baptiste Onofré <jbonofre@apache.org>
Committed: Thu Aug 10 11:23:57 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/31e38f8f/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/31e38f8f/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.


Mime
View raw message