Repository: karaf
Updated Branches:
  refs/heads/master 7660ee68c -> 6f2d2bb57


[KARAF-4346] Support array of values with etc/*.config files

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

Branch: refs/heads/master
Commit: 2969a3489e1d73605bd82af16d6b4344fe06b55d
Parents: 7660ee6
Author: Guillaume Nodet <[email protected]>
Authored: Thu Sep 8 11:48:11 2016 +0200
Committer: Guillaume Nodet <[email protected]>
Committed: Thu Sep 8 11:48:11 2016 +0200

----------------------------------------------------------------------
 .../filtered-resources/resources/etc/config.properties   |  2 +-
 .../karaf/config/command/ConfigCommandSupport.java       | 11 +++++++++++
 .../org/apache/karaf/config/command/ListCommand.java     |  2 +-
 .../src/main/webapp/WEB-INF/karaf/etc/config.properties  |  2 +-
 manual/src/main/asciidoc/user-guide/configuration.adoc   |  4 ++--
 5 files changed, 16 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/karaf/blob/2969a348/assemblies/features/base/src/main/filtered-resources/resources/etc/config.properties
----------------------------------------------------------------------
diff --git 
a/assemblies/features/base/src/main/filtered-resources/resources/etc/config.properties
 
b/assemblies/features/base/src/main/filtered-resources/resources/etc/config.properties
index debedeb..5b36a2d 100644
--- 
a/assemblies/features/base/src/main/filtered-resources/resources/etc/config.properties
+++ 
b/assemblies/features/base/src/main/filtered-resources/resources/etc/config.properties
@@ -168,7 +168,7 @@ karaf.shutdown.port.file=${karaf.data}/port
 #
 felix.fileinstall.enableConfigSave = true
 felix.fileinstall.dir    = ${karaf.etc}
-felix.fileinstall.filter = .*\\.cfg
+felix.fileinstall.filter = .*\\.(cfg|config)
 felix.fileinstall.poll   = 1000
 felix.fileinstall.noInitialDelay = true
 felix.fileinstall.log.level = 3

http://git-wip-us.apache.org/repos/asf/karaf/blob/2969a348/config/src/main/java/org/apache/karaf/config/command/ConfigCommandSupport.java
----------------------------------------------------------------------
diff --git 
a/config/src/main/java/org/apache/karaf/config/command/ConfigCommandSupport.java
 
b/config/src/main/java/org/apache/karaf/config/command/ConfigCommandSupport.java
index fe0ca93..485988a 100644
--- 
a/config/src/main/java/org/apache/karaf/config/command/ConfigCommandSupport.java
+++ 
b/config/src/main/java/org/apache/karaf/config/command/ConfigCommandSupport.java
@@ -16,6 +16,7 @@
  */
 package org.apache.karaf.config.command;
 
+import java.util.Arrays;
 import java.util.Dictionary;
 
 import org.apache.karaf.config.core.ConfigRepository;
@@ -60,4 +61,14 @@ public abstract class ConfigCommandSupport implements Action 
{
     public void setSession(Session session) {
         this.session = session;
     }
+
+    protected String displayValue(Object value) {
+        if (value == null) {
+            return "<null>";
+        }
+        if (value.getClass().isArray()) {
+            return Arrays.toString((Object[]) value);
+        }
+        return value.toString();
+    }
 }

http://git-wip-us.apache.org/repos/asf/karaf/blob/2969a348/config/src/main/java/org/apache/karaf/config/command/ListCommand.java
----------------------------------------------------------------------
diff --git 
a/config/src/main/java/org/apache/karaf/config/command/ListCommand.java 
b/config/src/main/java/org/apache/karaf/config/command/ListCommand.java
index bce8410..fb8ef9b 100644
--- a/config/src/main/java/org/apache/karaf/config/command/ListCommand.java
+++ b/config/src/main/java/org/apache/karaf/config/command/ListCommand.java
@@ -58,7 +58,7 @@ public class ListCommand extends ConfigCommandSupport {
                         sortedProps.put(key.toString(), props.get(key));
                     }
                     for (String key : sortedProps.keySet()) {
-                        System.out.println("   " + key + " = " + 
sortedProps.get(key));
+                        System.out.println("   " + key + " = " + 
displayValue(sortedProps.get(key)));
                     }
                 }
             }

http://git-wip-us.apache.org/repos/asf/karaf/blob/2969a348/demos/web/src/main/webapp/WEB-INF/karaf/etc/config.properties
----------------------------------------------------------------------
diff --git a/demos/web/src/main/webapp/WEB-INF/karaf/etc/config.properties 
b/demos/web/src/main/webapp/WEB-INF/karaf/etc/config.properties
index 4402d4f..e8ff536 100644
--- a/demos/web/src/main/webapp/WEB-INF/karaf/etc/config.properties
+++ b/demos/web/src/main/webapp/WEB-INF/karaf/etc/config.properties
@@ -342,7 +342,7 @@ karaf.shutdown.port.file=${karaf.data}/port
 #
 felix.fileinstall.enableConfigSave = true
 felix.fileinstall.dir    = ${karaf.etc}
-felix.fileinstall.filter = .*\\.cfg
+felix.fileinstall.filter = .*\\.(cfg|config)
 felix.fileinstall.poll   = 1000
 felix.fileinstall.noInitialDelay = true
 felix.fileinstall.log.level = 3

http://git-wip-us.apache.org/repos/asf/karaf/blob/2969a348/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 4ee0ad3..3217f3f 100644
--- a/manual/src/main/asciidoc/user-guide/configuration.adoc
+++ b/manual/src/main/asciidoc/user-guide/configuration.adoc
@@ -62,7 +62,7 @@ You can configure the behaviour of the configuration files 
using some dedicated
 #
 felix.fileinstall.enableConfigSave = true
 felix.fileinstall.dir    = ${karaf.etc}
-felix.fileinstall.filter = .*\\.cfg
+felix.fileinstall.filter = .*\\.(cfg|config)
 felix.fileinstall.poll   = 1000
 felix.fileinstall.noInitialDelay = true
 felix.fileinstall.log.level = 3
@@ -76,7 +76,7 @@ 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`}
 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` meaning *.cfg files.
+the pattern will be loaded. Default value is `.*\\.(cfg|config)` meaning *.cfg 
and *.config files.
 * `felix.fileinstall.poll` is the polling interval (in milliseconds). Default 
value is `1000` meaning that Apache
 Karaf "re-loads" the configuration files every second.
 * `felix.fileinstall.noInitialDelay` is a flag indicating if the configuration 
file polling starts as soon as Apache

Reply via email to