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/11/26 22:23:08 UTC

svn commit: r1413858 - in /karaf/cellar/branches/cellar-2.3.x: bundle/src/main/java/org/apache/karaf/cellar/bundle/ config/src/main/java/org/apache/karaf/cellar/config/ features/src/main/java/org/apache/karaf/cellar/features/

Author: jbonofre
Date: Mon Nov 26 21:23:07 2012
New Revision: 1413858

URL: http://svn.apache.org/viewvc?rev=1413858&view=rev
Log:
Remove sync check in the local listeners (postponed to next Cellar release)

Modified:
    karaf/cellar/branches/cellar-2.3.x/bundle/src/main/java/org/apache/karaf/cellar/bundle/BundleSupport.java
    karaf/cellar/branches/cellar-2.3.x/bundle/src/main/java/org/apache/karaf/cellar/bundle/BundleSynchronizer.java
    karaf/cellar/branches/cellar-2.3.x/bundle/src/main/java/org/apache/karaf/cellar/bundle/LocalBundleListener.java
    karaf/cellar/branches/cellar-2.3.x/config/src/main/java/org/apache/karaf/cellar/config/ConfigurationSupport.java
    karaf/cellar/branches/cellar-2.3.x/config/src/main/java/org/apache/karaf/cellar/config/ConfigurationSynchronizer.java
    karaf/cellar/branches/cellar-2.3.x/config/src/main/java/org/apache/karaf/cellar/config/LocalConfigurationListener.java
    karaf/cellar/branches/cellar-2.3.x/features/src/main/java/org/apache/karaf/cellar/features/FeaturesSupport.java
    karaf/cellar/branches/cellar-2.3.x/features/src/main/java/org/apache/karaf/cellar/features/FeaturesSynchronizer.java
    karaf/cellar/branches/cellar-2.3.x/features/src/main/java/org/apache/karaf/cellar/features/LocalFeaturesListener.java

Modified: karaf/cellar/branches/cellar-2.3.x/bundle/src/main/java/org/apache/karaf/cellar/bundle/BundleSupport.java
URL: http://svn.apache.org/viewvc/karaf/cellar/branches/cellar-2.3.x/bundle/src/main/java/org/apache/karaf/cellar/bundle/BundleSupport.java?rev=1413858&r1=1413857&r2=1413858&view=diff
==============================================================================
--- karaf/cellar/branches/cellar-2.3.x/bundle/src/main/java/org/apache/karaf/cellar/bundle/BundleSupport.java (original)
+++ karaf/cellar/branches/cellar-2.3.x/bundle/src/main/java/org/apache/karaf/cellar/bundle/BundleSupport.java Mon Nov 26 21:23:07 2012
@@ -14,15 +14,11 @@
 package org.apache.karaf.cellar.bundle;
 
 import org.apache.karaf.cellar.core.CellarSupport;
-import org.apache.karaf.cellar.core.Configurations;
-import org.apache.karaf.cellar.core.Group;
 import org.osgi.framework.Bundle;
 import org.osgi.framework.BundleContext;
 import org.osgi.framework.BundleException;
-import org.osgi.service.cm.Configuration;
 import org.osgi.service.cm.ConfigurationAdmin;
 
-import java.io.IOException;
 import java.util.Dictionary;
 import java.util.Enumeration;
 import java.util.Properties;
@@ -131,24 +127,6 @@ public class BundleSupport extends Cella
         }
     }
 
