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 2012/05/15 15:32:24 UTC

svn commit: r1338701 - in /karaf/cellar/trunk: assembly/src/main/resources/ config/src/main/java/org/apache/karaf/cellar/config/

Author: jbonofre
Date: Tue May 15 13:32:24 2012
New Revision: 1338701

URL: http://svn.apache.org/viewvc?rev=1338701&view=rev
Log:
Populate config properties instead of overriding the whole config

Modified:
    karaf/cellar/trunk/assembly/src/main/resources/groups.cfg
    karaf/cellar/trunk/config/src/main/java/org/apache/karaf/cellar/config/ConfigurationEventHandler.java
    karaf/cellar/trunk/config/src/main/java/org/apache/karaf/cellar/config/ConfigurationSupport.java
    karaf/cellar/trunk/config/src/main/java/org/apache/karaf/cellar/config/ConfigurationSynchronizer.java
    karaf/cellar/trunk/config/src/main/java/org/apache/karaf/cellar/config/LocalConfigurationListener.java

Modified: karaf/cellar/trunk/assembly/src/main/resources/groups.cfg
URL: http://svn.apache.org/viewvc/karaf/cellar/trunk/assembly/src/main/resources/groups.cfg?rev=1338701&r1=1338700&r2=1338701&view=diff
==============================================================================
--- karaf/cellar/trunk/assembly/src/main/resources/groups.cfg (original)
+++ karaf/cellar/trunk/assembly/src/main/resources/groups.cfg Tue May 15 13:32:24 2012
@@ -1,10 +1,12 @@
 default.config.whitelist.inbound=*
 default.config.whitelist.outbound=*
-default.config.blacklist.inbound=org.apache.karaf.cellar.node, \
+default.config.blacklist.inbound=org.apache.karaf.cellar.groups, \
+                                 org.apache.karaf.cellar.node, \
                                  org.apache.karaf.management, \
                                  org.apache.karaf.shell, \
                                  org.ops4j.pax.logging
-default.config.blacklist.outbound=org.apache.karaf.cellar.node, \
+default.config.blacklist.outbound=org.apache.karaf.cellar.groups, \
+                                 org.apache.karaf.cellar.node, \
                                  org.apache.karaf.management, \
                                  org.apache.karaf.shell, \
                                  org.ops4j.pax.logging

Modified: karaf/cellar/trunk/config/src/main/java/org/apache/karaf/cellar/config/ConfigurationEventHandler.java
URL: http://svn.apache.org/viewvc/karaf/cellar/trunk/config/src/main/java/org/apache/karaf/cellar/config/ConfigurationEventHandler.java?rev=1338701&r1=1338700&r2=1338701&view=diff
==============================================================================
--- karaf/cellar/trunk/config/src/main/java/org/apache/karaf/cellar/config/ConfigurationEventHandler.java (original)
+++ karaf/cellar/trunk/config/src/main/java/org/apache/karaf/cellar/config/ConfigurationEventHandler.java Tue May 15 13:32:24 2012
@@ -73,7 +73,11 @@ public class ConfigurationEventHandler e
                     } else {
                         if (remoteDictionary != null) {
                             remoteDictionary.put(Constants.SYNC_PROPERTY, new Long(System.currentTimeMillis()).toString());
-                            conf.update(filter(remoteDictionary));
+                            Dictionary localDictionary = conf.getProperties();
+                            if (localDictionary == null)
+                                localDictionary = new Properties();
+                            filter(remoteDictionary, localDictionary);
+                            conf.update(localDictionary);
                         }
                     }
                 }

Modified: karaf/cellar/trunk/config/src/main/java/org/apache/karaf/cellar/config/ConfigurationSupport.java
URL: http://svn.apache.org/viewvc/karaf/cellar/trunk/config/src/main/java/org/apache/karaf/cellar/config/ConfigurationSupport.java?rev=1338701&r1=1338700&r2=1338701&view=diff
==============================================================================
--- karaf/cellar/trunk/config/src/main/java/org/apache/karaf/cellar/config/ConfigurationSupport.java (original)
+++ karaf/cellar/trunk/config/src/main/java/org/apache/karaf/cellar/config/ConfigurationSupport.java Tue May 15 13:32:24 2012
@@ -27,45 +27,22 @@ public class ConfigurationSupport extend
     private static String[] EXCLUDED_PROPERTIES = { "felix.fileinstall.filename", "felix.fileinstall.dir", "felix.fileinstall.tmpdir", "org.ops4j.pax.url.mvn.defaultRepositories" };
 
     /**
-     * Reads a {@code Dictionary} object and creates a property object out of it.
-     *
-     * @param dictionary
-     * @return
-     */
-    public Properties dictionaryToProperties(Dictionary dictionary) {
-        Properties properties = new Properties();
-        if (dictionary != null && dictionary.keys() != null) {
-
-            Enumeration keys = dictionary.keys();
-            while (keys.hasMoreElements()) {
-                String key = (String) keys.nextElement();
-                if (key != null && dictionary.get(key) != null) {
-                    String value = String.valueOf(dictionary.get(key));
-                    properties.put(key, value);
-                }
-            }
-        }
-        return properties;
-    }
-
-    /**
      * Filter a dictionary, specially replace the karaf.home property with a relative value.
-     * @param dictionary
-     * @return
+     *
+     * @param source the source dictionary.
+     * @param target the target dictionary
      */