-    public Boolean isSyncEnabled(Group group) {
-        Boolean result = Boolean.FALSE;
-        String groupName = group.getName();
-
-        try {
-            Configuration configuration = configurationAdmin.getConfiguration(Configurations.GROUP);
-            Dictionary<String, Object> properties = configuration.getProperties();
-            if (properties != null) {
-                String propertyKey = groupName + Configurations.SEPARATOR + Constants.CATEGORY + Configurations.SEPARATOR + Configurations.SYNC;
-                String propertyValue = (String) properties.get(propertyKey);
-                result = Boolean.parseBoolean(propertyValue);
-            }
-        } catch (IOException e) {
-            LOGGER.error("CELLAR BUNDLE: failed to check if sync is enabled", e);
-        }
-        return result;
-    }
-
     /**
      * Returns the {@link BundleContext}.
      *

Modified: karaf/cellar/branches/cellar-2.3.x/bundle/src/main/java/org/apache/karaf/cellar/bundle/BundleSynchronizer.java
URL: http://svn.apache.org/viewvc/karaf/cellar/branches/cellar-2.3.x/bundle/src/main/java/org/apache/karaf/cellar/bundle/BundleSynchronizer.java?rev=1413858&r1=1413857&r2=1413858&view=diff
==============================================================================
--- karaf/cellar/branches/cellar-2.3.x/bundle/src/main/java/org/apache/karaf/cellar/bundle/BundleSynchronizer.java (original)
+++ karaf/cellar/branches/cellar-2.3.x/bundle/src/main/java/org/apache/karaf/cellar/bundle/BundleSynchronizer.java Mon Nov 26 21:23:07 2012
@@ -24,9 +24,13 @@ import org.osgi.framework.BundleContext;
 import org.osgi.framework.BundleEvent;
 import org.osgi.framework.BundleException;
 import org.osgi.framework.BundleReference;
+import org.osgi.service.cm.Configuration;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import java.io.IOException;
+import java.util.Dictionary;
+import java.util.List;
 import java.util.Map;
 import java.util.Set;
 
@@ -172,6 +176,24 @@ public class BundleSynchronizer extends 
         }
     }
 
+    public Boolean isSyncEnabled(Group group) {
+        Boolean result = Boolean.FALSE;
+        String groupName = group.getName();
+
+        try {
+            Configuration configuration = configurationAdmin.getConfiguration(Configurations.GROUP);
+            Dictionary<String, Object> properties = configuration.getProperties();
+            if (properties != null) {
+                String propertyKey = groupName + Configurations.SEPARATOR + Constants.CATEGORY + Configurations.SEPARATOR + Configurations.SYNC;
+                String propertyValue = (String) properties.get(propertyKey);
+                result = Boolean.parseBoolean(propertyValue);
+            }
+        } catch (IOException e) {
+            LOGGER.error("CELLAR BUNDLE: failed to check if sync is enabled", e);
+        }
+        return result;
+    }
+
     public EventProducer getEventProducer() {
         return eventProducer;
     }

Modified: karaf/cellar/branches/cellar-2.3.x/bundle/src/main/java/org/apache/karaf/cellar/bundle/LocalBundleListener.java
URL: http://svn.apache.org/viewvc/karaf/cellar/branches/cellar-2.3.x/bundle/src/main/java/org/apache/karaf/cellar/bundle/LocalBundleListener.java?rev=1413858&r1=1413857&r2=1413858&view=diff
==============================================================================
--- karaf/cellar/branches/cellar-2.3.x/bundle/src/main/java/org/apache/karaf/cellar/bundle/LocalBundleListener.java (original)
+++ karaf/cellar/branches/cellar-2.3.x/bundle/src/main/java/org/apache/karaf/cellar/bundle/LocalBundleListener.java Mon Nov 26 21:23:07 2012
@@ -15,6 +15,7 @@ package org.apache.karaf.cellar.bundle;
 
 import org.apache.karaf.cellar.core.Configurations;
 import org.apache.karaf.cellar.core.Group;
+import org.apache.karaf.cellar.core.Node;
 import org.apache.karaf.cellar.core.control.SwitchStatus;
 import org.apache.karaf.cellar.core.event.EventProducer;
 import org.apache.karaf.cellar.core.event.EventType;
@@ -23,6 +24,7 @@ import org.osgi.framework.BundleListener
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import java.util.List;
 import java.util.Map;
 import java.util.Set;
 
@@ -57,46 +59,41 @@ public class LocalBundleListener extends
             if (groups != null && !groups.isEmpty()) {
                 for (Group group : groups) {
 
-                    if (isSyncEnabled(group)) {
-
-                        String name = (String) event.getBundle().getHeaders().get(org.osgi.framework.Constants.BUNDLE_NAME);
-                        String symbolicName = event.getBundle().getSymbolicName();
-                        String version = event.getBundle().getVersion().toString();
-                        String bundleLocation = event.getBundle().getLocation();
-                        int type = event.getType();
-                        if (isAllowed(group, Constants.CATEGORY, bundleLocation, EventType.OUTBOUND)) {
-
-                            ClassLoader originalClassLoader = Thread.currentThread().getContextClassLoader();
-                            Thread.currentThread().setContextClassLoader(getClass().getClassLoader());
-
-                            try {
-                                // update the cluster map
-                                Map<String, BundleState> bundles = clusterManager.getMap(Constants.BUNDLE_MAP + Configurations.SEPARATOR + group.getName());
-                                if (type == BundleEvent.UNINSTALLED) {
-                                    bundles.remove(symbolicName + "/" + version);
-                                } else {
-                                    BundleState state = bundles.get(symbolicName + "/" + version);
-                                    if (state == null) {
-                                        state = new BundleState();
-                                    }
-                                    state.setName(name);
-                                    state.setStatus(type);
-                                    state.setLocation(bundleLocation);
-                                    bundles.put(symbolicName + "/" + version, state);
+                    String name = (String) event.getBundle().getHeaders().get(org.osgi.framework.Constants.BUNDLE_NAME);
+                    String symbolicName = event.getBundle().getSymbolicName();
+                    String version = event.getBundle().getVersion().toString();
+                    String bundleLocation = event.getBundle().getLocation();
+                    int type = event.getType();
+                    if (isAllowed(group, Constants.CATEGORY, bundleLocation, EventType.OUTBOUND)) {
+
+                        ClassLoader originalClassLoader = Thread.currentThread().getContextClassLoader();
+                        Thread.currentThread().setContextClassLoader(getClass().getClassLoader());
+
+                        try {
+                            // update the cluster map
+                            Map<String, BundleState> bundles = clusterManager.getMap(Constants.BUNDLE_MAP + Configurations.SEPARATOR + group.getName());
+                            if (type == BundleEvent.UNINSTALLED) {
+                                bundles.remove(symbolicName + "/" + version);
+                            } else {
+                                BundleState state = bundles.get(symbolicName + "/" + version);
+                                if (state == null) {
+                                    state = new BundleState();
                                 }
-
-                                // broadcast the cluster event
-                                RemoteBundleEvent remoteBundleEvent = new RemoteBundleEvent(symbolicName, version, bundleLocation, type);
-                                remoteBundleEvent.setSourceGroup(group);
-                                eventProducer.produce(remoteBundleEvent);
-                            } finally {
-                                Thread.currentThread().setContextClassLoader(originalClassLoader);
+                                state.setName(name);
+                                state.setStatus(type);
+                                state.setLocation(bundleLocation);
+                                bundles.put(symbolicName + "/" + version, state);
                             }
 
-                        } else LOGGER.warn("CELLAR BUNDLE: bundle {} is marked as BLOCKED OUTBOUND", bundleLocation);
-                    } else {
-                        LOGGER.info("CELLAR BUNDLE: sync is disabled for cluster group " + group.getName());
-                    }
+                            // broadcast the cluster event
+                            RemoteBundleEvent remoteBundleEvent = new RemoteBundleEvent(symbolicName, version, bundleLocation, type);
+                            remoteBundleEvent.setSourceGroup(group);
+                            eventProducer.produce(remoteBundleEvent);
+                        } finally {
+                            Thread.currentThread().setContextClassLoader(originalClassLoader);
+                        }
+
+                    } else LOGGER.warn("CELLAR BUNDLE: bundle {} is marked as BLOCKED OUTBOUND", bundleLocation);
                 }
             }
         }

Modified: karaf/cellar/branches/cellar-2.3.x/config/src/main/java/org/apache/karaf/cellar/config/ConfigurationSupport.java
URL: http://svn.apache.org/viewvc/karaf/cellar/branches/cellar-2.3.x/config/src/main/java/org/apache/karaf/cellar/config/ConfigurationSupport.java?rev=1413858&r1=1413857&r2=1413858&view=diff
==============================================================================
--- karaf/cellar/branches/cellar-2.3.x/config/src/main/java/org/apache/karaf/cellar/config/ConfigurationSupport.java (original)
+++ karaf/cellar/branches/cellar-2.3.x/config/src/main/java/org/apache/karaf/cellar/config/ConfigurationSupport.java Mon Nov 26 21:23:07 2012
@@ -14,8 +14,6 @@
 package org.apache.karaf.cellar.config;
 
 import org.apache.karaf.cellar.core.CellarSupport;
-import org.apache.karaf.cellar.core.Configurations;
-import org.apache.karaf.cellar.core.Group;
 import org.osgi.service.cm.Configuration;
 import org.osgi.service.cm.ConfigurationAdmin;
 
@@ -206,21 +204,4 @@ public class ConfigurationSupport extend
         this.storage = storage;
     }
 
-    public Boolean isSyncEnabled(Group group) {
-        Boolean result = Boolean.FALSE;
-        String groupName = group.getName();
-        try {
-            Configuration configuration = configurationAdmin.getConfiguration(Configurations.GROUP);
-            Dictionary<String, Object> properties = configuration.getProperties();
-            if (properties != null) {
-                String propertyKey = groupName + Configurations.SEPARATOR + Constants.CATEGORY + Configurations.SEPARATOR + Configurations.SYNC;
-                String propertyValue = (String) properties.get(propertyKey);
-                result = Boolean.parseBoolean(propertyValue);
-            }
-        } catch (IOException e) {
-            LOGGER.error("CELLAR CONFIG: failed to check if sync is enabled", e);
-        }
-        return result;
-    }
-
 }

Modified: karaf/cellar/branches/cellar-2.3.x/config/src/main/java/org/apache/karaf/cellar/config/ConfigurationSynchronizer.java
URL: http://svn.apache.org/viewvc/karaf/cellar/branches/cellar-2.3.x/config/src/main/java/org/apache/karaf/cellar/config/ConfigurationSynchronizer.java?rev=1413858&r1=1413857&r2=1413858&view=diff
==============================================================================
--- karaf/cellar/branches/cellar-2.3.x/config/src/main/java/org/apache/karaf/cellar/config/ConfigurationSynchronizer.java (original)
+++ karaf/cellar/branches/cellar-2.3.x/config/src/main/java/org/apache/karaf/cellar/config/ConfigurationSynchronizer.java Mon Nov 26 21:23:07 2012
@@ -26,6 +26,8 @@ import org.slf4j.LoggerFactory;
 
 import java.io.IOException;
 import java.util.Dictionary;
+import java.util.Enumeration;
+import java.util.List;
 import java.util.Map;
 import java.util.Properties;
 import java.util.Set;
@@ -153,6 +155,23 @@ public class ConfigurationSynchronizer e
         }
     }
 
+    public Boolean isSyncEnabled(Group group) {
+        Boolean result = Boolean.FALSE;
+        String groupName = group.getName();
+        try {
+            Configuration configuration = configurationAdmin.getConfiguration(Configurations.GROUP);
+            Dictionary<String, Object> properties = configuration.getProperties();
+            if (properties != null) {
+                String propertyKey = groupName + Configurations.SEPARATOR + Constants.CATEGORY + Configurations.SEPARATOR + Configurations.SYNC;
+                String propertyValue = (String) properties.get(propertyKey);
+                result = Boolean.parseBoolean(propertyValue);
+            }
+        } catch (IOException e) {
+            LOGGER.error("CELLAR CONFIG: failed to check if sync is enabled", e);
+        }
+        return result;
+    }
+
     public EventProducer getEventProducer() {
         return eventProducer;
     }

Modified: karaf/cellar/branches/cellar-2.3.x/config/src/main/java/org/apache/karaf/cellar/config/LocalConfigurationListener.java
URL: http://svn.apache.org/viewvc/karaf/cellar/branches/cellar-2.3.x/config/src/main/java/org/apache/karaf/cellar/config/LocalConfigurationListener.java?rev=1413858&r1=1413857&r2=1413858&view=diff
==============================================================================
--- karaf/cellar/branches/cellar-2.3.x/config/src/main/java/org/apache/karaf/cellar/config/LocalConfigurationListener.java (original)
+++ karaf/cellar/branches/cellar-2.3.x/config/src/main/java/org/apache/karaf/cellar/config/LocalConfigurationListener.java Mon Nov 26 21:23:07 2012
@@ -15,15 +15,18 @@ package org.apache.karaf.cellar.config;
 
 import org.apache.karaf.cellar.core.Configurations;
 import org.apache.karaf.cellar.core.Group;
+import org.apache.karaf.cellar.core.Node;
 import org.apache.karaf.cellar.core.control.SwitchStatus;
 import org.apache.karaf.cellar.core.event.EventProducer;
 import org.apache.karaf.cellar.core.event.EventType;
+import org.osgi.framework.InvalidSyntaxException;
 import org.osgi.service.cm.Configuration;
 import org.osgi.service.cm.ConfigurationEvent;
 import org.osgi.service.cm.ConfigurationListener;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import java.io.IOException;
 import java.util.Dictionary;
 import java.util.Map;
 import java.util.Properties;
@@ -69,48 +72,42 @@ public class LocalConfigurationListener 
 
         if (groups != null && !groups.isEmpty()) {
             for (Group group : groups) {
+                // check if the pid is allowed for outbound.
+                if (isAllowed(group, Constants.CATEGORY, pid, EventType.OUTBOUND)) {
 
-                if (isSyncEnabled(group)) {
+                    // update the distributed map if needed
+                    Map<String, Properties> distributedConfigurations = clusterManager.getMap(Constants.CONFIGURATION_MAP + Configurations.SEPARATOR + group.getName());
 
-                    // check if the pid is allowed for outbound.
-                    if (isAllowed(group, Constants.CATEGORY, pid, EventType.OUTBOUND)) {
+                    // broadcast the cluster event
+                    try {
+                        if (event.getType() == ConfigurationEvent.CM_DELETED) {
+                            // update the distributed map
+                            distributedConfigurations.remove(pid);
+                            // broadcast the cluster event
+                            RemoteConfigurationEvent remoteConfigurationEvent = new RemoteConfigurationEvent(pid);
+                            remoteConfigurationEvent.setType(ConfigurationEvent.CM_DELETED);
+                            remoteConfigurationEvent.setSourceNode(clusterManager.getNode());
+                            remoteConfigurationEvent.setSourceGroup(group);
+                            eventProducer.produce(remoteConfigurationEvent);
+                        } else {
+                            localDictionary = filter(localDictionary);
 
-                        // update the distributed map if needed
-                        Map<String, Properties> distributedConfigurations = clusterManager.getMap(Constants.CONFIGURATION_MAP + Configurations.SEPARATOR + group.getName());
+                            Properties distributedDictionary = distributedConfigurations.get(pid);
 
-                        // broadcast the cluster event
-                        try {
-                            if (event.getType() == ConfigurationEvent.CM_DELETED) {
+                            if (!equals(localDictionary, distributedDictionary)) {
                                 // update the distributed map
-                                distributedConfigurations.remove(pid);
+                                distributedConfigurations.put(pid, dictionaryToProperties(localDictionary));
                                 // broadcast the cluster event
                                 RemoteConfigurationEvent remoteConfigurationEvent = new RemoteConfigurationEvent(pid);
-                                remoteConfigurationEvent.setType(ConfigurationEvent.CM_DELETED);
-                                remoteConfigurationEvent.setSourceNode(clusterManager.getNode());
                                 remoteConfigurationEvent.setSourceGroup(group);
+                                remoteConfigurationEvent.setSourceNode(clusterManager.getNode());
                                 eventProducer.produce(remoteConfigurationEvent);
-                            } else {
-                                localDictionary = filter(localDictionary);
-
-                                Properties distributedDictionary = distributedConfigurations.get(pid);
-
-                                if (!equals(localDictionary, distributedDictionary)) {
-                                    // update the distributed map
-                                    distributedConfigurations.put(pid, dictionaryToProperties(localDictionary));
-                                    // broadcast the cluster event
-                                    RemoteConfigurationEvent remoteConfigurationEvent = new RemoteConfigurationEvent(pid);
-                                    remoteConfigurationEvent.setSourceGroup(group);
-                                    remoteConfigurationEvent.setSourceNode(clusterManager.getNode());
-                                    eventProducer.produce(remoteConfigurationEvent);
-                                }
                             }
-                        } catch (Exception e) {
-                            LOGGER.error("CELLAR CONFIG: failed to push configuration with PID {} to the distributed map", pid, e);
                         }
-                    } else LOGGER.warn("CELLAR CONFIG: configuration with PID {} is marked as BLOCKED OUTBOUND", pid);
-                } else {
-                    LOGGER.info("CELLAR CONFIG: sync is disabled for cluster group " + group.getName());
-                }
+                    } catch (Exception e) {
+                        LOGGER.error("CELLAR CONFIG: failed to push configuration with PID {} to the distributed map", pid, e);
+                    }
+                } else LOGGER.warn("CELLAR CONFIG: configuration with PID {} is marked as BLOCKED OUTBOUND", pid);
             }
         }
     }

Modified: karaf/cellar/branches/cellar-2.3.x/features/src/main/java/org/apache/karaf/cellar/features/FeaturesSupport.java
URL: http://svn.apache.org/viewvc/karaf/cellar/branches/cellar-2.3.x/features/src/main/java/org/apache/karaf/cellar/features/FeaturesSupport.java?rev=1413858&r1=1413857&r2=1413858&view=diff
==============================================================================
--- karaf/cellar/branches/cellar-2.3.x/features/src/main/java/org/apache/karaf/cellar/features/FeaturesSupport.java (original)
+++ karaf/cellar/branches/cellar-2.3.x/features/src/main/java/org/apache/karaf/cellar/features/FeaturesSupport.java Mon Nov 26 21:23:07 2012
@@ -20,13 +20,10 @@ import org.apache.karaf.cellar.core.even
 import org.apache.karaf.features.Feature;
 import org.apache.karaf.features.FeaturesService;
 import org.apache.karaf.features.Repository;
-import org.osgi.service.cm.Configuration;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import java.io.IOException;
 import java.net.URI;
-import java.util.Dictionary;
 import java.util.List;
 import java.util.Map;
 
@@ -149,25 +146,6 @@ public class FeaturesSupport extends Cel
             repositories.remove(uri.toString());
         }
     }
-
-    public Boolean isSyncEnabled(Group group) {
-        Boolean result = Boolean.FALSE;
-        String groupName = group.getName();
-
-        try {
-            Configuration configuration = configurationAdmin.getConfiguration(Configurations.GROUP);
-            Dictionary<String, Object> properties = configuration.getProperties();
-            if (properties != null) {
-                String propertyKey = groupName + Configurations.SEPARATOR + Constants.FEATURES_CATEGORY + Configurations.SEPARATOR + Configurations.SYNC;
-                String propertyValue = (String) properties.get(propertyKey);
-                result = Boolean.parseBoolean(propertyValue);
-            }
-        } catch (IOException e) {
-            LOGGER.warn("CELLAR FEATURES: error while checking if sync is enabled", e);
-        }
-        return result;
-    }
-
     public FeaturesService getFeaturesService() {
         return featuresService;
     }

Modified: karaf/cellar/branches/cellar-2.3.x/features/src/main/java/org/apache/karaf/cellar/features/FeaturesSynchronizer.java
URL: http://svn.apache.org/viewvc/karaf/cellar/branches/cellar-2.3.x/features/src/main/java/org/apache/karaf/cellar/features/FeaturesSynchronizer.java?rev=1413858&r1=1413857&r2=1413858&view=diff
==============================================================================
--- karaf/cellar/branches/cellar-2.3.x/features/src/main/java/org/apache/karaf/cellar/features/FeaturesSynchronizer.java (original)
+++ karaf/cellar/branches/cellar-2.3.x/features/src/main/java/org/apache/karaf/cellar/features/FeaturesSynchronizer.java Mon Nov 26 21:23:07 2012
@@ -17,15 +17,19 @@ import org.apache.karaf.cellar.core.Clus
 import org.apache.karaf.cellar.core.Configurations;
 import org.apache.karaf.cellar.core.Group;
 import org.apache.karaf.cellar.core.Synchronizer;
+import org.apache.karaf.cellar.core.event.EventProducer;
 import org.apache.karaf.cellar.core.event.EventType;
 import org.apache.karaf.features.Feature;
 import org.apache.karaf.features.FeaturesService;
 import org.apache.karaf.features.Repository;
+import org.osgi.service.cm.Configuration;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import java.io.IOException;
 import java.net.MalformedURLException;
 import java.net.URI;
+import java.util.Dictionary;
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
@@ -166,6 +170,25 @@ public class FeaturesSynchronizer extend
             }
         }
     }
+
+    public Boolean isSyncEnabled(Group group) {
+        Boolean result = Boolean.FALSE;
+        String groupName = group.getName();
+
+        try {
+            Configuration configuration = configurationAdmin.getConfiguration(Configurations.GROUP);
+            Dictionary<String, Object> properties = configuration.getProperties();
+            if (properties != null) {
+                String propertyKey = groupName + Configurations.SEPARATOR + Constants.FEATURES_CATEGORY + Configurations.SEPARATOR + Configurations.SYNC;
+                String propertyValue = (String) properties.get(propertyKey);
+                result = Boolean.parseBoolean(propertyValue);
+            }
+        } catch (IOException e) {
+            LOGGER.warn("CELLAR FEATURES: error while checking if sync is enabled", e);
+        }
+        return result;
+    }
+
     public ClusterManager getCollectionManager() {
         return clusterManager;
     }

Modified: karaf/cellar/branches/cellar-2.3.x/features/src/main/java/org/apache/karaf/cellar/features/LocalFeaturesListener.java
URL: http://svn.apache.org/viewvc/karaf/cellar/branches/cellar-2.3.x/features/src/main/java/org/apache/karaf/cellar/features/LocalFeaturesListener.java?rev=1413858&r1=1413857&r2=1413858&view=diff
==============================================================================
--- karaf/cellar/branches/cellar-2.3.x/features/src/main/java/org/apache/karaf/cellar/features/LocalFeaturesListener.java (original)
+++ karaf/cellar/branches/cellar-2.3.x/features/src/main/java/org/apache/karaf/cellar/features/LocalFeaturesListener.java Mon Nov 26 21:23:07 2012
@@ -15,6 +15,7 @@ package org.apache.karaf.cellar.features
 
 import org.apache.karaf.cellar.core.Configurations;
 import org.apache.karaf.cellar.core.Group;
+import org.apache.karaf.cellar.core.Node;
 import org.apache.karaf.cellar.core.control.SwitchStatus;
 import org.apache.karaf.cellar.core.event.EventProducer;
 import org.apache.karaf.cellar.core.event.EventType;
@@ -24,6 +25,7 @@ import org.apache.karaf.features.Reposit
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import java.util.List;
 import java.util.Map;
 import java.util.Set;
 
@@ -65,30 +67,25 @@ public class LocalFeaturesListener exten
             if (groups != null && !groups.isEmpty()) {
                 for (Group group : groups) {
 
-                    if (isSyncEnabled(group)) {
-
-                        Feature feature = event.getFeature();
-                        String name = feature.getName();
-                        String version = feature.getVersion();
-
-                        if (isAllowed(group, Constants.FEATURES_CATEGORY, name, EventType.OUTBOUND)) {
-                            FeatureEvent.EventType type = event.getType();
-
-                            // update the distributed map
-                            if (FeatureEvent.EventType.FeatureInstalled.equals(event.getType())) {
-                                pushFeature(event.getFeature(), group, true);
-                            } else {
-                                pushFeature(event.getFeature(), group, false);
-                            }
+                    Feature feature = event.getFeature();
+                    String name = feature.getName();
+                    String version = feature.getVersion();
+
+                    if (isAllowed(group, Constants.FEATURES_CATEGORY, name, EventType.OUTBOUND)) {
+                        FeatureEvent.EventType type = event.getType();
+
+                        // update the distributed map
+                        if (FeatureEvent.EventType.FeatureInstalled.equals(event.getType())) {
+                            pushFeature(event.getFeature(), group, true);
+                        } else {
+                            pushFeature(event.getFeature(), group, false);
+                        }
 
-                            // broadcast the cluster event
-                            RemoteFeaturesEvent featureEvent = new RemoteFeaturesEvent(name, version, type);
-                            featureEvent.setSourceGroup(group);
-                            eventProducer.produce(featureEvent);
-                        } else LOGGER.warn("CELLAR FEATURES: feature {} is marked as BLOCKED OUTBOUND", name);
-                    } else {
-                        LOGGER.info("CELLAR FEATURES: sync is disabled for cluster group " + group.getName());
-                    }
+                        // broadcast the cluster event
+                        RemoteFeaturesEvent featureEvent = new RemoteFeaturesEvent(name, version, type);
+                        featureEvent.setSourceGroup(group);
+                        eventProducer.produce(featureEvent);
+                    } else LOGGER.warn("CELLAR FEATURES: feature {} is marked as BLOCKED OUTBOUND", name);
                 }
             }
         }
@@ -115,55 +112,49 @@ public class LocalFeaturesListener exten
 
                 if (groups != null && !groups.isEmpty()) {
                     for (Group group : groups) {
-
-                        if (isSyncEnabled(group)) {
-
-                            RemoteRepositoryEvent repositoryEvent = new RemoteRepositoryEvent(event.getRepository().getURI().toString(), event.getType());
-                            repositoryEvent.setSourceGroup(group);
-                            RepositoryEvent.EventType type = event.getType();
-
-                            // update the distributed map
-                            if (RepositoryEvent.EventType.RepositoryAdded.equals(type)) {
-                                pushRepository(event.getRepository(), group);
-                                // update the feature map
-                                Map<FeatureInfo, Boolean> distributedFeatures = clusterManager.getMap(Constants.FEATURES + Configurations.SEPARATOR + group.getName());
-                                try {
-                                    for (Feature feature : event.getRepository().getFeatures()) {
-                                        // check the feature in the distributed map
-                                        FeatureInfo featureInfo = null;
-                                        for (FeatureInfo distributedFeature : distributedFeatures.keySet()) {
-                                            if (distributedFeature.getName().equals(feature.getName()) && distributedFeature.getVersion().equals(feature.getVersion())) {
-                                                featureInfo = distributedFeature;
-                                                break;
-                                            }
-                                        }
-                                        if (featureInfo == null) {
-                                            featureInfo = new FeatureInfo(feature.getName(), feature.getVersion());
-                                            distributedFeatures.put(featureInfo, false);
+                        RemoteRepositoryEvent repositoryEvent = new RemoteRepositoryEvent(event.getRepository().getURI().toString(), event.getType());
+                        repositoryEvent.setSourceGroup(group);
+                        RepositoryEvent.EventType type = event.getType();
+
+                        // update the distributed map
+                        if (RepositoryEvent.EventType.RepositoryAdded.equals(type)) {
+                            pushRepository(event.getRepository(), group);
+                            // update the feature map
+                            Map<FeatureInfo, Boolean> distributedFeatures = clusterManager.getMap(Constants.FEATURES + Configurations.SEPARATOR + group.getName());
+                            try {
+                                for (Feature feature : event.getRepository().getFeatures()) {
+                                    // check the feature in the distributed map
+                                    FeatureInfo featureInfo = null;
+                                    for (FeatureInfo distributedFeature : distributedFeatures.keySet()) {
+                                        if (distributedFeature.getName().equals(feature.getName()) && distributedFeature.getVersion().equals(feature.getVersion())) {
+                                            featureInfo = distributedFeature;
+                                            break;
                                         }
                                     }
-                                } catch (Exception e) {
-                                    LOGGER.warn("CELLAR FEATURES: can't update the distributed features map", e);
-                                }
-                            } else {
-                                removeRepository(event.getRepository(), group);
-                                // update the feature map
-                                Map<FeatureInfo, Boolean> distributedFeatures = clusterManager.getMap(Constants.FEATURES + Configurations.SEPARATOR + group.getName());
-                                try {
-                                    for (Feature feature : event.getRepository().getFeatures()) {
-                                        FeatureInfo info = new FeatureInfo(feature.getName(), feature.getVersion());
-                                        distributedFeatures.remove(info);
+                                    if (featureInfo == null) {
+                                        featureInfo = new FeatureInfo(feature.getName(), feature.getVersion());
+                                        distributedFeatures.put(featureInfo, false);
                                     }
-                                } catch (Exception e) {
-                                    LOGGER.warn("CELLAR FEATURES: can't update the distributed features map", e);
                                 }
+                            } catch (Exception e) {
+                                LOGGER.warn("CELLAR FEATURES: can't update the distributed features map", e);
                             }
-
-                            // broadcast the cluster event
-                            eventProducer.produce(repositoryEvent);
                         } else {
-                            LOGGER.info("CELLAR FEATURES: sync is disabled for cluster group " + group.getName());
+                            removeRepository(event.getRepository(), group);
+                            // update the feature map
+                            Map<FeatureInfo, Boolean> distributedFeatures = clusterManager.getMap(Constants.FEATURES + Configurations.SEPARATOR + group.getName());
+                            try {
+                                for (Feature feature : event.getRepository().getFeatures()) {
+                                    FeatureInfo info = new FeatureInfo(feature.getName(), feature.getVersion());
+                                    distributedFeatures.remove(info);
+                                }
+                            } catch (Exception e) {
+                                LOGGER.warn("CELLAR FEATURES: can't update the distributed features map", e);
+                            }
                         }
+
+                        // broadcast the cluster event
+                        eventProducer.produce(repositoryEvent);
                     }
                 }
             }