-    public Dictionary filter(Dictionary dictionary) {
-        Dictionary result = new Properties();
-        if (dictionary != null) {
-            Enumeration enumaration = dictionary.keys();
+    public void filter(Dictionary source, Dictionary target) {
+        if (source != null) {
+            Enumeration enumaration = source.keys();
             while (enumaration.hasMoreElements()) {
                 String key = (String) enumaration.nextElement();
                 if (!isExcludedProperty(key)) {
-                    String value = String.valueOf(dictionary.get(key));
-                    result.put(key, value);
+                    String value = String.valueOf(source.get(key));
+                    target.put(key, value);
                 }
             }
         }
-        return result;
     }
 
     /**

Modified: karaf/cellar/trunk/config/src/main/java/org/apache/karaf/cellar/config/ConfigurationSynchronizer.java
URL: http://svn.apache.org/viewvc/karaf/cellar/trunk/config/src/main/java/org/apache/karaf/cellar/config/ConfigurationSynchronizer.java?rev=1338701&r1=1338700&r2=1338701&view=diff
==============================================================================
--- karaf/cellar/trunk/config/src/main/java/org/apache/karaf/cellar/config/ConfigurationSynchronizer.java (original)
+++ karaf/cellar/trunk/config/src/main/java/org/apache/karaf/cellar/config/ConfigurationSynchronizer.java Tue May 15 13:32:24 2012
@@ -89,7 +89,11 @@ public class ConfigurationSynchronizer e
                             // update the local configuration if needed
                             Configuration conf = configurationAdmin.getConfiguration(pid);
                             remoteDictionary.put(Constants.SYNC_PROPERTY, new Long(System.currentTimeMillis()).toString());
-                            conf.update(filter(remoteDictionary));
+                            Dictionary localDictionary = conf.getProperties();
+                            if (localDictionary == null)
+                                localDictionary = new Properties();
+                            filter(remoteDictionary, localDictionary);
+                            conf.update(localDictionary);
                         } catch (IOException ex) {
                             LOGGER.error("CELLAR CONFIG: failed to read distributed map", ex);
                         }
@@ -126,11 +130,15 @@ public class ConfigurationSynchronizer e
                         String pid = conf.getPid();
                         // check if the pid is marked as local.
                         if (isAllowed(group, Constants.CATEGORY, pid, EventType.OUTBOUND)) {
-                            Properties localDictionary = dictionaryToProperties(filter(conf.getProperties()));
+                            Dictionary localDictionary = conf.getProperties();
+                            if (localDictionary == null)
+                                localDictionary = new Properties();
+                            Properties localProperties = new Properties();
+                            filter(localDictionary, localProperties);
                             // update the distributed map
-                            configurationTable.put(pid, localDictionary);
+                            configurationTable.put(pid, localProperties);
                             // broadcast the cluster event
-                            RemoteConfigurationEvent event = new RemoteConfigurationEvent(conf.getPid());
+                            RemoteConfigurationEvent event = new RemoteConfigurationEvent(pid);
                             event.setSourceGroup(group);
                             eventProducer.produce(event);
                         } else

Modified: karaf/cellar/trunk/config/src/main/java/org/apache/karaf/cellar/config/LocalConfigurationListener.java
URL: http://svn.apache.org/viewvc/karaf/cellar/trunk/config/src/main/java/org/apache/karaf/cellar/config/LocalConfigurationListener.java?rev=1338701&r1=1338700&r2=1338701&view=diff
==============================================================================
--- karaf/cellar/trunk/config/src/main/java/org/apache/karaf/cellar/config/LocalConfigurationListener.java (original)
+++ karaf/cellar/trunk/config/src/main/java/org/apache/karaf/cellar/config/LocalConfigurationListener.java Tue May 15 13:32:24 2012
@@ -91,8 +91,8 @@ public class LocalConfigurationListener 
                             configurationTable.remove(pid);
                             // TODO broadcast the cluster event
                         } else {
-                            //Configuration conf = configurationAdmin.getConfiguration(pid);
-                            Properties localProperties = dictionaryToProperties(filter(localDictionary));
+                            Properties localProperties = new Properties();
+                            filter(localDictionary, localProperties);
                             // update the distributed map
                             configurationTable.put(pid, localProperties);
                             // broadcast the cluster event