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/04/29 21:43:24 UTC

svn commit: r1331983 - in /karaf/cellar/branches/cellar-2.2.x: bundle/src/main/java/org/apache/karaf/cellar/bundle/ bundle/src/main/java/org/apache/karaf/cellar/bundle/shell/ bundle/src/main/resources/OSGI-INF/blueprint/ core/src/main/java/org/apache/k...

Author: jbonofre
Date: Sun Apr 29 19:43:21 2012
New Revision: 1331983

URL: http://svn.apache.org/viewvc?rev=1331983&view=rev
Log:
[KARAF-1239] Use an EventProducer and check the producer switch status

Modified:
    karaf/cellar/branches/cellar-2.2.x/bundle/src/main/java/org/apache/karaf/cellar/bundle/BundleSynchronizer.java
    karaf/cellar/branches/cellar-2.2.x/bundle/src/main/java/org/apache/karaf/cellar/bundle/LocalBundleListener.java
    karaf/cellar/branches/cellar-2.2.x/bundle/src/main/java/org/apache/karaf/cellar/bundle/shell/InstallBundleCommand.java
    karaf/cellar/branches/cellar-2.2.x/bundle/src/main/java/org/apache/karaf/cellar/bundle/shell/ListBundleCommand.java
    karaf/cellar/branches/cellar-2.2.x/bundle/src/main/java/org/apache/karaf/cellar/bundle/shell/StartBundleCommand.java
    karaf/cellar/branches/cellar-2.2.x/bundle/src/main/java/org/apache/karaf/cellar/bundle/shell/StopBundleCommand.java
    karaf/cellar/branches/cellar-2.2.x/bundle/src/main/java/org/apache/karaf/cellar/bundle/shell/UninstallBundleCommand.java
    karaf/cellar/branches/cellar-2.2.x/bundle/src/main/resources/OSGI-INF/blueprint/shell-bundle.xml
    karaf/cellar/branches/cellar-2.2.x/core/src/main/java/org/apache/karaf/cellar/core/control/ProducerSwitchCommandHandler.java
    karaf/cellar/branches/cellar-2.2.x/core/src/main/java/org/apache/karaf/cellar/core/shell/CellarCommandSupport.java
    karaf/cellar/branches/cellar-2.2.x/dosgi/src/main/resources/OSGI-INF/blueprint/shell-dosgi.xml
    karaf/cellar/branches/cellar-2.2.x/features/src/main/java/org/apache/karaf/cellar/features/shell/InstallFeatureCommand.java
    karaf/cellar/branches/cellar-2.2.x/features/src/main/java/org/apache/karaf/cellar/features/shell/UninstallFeatureCommand.java
    karaf/cellar/branches/cellar-2.2.x/features/src/main/resources/OSGI-INF/blueprint/shell-features.xml
    karaf/cellar/branches/cellar-2.2.x/management/src/main/java/org/apache/karaf/cellar/management/internal/CellarBundleMBeanImpl.java
    karaf/cellar/branches/cellar-2.2.x/management/src/main/java/org/apache/karaf/cellar/management/internal/CellarFeaturesMBeanImpl.java
    karaf/cellar/branches/cellar-2.2.x/management/src/main/resources/OSGI-INF/blueprint/blueprint.xml
    karaf/cellar/branches/cellar-2.2.x/obr/src/main/java/org/apache/karaf/cellar/obr/shell/ObrAddUrlCommand.java
    karaf/cellar/branches/cellar-2.2.x/obr/src/main/java/org/apache/karaf/cellar/obr/shell/ObrDeployCommand.java
    karaf/cellar/branches/cellar-2.2.x/obr/src/main/java/org/apache/karaf/cellar/obr/shell/ObrListCommand.java
    karaf/cellar/branches/cellar-2.2.x/obr/src/main/java/org/apache/karaf/cellar/obr/shell/ObrListUrlCommand.java
    karaf/cellar/branches/cellar-2.2.x/obr/src/main/java/org/apache/karaf/cellar/obr/shell/ObrRemoveUrlCommand.java
    karaf/cellar/branches/cellar-2.2.x/obr/src/main/resources/OSGI-INF/blueprint/shell-commands.xml

Modified: karaf/cellar/branches/cellar-2.2.x/bundle/src/main/java/org/apache/karaf/cellar/bundle/BundleSynchronizer.java
URL: http://svn.apache.org/viewvc/karaf/cellar/branches/cellar-2.2.x/bundle/src/main/java/org/apache/karaf/cellar/bundle/BundleSynchronizer.java?rev=1331983&r1=1331982&r2=1331983&view=diff
==============================================================================
--- karaf/cellar/branches/cellar-2.2.x/bundle/src/main/java/org/apache/karaf/cellar/bundle/BundleSynchronizer.java (original)
+++ karaf/cellar/branches/cellar-2.2.x/bundle/src/main/java/org/apache/karaf/cellar/bundle/BundleSynchronizer.java Sun Apr 29 19:43:21 2012
@@ -133,6 +133,7 @@ public class BundleSynchronizer extends 
                     }
 
                     // broadcast the event
+                    // TODO use the local producer and check its status
                     if (producerList != null && !producerList.isEmpty() && event != null) {
                         for (EventProducer producer : producerList) {
                             producer.produce(event);

Modified: karaf/cellar/branches/cellar-2.2.x/bundle/src/main/java/org/apache/karaf/cellar/bundle/LocalBundleListener.java
URL: http://svn.apache.org/viewvc/karaf/cellar/branches/cellar-2.2.x/bundle/src/main/java/org/apache/karaf/cellar/bundle/LocalBundleListener.java?rev=1331983&r1=1331982&r2=1331983&view=diff
==============================================================================
--- karaf/cellar/branches/cellar-2.2.x/bundle/src/main/java/org/apache/karaf/cellar/bundle/LocalBundleListener.java (original)
+++ karaf/cellar/branches/cellar-2.2.x/bundle/src/main/java/org/apache/karaf/cellar/bundle/LocalBundleListener.java Sun Apr 29 19:43:21 2012
@@ -73,6 +73,7 @@ public class LocalBundleListener extends
                             bundles.put(symbolicName + "/" + version, state);
 
                             // broadcast the cluster event
+                            // TODO use the local producer and check its status
                             if (producerList != null && !producerList.isEmpty()) {
                                 for (EventProducer producer : producerList) {
                                     producer.produce(remoteBundleEvent);

Modified: karaf/cellar/branches/cellar-2.2.x/bundle/src/main/java/org/apache/karaf/cellar/bundle/shell/InstallBundleCommand.java
URL: http://svn.apache.org/viewvc/karaf/cellar/branches/cellar-2.2.x/bundle/src/main/java/org/apache/karaf/cellar/bundle/shell/InstallBundleCommand.java?rev=1331983&r1=1331982&r2=1331983&view=diff
==============================================================================
--- karaf/cellar/branches/cellar-2.2.x/bundle/src/main/java/org/apache/karaf/cellar/bundle/shell/InstallBundleCommand.java (original)
+++ karaf/cellar/branches/cellar-2.2.x/bundle/src/main/java/org/apache/karaf/cellar/bundle/shell/InstallBundleCommand.java Sun Apr 29 19:43:21 2012
@@ -20,6 +20,7 @@ import org.apache.karaf.cellar.bundle.Co
 import org.apache.karaf.cellar.bundle.RemoteBundleEvent;
 import org.apache.karaf.cellar.core.Configurations;
 import org.apache.karaf.cellar.core.Group;
+import org.apache.karaf.cellar.core.control.SwitchStatus;
 import org.apache.karaf.cellar.core.event.EventProducer;
 import org.apache.karaf.cellar.core.shell.CellarCommandSupport;
 import org.osgi.framework.BundleEvent;
@@ -38,14 +39,23 @@ public class InstallBundleCommand extend
     @Argument(index = 1, name = "location", description = "The bundle location.", required = true, multiValued = false)
     String location;
 
+    private EventProducer eventProducer;
+
     @Override
     protected Object doExecute() throws Exception {
+        // check if the group exists
         Group group = groupManager.findGroupByName(groupName);
         if (group == null) {
             System.err.println("Cluster group " + groupName + " doesn't exist");
             return null;
         }
 
+        // check if the producer is started
+        if (eventProducer.getSwitch().getStatus().equals(SwitchStatus.OFF)) {
+            System.err.println("Cluster event producer is OFF for this node");
+            return null;
+        }
+
         // get the name and version in the location MANIFEST
         JarInputStream jarInputStream = new JarInputStream(new URL(location).openStream());
         Manifest manifest = jarInputStream.getManifest();
@@ -61,12 +71,19 @@ public class InstallBundleCommand extend
         bundles.put(name + "/" + version, state);
         
         // broadcast the cluster event
-        EventProducer producer = eventTransportFactory.getEventProducer(groupName, true);
         RemoteBundleEvent event = new RemoteBundleEvent(name, version, location, BundleEvent.INSTALLED);
         event.setSourceGroup(group);
-        producer.produce(event);
+        eventProducer.produce(event);
 
         return null;
     }
 
+    public EventProducer getEventProducer() {
+        return eventProducer;
+    }
+
+    public void setEventProducer(EventProducer eventProducer) {
+        this.eventProducer = eventProducer;
+    }
+
 }

Modified: karaf/cellar/branches/cellar-2.2.x/bundle/src/main/java/org/apache/karaf/cellar/bundle/shell/ListBundleCommand.java
URL: http://svn.apache.org/viewvc/karaf/cellar/branches/cellar-2.2.x/bundle/src/main/java/org/apache/karaf/cellar/bundle/shell/ListBundleCommand.java?rev=1331983&r1=1331982&r2=1331983&view=diff
==============================================================================
--- karaf/cellar/branches/cellar-2.2.x/bundle/src/main/java/org/apache/karaf/cellar/bundle/shell/ListBundleCommand.java (original)
+++ karaf/cellar/branches/cellar-2.2.x/bundle/src/main/java/org/apache/karaf/cellar/bundle/shell/ListBundleCommand.java Sun Apr 29 19:43:21 2012
@@ -34,6 +34,7 @@ public class ListBundleCommand extends C
 
     @Override
     protected Object doExecute() throws Exception {
+        // check if the group exists
         Group group = groupManager.findGroupByName(groupName);
         if (group == null) {
             System.err.println("Cluster group " + groupName + " doesn't exist.");

Modified: karaf/cellar/branches/cellar-2.2.x/bundle/src/main/java/org/apache/karaf/cellar/bundle/shell/StartBundleCommand.java
URL: http://svn.apache.org/viewvc/karaf/cellar/branches/cellar-2.2.x/bundle/src/main/java/org/apache/karaf/cellar/bundle/shell/StartBundleCommand.java?rev=1331983&r1=1331982&r2=1331983&view=diff
==============================================================================
--- karaf/cellar/branches/cellar-2.2.x/bundle/src/main/java/org/apache/karaf/cellar/bundle/shell/StartBundleCommand.java (original)
+++ karaf/cellar/branches/cellar-2.2.x/bundle/src/main/java/org/apache/karaf/cellar/bundle/shell/StartBundleCommand.java Sun Apr 29 19:43:21 2012
@@ -20,6 +20,7 @@ import org.apache.karaf.cellar.bundle.Co
 import org.apache.karaf.cellar.bundle.RemoteBundleEvent;
 import org.apache.karaf.cellar.core.Configurations;
 import org.apache.karaf.cellar.core.Group;
+import org.apache.karaf.cellar.core.control.SwitchStatus;
 import org.apache.karaf.cellar.core.event.EventProducer;
 import org.apache.karaf.cellar.core.shell.CellarCommandSupport;
 import org.osgi.framework.BundleEvent;
@@ -38,11 +39,20 @@ public class StartBundleCommand extends 
     @Argument(index = 2, name = "version", description = "The bundle version.", required = true, multiValued = false)
     String version;
 
+    private EventProducer eventProducer;
+
     @Override
     protected Object doExecute() throws Exception {
+        // check if the cluster group exists
         Group group = groupManager.findGroupByName(groupName);
         if (group == null) {
-            System.err.println("Group " + groupName + " doesn't exist");
+            System.err.println("Cluster group " + groupName + " doesn't exist");
+            return null;
+        }
+
+        // check if the producer is ON
+        if (eventProducer.getSwitch().getStatus().equals(SwitchStatus.OFF)) {
+            System.err.println("Cluster event producer is OFF for this node");
             return null;
         }
 
@@ -65,12 +75,19 @@ public class StartBundleCommand extends 
         }
 
         // broadcast the cluster event
-        EventProducer producer = eventTransportFactory.getEventProducer(groupName, true);
         RemoteBundleEvent event = new RemoteBundleEvent(name, version, location, BundleEvent.STARTED);
         event.setSourceGroup(group);
-        producer.produce(event);
+        eventProducer.produce(event);
 
         return null;
     }
 
+    public EventProducer getEventProducer() {
+        return eventProducer;
+    }
+
+    public void setEventProducer(EventProducer eventProducer) {
+        this.eventProducer = eventProducer;
+    }
+
 }

Modified: karaf/cellar/branches/cellar-2.2.x/bundle/src/main/java/org/apache/karaf/cellar/bundle/shell/StopBundleCommand.java
URL: http://svn.apache.org/viewvc/karaf/cellar/branches/cellar-2.2.x/bundle/src/main/java/org/apache/karaf/cellar/bundle/shell/StopBundleCommand.java?rev=1331983&r1=1331982&r2=1331983&view=diff
==============================================================================
--- karaf/cellar/branches/cellar-2.2.x/bundle/src/main/java/org/apache/karaf/cellar/bundle/shell/StopBundleCommand.java (original)
+++ karaf/cellar/branches/cellar-2.2.x/bundle/src/main/java/org/apache/karaf/cellar/bundle/shell/StopBundleCommand.java Sun Apr 29 19:43:21 2012
@@ -20,6 +20,7 @@ import org.apache.karaf.cellar.bundle.Co
 import org.apache.karaf.cellar.bundle.RemoteBundleEvent;
 import org.apache.karaf.cellar.core.Configurations;
 import org.apache.karaf.cellar.core.Group;
+import org.apache.karaf.cellar.core.control.SwitchStatus;
 import org.apache.karaf.cellar.core.event.EventProducer;
 import org.apache.karaf.cellar.core.shell.CellarCommandSupport;
 import org.osgi.framework.BundleEvent;
@@ -38,11 +39,20 @@ public class StopBundleCommand extends C
     @Argument(index = 2, name = "version", description = "The bundle version.", required = true, multiValued = false)
     String version;
 
+    private EventProducer eventProducer;
+
     @Override
     protected Object doExecute() throws Exception {
+        // check if the cluster group exists
         Group group = groupManager.findGroupByName(groupName);
         if (group == null) {
-            System.err.println("Cluster group " + groupName + " doesn't exist.");
+            System.err.println("Cluster group " + groupName + " doesn't exist");
+            return null;
+        }
+
+        // check if the producer is ON
+        if (eventProducer.getSwitch().getStatus().equals(SwitchStatus.OFF)) {
+            System.err.println("Cluster event producer is OFF for this node");
             return null;
         }
 
@@ -65,12 +75,19 @@ public class StopBundleCommand extends C
         }
 
         // broadcast the cluster event
-        EventProducer producer = eventTransportFactory.getEventProducer(groupName, true);
         RemoteBundleEvent event = new RemoteBundleEvent(name, version, location, BundleEvent.STOPPED);
         event.setSourceGroup(group);
-        producer.produce(event);
+        eventProducer.produce(event);
 
         return null;
     }
 
+    public EventProducer getEventProducer() {
+        return eventProducer;
+    }
+
+    public void setEventProducer(EventProducer eventProducer) {
+        this.eventProducer = eventProducer;
+    }
+
 }

Modified: karaf/cellar/branches/cellar-2.2.x/bundle/src/main/java/org/apache/karaf/cellar/bundle/shell/UninstallBundleCommand.java
URL: http://svn.apache.org/viewvc/karaf/cellar/branches/cellar-2.2.x/bundle/src/main/java/org/apache/karaf/cellar/bundle/shell/UninstallBundleCommand.java?rev=1331983&r1=1331982&r2=1331983&view=diff
==============================================================================
--- karaf/cellar/branches/cellar-2.2.x/bundle/src/main/java/org/apache/karaf/cellar/bundle/shell/UninstallBundleCommand.java (original)
+++ karaf/cellar/branches/cellar-2.2.x/bundle/src/main/java/org/apache/karaf/cellar/bundle/shell/UninstallBundleCommand.java Sun Apr 29 19:43:21 2012
@@ -20,6 +20,7 @@ import org.apache.karaf.cellar.bundle.Co
 import org.apache.karaf.cellar.bundle.RemoteBundleEvent;
 import org.apache.karaf.cellar.core.Configurations;
 import org.apache.karaf.cellar.core.Group;
+import org.apache.karaf.cellar.core.control.SwitchStatus;
 import org.apache.karaf.cellar.core.event.EventProducer;
 import org.apache.karaf.cellar.core.shell.CellarCommandSupport;
 import org.osgi.framework.BundleEvent;
@@ -38,14 +39,23 @@ public class UninstallBundleCommand exte
     @Argument(index = 2, name = "version", description = "The bundle version.", required = true, multiValued = false)
     String version;
 
+    private EventProducer eventProducer;
+
     @Override
     protected Object doExecute() throws Exception {
+        // check if cluster group exists
         Group group = groupManager.findGroupByName(groupName);
         if (group == null) {
             System.err.println("Cluster group " + groupName + " doesn't exist");
             return null;
         }
 
+        // check if the producer is ON
+        if (eventProducer.getSwitch().getStatus().equals(SwitchStatus.OFF)) {
+            System.err.println("Cluster event producer is OFF for this node");
+            return null;
+        }
+
         // update the cluster map
         ClassLoader originalClassLoader = Thread.currentThread().getContextClassLoader();
         Thread.currentThread().setContextClassLoader(getClass().getClassLoader());
@@ -64,12 +74,19 @@ public class UninstallBundleCommand exte
         }
 
         // broadcast the cluster event
-        EventProducer producer = eventTransportFactory.getEventProducer(groupName, true);
         RemoteBundleEvent event = new RemoteBundleEvent(name, version, location, BundleEvent.UNINSTALLED);
         event.setSourceGroup(group);
-        producer.produce(event);
+        eventProducer.produce(event);
 
         return null;
     }
 
+    public EventProducer getEventProducer() {
+        return eventProducer;
+    }
+
+    public void setEventProducer(EventProducer eventProducer) {
+        this.eventProducer = eventProducer;
+    }
+
 }

Modified: karaf/cellar/branches/cellar-2.2.x/bundle/src/main/resources/OSGI-INF/blueprint/shell-bundle.xml
URL: http://svn.apache.org/viewvc/karaf/cellar/branches/cellar-2.2.x/bundle/src/main/resources/OSGI-INF/blueprint/shell-bundle.xml?rev=1331983&r1=1331982&r2=1331983&view=diff
==============================================================================
--- karaf/cellar/branches/cellar-2.2.x/bundle/src/main/resources/OSGI-INF/blueprint/shell-bundle.xml (original)
+++ karaf/cellar/branches/cellar-2.2.x/bundle/src/main/resources/OSGI-INF/blueprint/shell-bundle.xml Sun Apr 29 19:43:21 2012
@@ -19,7 +19,6 @@
             <action class="org.apache.karaf.cellar.bundle.shell.ListBundleCommand">
                 <property name="clusterManager" ref="clusterManager"/>
                 <property name="groupManager" ref="groupManager"/>
-                <property name="eventTransportFactory" ref="eventTransportFactory"/>
             </action>
             <completers>
                 <ref component-id="allGroupCompleter"/>
@@ -29,7 +28,7 @@
             <action class="org.apache.karaf.cellar.bundle.shell.InstallBundleCommand">
                 <property name="clusterManager" ref="clusterManager"/>
                 <property name="groupManager" ref="groupManager"/>
-                <property name="eventTransportFactory" ref="eventTransportFactory"/>
+                <property name="eventProducer" ref="eventProducer"/>
             </action>
             <completers>
                 <ref component-id="allGroupCompleter"/>
@@ -39,7 +38,7 @@
             <action class="org.apache.karaf.cellar.bundle.shell.UninstallBundleCommand">
                 <property name="clusterManager" ref="clusterManager"/>
                 <property name="groupManager" ref="groupManager"/>
-                <property name="eventTransportFactory" ref="eventTransportFactory"/>
+                <property name="eventProducer" ref="eventProducer"/>
             </action>
             <completers>
                 <ref component-id="allGroupCompleter"/>
@@ -51,7 +50,7 @@
             <action class="org.apache.karaf.cellar.bundle.shell.StartBundleCommand">
                 <property name="clusterManager" ref="clusterManager"/>
                 <property name="groupManager" ref="groupManager"/>
-                <property name="eventTransportFactory" ref="eventTransportFactory"/>
+                <property name="eventProducer" ref="eventProducer"/>
             </action>
             <completers>
                 <ref component-id="allGroupCompleter"/>
@@ -63,7 +62,7 @@
             <action class="org.apache.karaf.cellar.bundle.shell.StopBundleCommand">
                 <property name="clusterManager" ref="clusterManager"/>
                 <property name="groupManager" ref="groupManager"/>
-                <property name="eventTransportFactory" ref="eventTransportFactory"/>
+                <property name="eventProducer" ref="eventProducer"/>
             </action>
             <completers>
                 <ref component-id="allGroupCompleter"/>

Modified: karaf/cellar/branches/cellar-2.2.x/core/src/main/java/org/apache/karaf/cellar/core/control/ProducerSwitchCommandHandler.java
URL: http://svn.apache.org/viewvc/karaf/cellar/branches/cellar-2.2.x/core/src/main/java/org/apache/karaf/cellar/core/control/ProducerSwitchCommandHandler.java?rev=1331983&r1=1331982&r2=1331983&view=diff
==============================================================================
--- karaf/cellar/branches/cellar-2.2.x/core/src/main/java/org/apache/karaf/cellar/core/control/ProducerSwitchCommandHandler.java (original)
+++ karaf/cellar/branches/cellar-2.2.x/core/src/main/java/org/apache/karaf/cellar/core/control/ProducerSwitchCommandHandler.java Sun Apr 29 19:43:21 2012
@@ -39,7 +39,7 @@ public class ProducerSwitchCommandHandle
             producer.getSwitch().turnOn();
             return new ProducerSwitchResult(command.getId(), Boolean.TRUE, Boolean.TRUE);
         }
-        //Turn on the switch
+        //Turn off the switch
         else if (command.getStatus().equals(SwitchStatus.OFF)) {
             producer.getSwitch().turnOff();
             return new ProducerSwitchResult(command.getId(), Boolean.TRUE, Boolean.FALSE);

Modified: karaf/cellar/branches/cellar-2.2.x/core/src/main/java/org/apache/karaf/cellar/core/shell/CellarCommandSupport.java
URL: http://svn.apache.org/viewvc/karaf/cellar/branches/cellar-2.2.x/core/src/main/java/org/apache/karaf/cellar/core/shell/CellarCommandSupport.java?rev=1331983&r1=1331982&r2=1331983&view=diff
==============================================================================
--- karaf/cellar/branches/cellar-2.2.x/core/src/main/java/org/apache/karaf/cellar/core/shell/CellarCommandSupport.java (original)
+++ karaf/cellar/branches/cellar-2.2.x/core/src/main/java/org/apache/karaf/cellar/core/shell/CellarCommandSupport.java Sun Apr 29 19:43:21 2012
@@ -25,7 +25,6 @@ public abstract class CellarCommandSuppo
 
     protected ClusterManager clusterManager;
     protected GroupManager groupManager;
-    protected EventTransportFactory eventTransportFactory;
 
 
     public ClusterManager getClusterManager() {
@@ -44,11 +43,4 @@ public abstract class CellarCommandSuppo
         this.groupManager = groupManager;
     }
 
-    public EventTransportFactory getEventTransportFactory() {
-        return eventTransportFactory;
-    }
-
-    public void setEventTransportFactory(EventTransportFactory eventTransportFactory) {
-        this.eventTransportFactory = eventTransportFactory;
-    }
 }

Modified: karaf/cellar/branches/cellar-2.2.x/dosgi/src/main/resources/OSGI-INF/blueprint/shell-dosgi.xml
URL: http://svn.apache.org/viewvc/karaf/cellar/branches/cellar-2.2.x/dosgi/src/main/resources/OSGI-INF/blueprint/shell-dosgi.xml?rev=1331983&r1=1331982&r2=1331983&view=diff
==============================================================================
--- karaf/cellar/branches/cellar-2.2.x/dosgi/src/main/resources/OSGI-INF/blueprint/shell-dosgi.xml (original)
+++ karaf/cellar/branches/cellar-2.2.x/dosgi/src/main/resources/OSGI-INF/blueprint/shell-dosgi.xml Sun Apr 29 19:43:21 2012
@@ -19,7 +19,6 @@
         <command name="cluster/service-list">
             <action class="org.apache.karaf.cellar.dosgi.shell.ListDistributedServicesCommand">
                 <property name="clusterManager" ref="clusterManager"/>
-                <property name="eventTransportFactory" ref="eventTransportFactory"/>
             </action>
         </command>
     </command-bundle>

Modified: karaf/cellar/branches/cellar-2.2.x/features/src/main/java/org/apache/karaf/cellar/features/shell/InstallFeatureCommand.java
URL: http://svn.apache.org/viewvc/karaf/cellar/branches/cellar-2.2.x/features/src/main/java/org/apache/karaf/cellar/features/shell/InstallFeatureCommand.java?rev=1331983&r1=1331982&r2=1331983&view=diff
==============================================================================
--- karaf/cellar/branches/cellar-2.2.x/features/src/main/java/org/apache/karaf/cellar/features/shell/InstallFeatureCommand.java (original)
+++ karaf/cellar/branches/cellar-2.2.x/features/src/main/java/org/apache/karaf/cellar/features/shell/InstallFeatureCommand.java Sun Apr 29 19:43:21 2012
@@ -14,6 +14,7 @@
 package org.apache.karaf.cellar.features.shell;
 
 import org.apache.karaf.cellar.core.Group;
+import org.apache.karaf.cellar.core.control.SwitchStatus;
 import org.apache.karaf.cellar.core.event.EventProducer;
 import org.apache.karaf.cellar.features.RemoteFeaturesEvent;
 import org.apache.felix.gogo.commands.Argument;
@@ -32,22 +33,40 @@ public class InstallFeatureCommand exten
     @Argument(index = 2, name = "version", description = "The feature version.", required = false, multiValued = false)
     String version;
 
+    private EventProducer eventProducer;
+
     @Override
     protected Object doExecute() throws Exception {
+        // check if the cluster group exists
         Group group = groupManager.findGroupByName(groupName);
         if (group == null) {
             System.err.println("Cluster group " + groupName + " doesn't exist");
             return null;
         }
 
-        EventProducer producer = eventTransportFactory.getEventProducer(groupName, true);
-        RemoteFeaturesEvent event = new RemoteFeaturesEvent(feature, version, FeatureEvent.EventType.FeatureInstalled);
-        event.setSourceGroup(group);
-        producer.produce(event);
+        // check if the producer is ON
+        if (eventProducer.getSwitch().getStatus().equals(SwitchStatus.OFF)) {
+            System.err.println("Cluster event producer is OFF for this node");
+            return null;
+        }
 
+        // update the distributed resource
         updateFeatureStatus(groupName, feature, version, true);
 
+        // broadcast the cluster event
+        RemoteFeaturesEvent event = new RemoteFeaturesEvent(feature, version, FeatureEvent.EventType.FeatureInstalled);
+        event.setSourceGroup(group);
+        eventProducer.produce(event);
+
         return null;
     }
 
+    public EventProducer getEventProducer() {
+        return eventProducer;
+    }
+
+    public void setEventProducer(EventProducer eventProducer) {
+        this.eventProducer = eventProducer;
+    }
+
 }

Modified: karaf/cellar/branches/cellar-2.2.x/features/src/main/java/org/apache/karaf/cellar/features/shell/UninstallFeatureCommand.java
URL: http://svn.apache.org/viewvc/karaf/cellar/branches/cellar-2.2.x/features/src/main/java/org/apache/karaf/cellar/features/shell/UninstallFeatureCommand.java?rev=1331983&r1=1331982&r2=1331983&view=diff
==============================================================================
--- karaf/cellar/branches/cellar-2.2.x/features/src/main/java/org/apache/karaf/cellar/features/shell/UninstallFeatureCommand.java (original)
+++ karaf/cellar/branches/cellar-2.2.x/features/src/main/java/org/apache/karaf/cellar/features/shell/UninstallFeatureCommand.java Sun Apr 29 19:43:21 2012
@@ -14,6 +14,7 @@
 package org.apache.karaf.cellar.features.shell;
 
 import org.apache.karaf.cellar.core.Group;
+import org.apache.karaf.cellar.core.control.SwitchStatus;
 import org.apache.karaf.cellar.core.event.EventProducer;
 import org.apache.karaf.cellar.features.RemoteFeaturesEvent;
 import org.apache.felix.gogo.commands.Argument;
@@ -32,23 +33,40 @@ public class UninstallFeatureCommand ext
     @Argument(index = 2, name = "version", description = "The feature version.", required = false, multiValued = false)
     String version;
 
+    private EventProducer eventProducer;
+
     @Override
     protected Object doExecute() throws Exception {
+        // check if cluster group exists
         Group group = groupManager.findGroupByName(groupName);
         if (group == null) {
             System.err.println("Cluster group " + groupName + " doesn't exist");
             return null;
         }
 
-        EventProducer producer = eventTransportFactory.getEventProducer(groupName, true);
-        RemoteFeaturesEvent event = new RemoteFeaturesEvent(feature, version, FeatureEvent.EventType.FeatureUninstalled);
-        event.setForce(true);
-        event.setSourceGroup(group);
-        producer.produce(event);
+        // check if the producer is ON
+        if (eventProducer.getSwitch().getStatus().equals(SwitchStatus.OFF)) {
+            System.err.println("Cluster event producer is OFF for this node");
+            return null;
+        }
 
+        // update distributed set
         updateFeatureStatus(groupName, feature, version, true);
 
+        // broadcast the cluster event
+        RemoteFeaturesEvent event = new RemoteFeaturesEvent(feature, version, FeatureEvent.EventType.FeatureUninstalled);
+        event.setSourceGroup(group);
+        eventProducer.produce(event);
+
         return null;
     }
 
+    public EventProducer getEventProducer() {
+        return eventProducer;
+    }
+
+    public void setEventProducer(EventProducer eventProducer) {
+        this.eventProducer = eventProducer;
+    }
+
 }

Modified: karaf/cellar/branches/cellar-2.2.x/features/src/main/resources/OSGI-INF/blueprint/shell-features.xml
URL: http://svn.apache.org/viewvc/karaf/cellar/branches/cellar-2.2.x/features/src/main/resources/OSGI-INF/blueprint/shell-features.xml?rev=1331983&r1=1331982&r2=1331983&view=diff
==============================================================================
--- karaf/cellar/branches/cellar-2.2.x/features/src/main/resources/OSGI-INF/blueprint/shell-features.xml (original)
+++ karaf/cellar/branches/cellar-2.2.x/features/src/main/resources/OSGI-INF/blueprint/shell-features.xml Sun Apr 29 19:43:21 2012
@@ -20,7 +20,7 @@
             <action class="org.apache.karaf.cellar.features.shell.InstallFeatureCommand">
                 <property name="clusterManager" ref="clusterManager"/>
                 <property name="groupManager" ref="groupManager"/>
-                <property name="eventTransportFactory" ref="eventTransportFactory"/>
+                <property name="eventProducer" ref="eventProducer"/>
                 <property name="featuresService" ref="featuresService"/>
             </action>
             <completers>
@@ -32,7 +32,7 @@
             <action class="org.apache.karaf.cellar.features.shell.UninstallFeatureCommand">
                 <property name="clusterManager" ref="clusterManager"/>
                 <property name="groupManager" ref="groupManager"/>
-                <property name="eventTransportFactory" ref="eventTransportFactory"/>
+                <property name="eventProducer" ref="eventProducer"/>
                 <property name="featuresService" ref="featuresService"/>
             </action>
             <completers>

Modified: karaf/cellar/branches/cellar-2.2.x/management/src/main/java/org/apache/karaf/cellar/management/internal/CellarBundleMBeanImpl.java
URL: http://svn.apache.org/viewvc/karaf/cellar/branches/cellar-2.2.x/management/src/main/java/org/apache/karaf/cellar/management/internal/CellarBundleMBeanImpl.java?rev=1331983&r1=1331982&r2=1331983&view=diff
==============================================================================
--- karaf/cellar/branches/cellar-2.2.x/management/src/main/java/org/apache/karaf/cellar/management/internal/CellarBundleMBeanImpl.java (original)
+++ karaf/cellar/branches/cellar-2.2.x/management/src/main/java/org/apache/karaf/cellar/management/internal/CellarBundleMBeanImpl.java Sun Apr 29 19:43:21 2012
@@ -20,6 +20,7 @@ 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.GroupManager;
+import org.apache.karaf.cellar.core.control.SwitchStatus;
 import org.apache.karaf.cellar.core.event.EventProducer;
 import org.apache.karaf.cellar.core.event.EventTransportFactory;
 import org.apache.karaf.cellar.management.CellarBundleMBean;
@@ -39,8 +40,8 @@ import java.util.jar.Manifest;
 public class CellarBundleMBeanImpl extends StandardMBean implements CellarBundleMBean {
 
     private ClusterManager clusterManager;
-    private EventTransportFactory eventTransportFactory;
     private GroupManager groupManager;
+    private EventProducer eventProducer;
 
     public CellarBundleMBeanImpl() throws NotCompliantMBeanException {
         super(CellarBundleMBean.class);
@@ -54,14 +55,6 @@ public class CellarBundleMBeanImpl exten
         this.clusterManager = clusterManager;
     }
 
-    public EventTransportFactory getEventTransportFactory() {
-        return this.eventTransportFactory;
-    }
-
-    public void setEventTransportFactory(EventTransportFactory eventTransportFactory) {
-        this.eventTransportFactory = eventTransportFactory;
-    }
-
     public GroupManager getGroupManager() {
         return this.groupManager;
     }
@@ -70,13 +63,26 @@ public class CellarBundleMBeanImpl exten
         this.groupManager = groupManager;
     }
 
+    public EventProducer getEventProducer() {
+        return eventProducer;
+    }
+
+    public void setEventProducer(EventProducer eventProducer) {
+        this.eventProducer = eventProducer;
+    }
+
     public void install(String groupName, String location) throws Exception {
+        // check if cluster group exists
         Group group = groupManager.findGroupByName(groupName);
-
         if (group == null) {
             throw new IllegalArgumentException("Cluster group " + groupName + " doesn't exist");
         }
 
+        // check if the producer is ON
+        if (eventProducer.getSwitch().getStatus().equals(SwitchStatus.OFF)) {
+            throw new IllegalStateException("Cluster event producer is OFF for this node");
+        }
+
         // get the name and version in the location MANIFEST
         JarInputStream jarInputStream = new JarInputStream(new URL(location).openStream());
         Manifest manifest = jarInputStream.getManifest();
@@ -92,19 +98,23 @@ public class CellarBundleMBeanImpl exten
         bundles.put(name + "/" + version, state);
 
         // broadcast the event
-        EventProducer producer = eventTransportFactory.getEventProducer(groupName, true);
         RemoteBundleEvent event = new RemoteBundleEvent(name, version, location, BundleEvent.INSTALLED);
         event.setSourceGroup(group);
-        producer.produce(event);
+        eventProducer.produce(event);
     }
 
     public void uninstall(String groupName, String symbolicName, String version) throws Exception {
+        // check if the cluster group exists
         Group group = groupManager.findGroupByName(groupName);
-
         if (group == null) {
             throw new IllegalArgumentException("Cluster group " + groupName + " doesn't exist");
         }
 
+        // check if the producer is ON
+        if (eventProducer.getSwitch().getStatus().equals(SwitchStatus.OFF)) {
+            throw new IllegalStateException("Cluster event producer is OFF for this node");
+        }
+
         // update the cluster map
         ClassLoader originalClassLoader = Thread.currentThread().getContextClassLoader();
         Thread.currentThread().setContextClassLoader(getClass().getClassLoader());
@@ -116,19 +126,23 @@ public class CellarBundleMBeanImpl exten
         }
 
         // broadcast the event
-        EventProducer producer = eventTransportFactory.getEventProducer(groupName, true);
         RemoteBundleEvent event = new RemoteBundleEvent(symbolicName, version, null, BundleEvent.UNINSTALLED);
         event.setSourceGroup(group);
-        producer.produce(event);
+        eventProducer.produce(event);
     }
 
     public void start(String groupName, String symbolicName, String version) throws Exception {
+        // check if the cluster group exists
         Group group = groupManager.findGroupByName(groupName);
-
         if (group == null) {
             throw new IllegalArgumentException("Cluster group " + groupName + " doesn't exist");
         }
 
+        // check if the producer is ON
+        if (eventProducer.getSwitch().getStatus().equals(SwitchStatus.OFF)) {
+            throw new IllegalStateException("Cluster event producer is OFF for this node");
+        }
+
         // update the cluster map
         ClassLoader originalClassLoader = Thread.currentThread().getContextClassLoader();
         Thread.currentThread().setContextClassLoader(getClass().getClassLoader());
@@ -145,19 +159,23 @@ public class CellarBundleMBeanImpl exten
         }
 
         // broadcast the event
-        EventProducer producer = eventTransportFactory.getEventProducer(groupName, true);
         RemoteBundleEvent event = new RemoteBundleEvent(symbolicName, version, null, BundleEvent.STARTED);
         event.setSourceGroup(group);
-        producer.produce(event);
+        eventProducer.produce(event);
     }
 
     public void stop(String groupName, String symbolicName, String version) throws Exception {
+        // check if the cluster group exists
         Group group = groupManager.findGroupByName(groupName);
-
         if (group == null) {
             throw new IllegalArgumentException("Cluster group " + groupName + " doesn't exist");
         }
 
+        // check if the producer is ON
+        if (eventProducer.getSwitch().getStatus().equals(SwitchStatus.OFF)) {
+            throw new IllegalStateException("Cluster event producer is OFF for this node");
+        }
+
         // update the cluster map
         ClassLoader originalClassLoader = Thread.currentThread().getContextClassLoader();
         Thread.currentThread().setContextClassLoader(getClass().getClassLoader());
@@ -174,11 +192,10 @@ public class CellarBundleMBeanImpl exten
         }
 
         // broadcast the event
-        EventProducer producer = eventTransportFactory.getEventProducer(groupName, true);
         RemoteBundleEvent event = new RemoteBundleEvent(symbolicName, version, null, BundleEvent.STOPPED);
         event.setForce(true);
         event.setSourceGroup(group);
-        producer.produce(event);
+        eventProducer.produce(event);
     }
 
     public TabularData getBundles(String groupName) throws Exception {
@@ -207,7 +224,6 @@ public class CellarBundleMBeanImpl exten
         } finally {
             Thread.currentThread().setContextClassLoader(originalClassLoader);
         }
-
         return table;
     }
 

Modified: karaf/cellar/branches/cellar-2.2.x/management/src/main/java/org/apache/karaf/cellar/management/internal/CellarFeaturesMBeanImpl.java
URL: http://svn.apache.org/viewvc/karaf/cellar/branches/cellar-2.2.x/management/src/main/java/org/apache/karaf/cellar/management/internal/CellarFeaturesMBeanImpl.java?rev=1331983&r1=1331982&r2=1331983&view=diff
==============================================================================
--- karaf/cellar/branches/cellar-2.2.x/management/src/main/java/org/apache/karaf/cellar/management/internal/CellarFeaturesMBeanImpl.java (original)
+++ karaf/cellar/branches/cellar-2.2.x/management/src/main/java/org/apache/karaf/cellar/management/internal/CellarFeaturesMBeanImpl.java Sun Apr 29 19:43:21 2012
@@ -17,6 +17,7 @@ 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.GroupManager;
+import org.apache.karaf.cellar.core.control.SwitchStatus;
 import org.apache.karaf.cellar.core.event.EventProducer;
 import org.apache.karaf.cellar.core.event.EventTransportFactory;
 import org.apache.karaf.cellar.features.Constants;
@@ -37,8 +38,8 @@ import java.util.Map;
 public class CellarFeaturesMBeanImpl extends StandardMBean implements CellarFeaturesMBean {
 
     private ClusterManager clusterManager;
-    private EventTransportFactory eventTransportFactory;
     private GroupManager groupManager;
+    private EventProducer eventProducer;
 
     public CellarFeaturesMBeanImpl() throws NotCompliantMBeanException {
         super(CellarFeaturesMBean.class);
@@ -60,20 +61,32 @@ public class CellarFeaturesMBeanImpl ext
         this.groupManager = groupManager;
     }
 
-    public EventTransportFactory getEventTransportFactory() {
-        return eventTransportFactory;
+    public EventProducer getEventProducer() {
+        return eventProducer;
     }
 
-    public void setEventTransportFactory(EventTransportFactory eventTransportFactory) {
-        this.eventTransportFactory = eventTransportFactory;
+    public void setEventProducer(EventProducer eventProducer) {
+        this.eventProducer = eventProducer;
     }
 
     public void install(String groupName, String name, String version) throws Exception {
+        // check if the cluster group exists
         Group group = groupManager.findGroupByName(groupName);
-        EventProducer producer = eventTransportFactory.getEventProducer(groupName,true);
+        if (group == null) {
+            throw new IllegalArgumentException("Cluster group " + groupName + " doesn't exist");
+        }
+
+        // check if the producer is ON
+        if (eventProducer.getSwitch().getStatus().equals(SwitchStatus.OFF)) {
+            throw new IllegalStateException("Cluster event producer is OFF for this node");
+        }
+
+        // TODO update the distributed resource
+
+        // broadcast the cluster event
         RemoteFeaturesEvent event = new RemoteFeaturesEvent(name, version, FeatureEvent.EventType.FeatureInstalled);
         event.setSourceGroup(group);
-        producer.produce(event);
+        eventProducer.produce(event);
     }
 
     public void install(String groupName, String name) throws Exception {
@@ -81,11 +94,20 @@ public class CellarFeaturesMBeanImpl ext
     }
 
     public void uninstall(String groupName, String name, String version) throws Exception {
+        // check if cluster group exists
         Group group = groupManager.findGroupByName(groupName);
-        EventProducer producer = eventTransportFactory.getEventProducer(groupName,true);
+        if (group == null) {
+            throw new IllegalArgumentException("Cluster group " + groupName + " doesn't exist");
+        }
+
+        // check if producer is ON
+        if (eventProducer.getSwitch().getStatus().equals(SwitchStatus.OFF)) {
+            throw new IllegalStateException("Cluster event producer is OFF for this node");
+        }
+
         RemoteFeaturesEvent event = new RemoteFeaturesEvent(name, version, FeatureEvent.EventType.FeatureUninstalled);
         event.setSourceGroup(group);
-        producer.produce(event);
+        eventProducer.produce(event);
     }
 
     public void uninstall(String groupName, String name) throws Exception {
@@ -117,7 +139,6 @@ public class CellarFeaturesMBeanImpl ext
         } finally {
             Thread.currentThread().setContextClassLoader(originalClassLoader);
         }
-
         return table;
     }
 

Modified: karaf/cellar/branches/cellar-2.2.x/management/src/main/resources/OSGI-INF/blueprint/blueprint.xml
URL: http://svn.apache.org/viewvc/karaf/cellar/branches/cellar-2.2.x/management/src/main/resources/OSGI-INF/blueprint/blueprint.xml?rev=1331983&r1=1331982&r2=1331983&view=diff
==============================================================================
--- karaf/cellar/branches/cellar-2.2.x/management/src/main/resources/OSGI-INF/blueprint/blueprint.xml (original)
+++ karaf/cellar/branches/cellar-2.2.x/management/src/main/resources/OSGI-INF/blueprint/blueprint.xml Sun Apr 29 19:43:21 2012
@@ -17,7 +17,7 @@
     <!-- Reference to the Cellar services -->
     <reference id="clusterManager" interface="org.apache.karaf.cellar.core.ClusterManager"/>
     <reference id="groupManager" interface="org.apache.karaf.cellar.core.GroupManager"/>
-    <reference id="eventTransportFactory" interface="org.apache.karaf.cellar.core.event.EventTransportFactory"/>
+    <reference id="eventProducer" interface="org.apache.karaf.cellar.core.event.EventProducer"/>
     <reference id="executionContext" interface="org.apache.karaf.cellar.core.command.ExecutionContext"/>
 
     <reference id="mbeanServer" interface="javax.management.MBeanServer">
@@ -40,8 +40,8 @@
 
     <bean id="cellarFeaturesMBean" class="org.apache.karaf.cellar.management.internal.CellarFeaturesMBeanImpl">
         <property name="clusterManager" ref="clusterManager"/>
-        <property name="eventTransportFactory" ref="eventTransportFactory"/>
         <property name="groupManager" ref="groupManager"/>
+        <property name="eventProducer" ref="eventProducer"/>
     </bean>
 
     <bean id="cellarGroupMBean" class="org.apache.karaf.cellar.management.internal.CellarGroupMBeanImpl">
@@ -52,8 +52,8 @@
     
     <bean id="cellarBundleMBean" class="org.apache.karaf.cellar.management.internal.CellarBundleMBeanImpl">
         <property name="clusterManager" ref="clusterManager"/>
-        <property name="eventTransportFactory" ref="eventTransportFactory"/>
         <property name="groupManager" ref="groupManager"/>
+        <property name="eventProducer" ref="eventProducer"/>
     </bean>
 
     <bean id="mbeanRegister" class="org.apache.karaf.management.MBeanRegistrer">

Modified: karaf/cellar/branches/cellar-2.2.x/obr/src/main/java/org/apache/karaf/cellar/obr/shell/ObrAddUrlCommand.java
URL: http://svn.apache.org/viewvc/karaf/cellar/branches/cellar-2.2.x/obr/src/main/java/org/apache/karaf/cellar/obr/shell/ObrAddUrlCommand.java?rev=1331983&r1=1331982&r2=1331983&view=diff
==============================================================================
--- karaf/cellar/branches/cellar-2.2.x/obr/src/main/java/org/apache/karaf/cellar/obr/shell/ObrAddUrlCommand.java (original)
+++ karaf/cellar/branches/cellar-2.2.x/obr/src/main/java/org/apache/karaf/cellar/obr/shell/ObrAddUrlCommand.java Sun Apr 29 19:43:21 2012
@@ -19,6 +19,7 @@ import org.apache.felix.gogo.commands.Ar
 import org.apache.felix.gogo.commands.Command;
 import org.apache.karaf.cellar.core.Configurations;
 import org.apache.karaf.cellar.core.Group;
+import org.apache.karaf.cellar.core.control.SwitchStatus;
 import org.apache.karaf.cellar.core.event.EventProducer;
 import org.apache.karaf.cellar.obr.Constants;
 import org.apache.karaf.cellar.obr.ObrBundleInfo;
@@ -35,14 +36,22 @@ public class ObrAddUrlCommand extends Ob
     @Argument(index = 1, name = "url", description = "The repository URL to register in the OBR service.", required = true, multiValued = false)
     String url;
 
+    private EventProducer eventProducer;
+
     public Object doExecute() throws Exception {
-        // find group for the given name
+        // check if the cluster group exists
         Group group = groupManager.findGroupByName(groupName);
         if (group == null) {
             System.err.println("Cluster group " + groupName + " doesn't exist.");
             return null;
         }
 
+        // check if the producer is ON
+        if (eventProducer.getSwitch().getStatus().equals(SwitchStatus.OFF)) {
+            System.err.println("Cluster event producer is OFF for this node");
+            return null;
+        }
+
         // push the OBR URL in the distributed set
         Set<String> urls = clusterManager.getSet(Constants.URLS_DISTRIBUTED_SET_NAME + Configurations.SEPARATOR + groupName);
         urls.add(url);
@@ -59,12 +68,20 @@ public class ObrAddUrlCommand extends Ob
         }
 
         // create an cluster event and produce it
-        EventProducer producer = eventTransportFactory.getEventProducer(groupName, true);
         ObrUrlEvent event = new ObrUrlEvent(url, Constants.URL_ADD_EVENT_TYPE);
         event.setForce(true);
         event.setSourceGroup(group);
-        producer.produce(event);
+        eventProducer.produce(event);
+
         return null;
     }
 
+    public EventProducer getEventProducer() {
+        return eventProducer;
+    }
+
+    public void setEventProducer(EventProducer eventProducer) {
+        this.eventProducer = eventProducer;
+    }
+
 }

Modified: karaf/cellar/branches/cellar-2.2.x/obr/src/main/java/org/apache/karaf/cellar/obr/shell/ObrDeployCommand.java
URL: http://svn.apache.org/viewvc/karaf/cellar/branches/cellar-2.2.x/obr/src/main/java/org/apache/karaf/cellar/obr/shell/ObrDeployCommand.java?rev=1331983&r1=1331982&r2=1331983&view=diff
==============================================================================
--- karaf/cellar/branches/cellar-2.2.x/obr/src/main/java/org/apache/karaf/cellar/obr/shell/ObrDeployCommand.java (original)
+++ karaf/cellar/branches/cellar-2.2.x/obr/src/main/java/org/apache/karaf/cellar/obr/shell/ObrDeployCommand.java Sun Apr 29 19:43:21 2012
@@ -18,6 +18,7 @@ import org.apache.felix.gogo.commands.Co
 import org.apache.felix.gogo.commands.Option;
 import org.apache.karaf.cellar.core.Configurations;
 import org.apache.karaf.cellar.core.Group;
+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.apache.karaf.cellar.core.shell.CellarCommandSupport;
@@ -38,23 +39,31 @@ public class ObrDeployCommand extends Ce
     @Option(name = "-s", aliases = { "--start" }, description = "Start the deployed bundles.", required = false, multiValued = false)
     boolean start = false;
 
+    private EventProducer eventProducer;
+
     @Override
     protected Object doExecute() throws Exception {
-        // find the group for the given name
+        // check if the group exists
         Group group = groupManager.findGroupByName(groupName);
         if (group == null) {
-            System.err.println("Cluster group " + groupName + " doesn't exist.");
+            System.err.println("Cluster group " + groupName + " doesn't exist");
+            return null;
+        }
+
+        // check if the producer is ON
+        if (eventProducer.getSwitch().getStatus().equals(SwitchStatus.OFF)) {
+            System.err.println("Cluster event producer is OFF for this node");
             return null;
         }
 
         // create an event and produce it
-        EventProducer producer = eventTransportFactory.getEventProducer(groupName, true);
         int type = 0;
         if (start) type = Constants.BUNDLE_START_EVENT_TYPE;
         ObrBundleEvent event = new ObrBundleEvent(bundleId, type);
         event.setForce(true);
         event.setSourceGroup(group);
-        producer.produce(event);
+        eventProducer.produce(event);
+
         return null;
     }
 

Modified: karaf/cellar/branches/cellar-2.2.x/obr/src/main/java/org/apache/karaf/cellar/obr/shell/ObrListCommand.java
URL: http://svn.apache.org/viewvc/karaf/cellar/branches/cellar-2.2.x/obr/src/main/java/org/apache/karaf/cellar/obr/shell/ObrListCommand.java?rev=1331983&r1=1331982&r2=1331983&view=diff
==============================================================================
--- karaf/cellar/branches/cellar-2.2.x/obr/src/main/java/org/apache/karaf/cellar/obr/shell/ObrListCommand.java (original)
+++ karaf/cellar/branches/cellar-2.2.x/obr/src/main/java/org/apache/karaf/cellar/obr/shell/ObrListCommand.java Sun Apr 29 19:43:21 2012
@@ -33,11 +33,13 @@ public class ObrListCommand extends Cell
     String groupName;
 
     public Object doExecute() {
+        // check if the group exists
         Group group = groupManager.findGroupByName(groupName);
         if (group == null) {
-            System.err.println("Cluster group " + groupName + " doesn't exist.");
+            System.err.println("Cluster group " + groupName + " doesn't exist");
             return null;
         }
+
         ClassLoader originalClassLoader = Thread.currentThread().getContextClassLoader();
         try {
             Thread.currentThread().setContextClassLoader(getClass().getClassLoader());
@@ -60,6 +62,7 @@ public class ObrListCommand extends Cell
         } finally {
             Thread.currentThread().setContextClassLoader(originalClassLoader);
         }
+
         return null;
     }
 

Modified: karaf/cellar/branches/cellar-2.2.x/obr/src/main/java/org/apache/karaf/cellar/obr/shell/ObrListUrlCommand.java
URL: http://svn.apache.org/viewvc/karaf/cellar/branches/cellar-2.2.x/obr/src/main/java/org/apache/karaf/cellar/obr/shell/ObrListUrlCommand.java?rev=1331983&r1=1331982&r2=1331983&view=diff
==============================================================================
--- karaf/cellar/branches/cellar-2.2.x/obr/src/main/java/org/apache/karaf/cellar/obr/shell/ObrListUrlCommand.java (original)
+++ karaf/cellar/branches/cellar-2.2.x/obr/src/main/java/org/apache/karaf/cellar/obr/shell/ObrListUrlCommand.java Sun Apr 29 19:43:21 2012
@@ -33,6 +33,7 @@ public class ObrListUrlCommand extends C
     String groupName;
 
     public Object doExecute() throws Exception {
+        // check if the group exists
         Group group = groupManager.findGroupByName(groupName);
         if (group == null) {
             System.err.println("Cluster group " + groupName + " doesn't exist.");
@@ -45,6 +46,7 @@ public class ObrListUrlCommand extends C
                 System.out.println(url);
             }
         }
+
         return null;
     }
 

Modified: karaf/cellar/branches/cellar-2.2.x/obr/src/main/java/org/apache/karaf/cellar/obr/shell/ObrRemoveUrlCommand.java
URL: http://svn.apache.org/viewvc/karaf/cellar/branches/cellar-2.2.x/obr/src/main/java/org/apache/karaf/cellar/obr/shell/ObrRemoveUrlCommand.java?rev=1331983&r1=1331982&r2=1331983&view=diff
==============================================================================
--- karaf/cellar/branches/cellar-2.2.x/obr/src/main/java/org/apache/karaf/cellar/obr/shell/ObrRemoveUrlCommand.java (original)
+++ karaf/cellar/branches/cellar-2.2.x/obr/src/main/java/org/apache/karaf/cellar/obr/shell/ObrRemoveUrlCommand.java Sun Apr 29 19:43:21 2012
@@ -19,6 +19,7 @@ import org.apache.felix.gogo.commands.Ar
 import org.apache.felix.gogo.commands.Command;
 import org.apache.karaf.cellar.core.Configurations;
 import org.apache.karaf.cellar.core.Group;
+import org.apache.karaf.cellar.core.control.SwitchStatus;
 import org.apache.karaf.cellar.core.event.EventProducer;
 import org.apache.karaf.cellar.obr.Constants;
 import org.apache.karaf.cellar.obr.ObrBundleInfo;
@@ -35,11 +36,19 @@ public class ObrRemoveUrlCommand extends
     @Argument(index = 1, name = "url", description = "The repository URL to add in the OBR service.", required = true, multiValued = false)
     String url;
 
+    private EventProducer eventProducer;
+
     public Object doExecute() throws Exception {
-        // find the group for the given name
+        // check if the group exists
         Group group = groupManager.findGroupByName(groupName);
         if (group == null) {
-            System.err.println("Cluster group " + groupName + " doesn't exist.");
+            System.err.println("Cluster group " + groupName + " doesn't exist");
+            return null;
+        }
+
+        // check if the producer is ON
+        if (eventProducer.getSwitch().getStatus().equals(SwitchStatus.OFF)) {
+            System.err.println("Cluster event producer is OFF for this node");
             return null;
         }
 
@@ -59,12 +68,18 @@ public class ObrRemoveUrlCommand extends
         }
 
         // create an event and produce it
-        EventProducer producer = eventTransportFactory.getEventProducer(groupName, true);
         ObrUrlEvent event = new ObrUrlEvent(url, Constants.URL_REMOVE_EVENT_TYPE);
-        event.setForce(true);
         event.setSourceGroup(group);
-        producer.produce(event);
+        eventProducer.produce(event);
         return null;
     }
 
+    public EventProducer getEventProducer() {
+        return eventProducer;
+    }
+
+    public void setEventProducer(EventProducer eventProducer) {
+        this.eventProducer = eventProducer;
+    }
+
 }

Modified: karaf/cellar/branches/cellar-2.2.x/obr/src/main/resources/OSGI-INF/blueprint/shell-commands.xml
URL: http://svn.apache.org/viewvc/karaf/cellar/branches/cellar-2.2.x/obr/src/main/resources/OSGI-INF/blueprint/shell-commands.xml?rev=1331983&r1=1331982&r2=1331983&view=diff
==============================================================================
--- karaf/cellar/branches/cellar-2.2.x/obr/src/main/resources/OSGI-INF/blueprint/shell-commands.xml (original)
+++ karaf/cellar/branches/cellar-2.2.x/obr/src/main/resources/OSGI-INF/blueprint/shell-commands.xml Sun Apr 29 19:43:21 2012
@@ -20,7 +20,6 @@
             <action class="org.apache.karaf.cellar.obr.shell.ObrListCommand">
                 <property name="clusterManager" ref="clusterManager"/>
                 <property name="groupManager" ref="groupManager"/>
-                <property name="eventTransportFactory" ref="eventTransportFactory"/>
             </action>
             <completers>
                 <ref component-id="allGroupCompleter"/>
@@ -31,7 +30,7 @@
             <action class="org.apache.karaf.cellar.obr.shell.ObrDeployCommand">
                 <property name="clusterManager" ref="clusterManager"/>
                 <property name="groupManager" ref="groupManager"/>
-                <property name="eventTransportFactory" ref="eventTransportFactory"/>
+                <property name="eventProducer" ref="eventProducer"/>
             </action>
             <completers>
                 <ref component-id="allGroupCompleter"/>
@@ -42,7 +41,7 @@
             <action class="org.apache.karaf.cellar.obr.shell.ObrListUrlCommand">
                 <property name="clusterManager" ref="clusterManager"/>
                 <property name="groupManager" ref="groupManager"/>
-                <property name="eventTransportFactory" ref="eventTransportFactory"/>
+                <property name="eventProducer" ref="eventProducer"/>
             </action>
             <completers>
                 <ref component-id="allGroupCompleter"/>
@@ -53,7 +52,7 @@
             <action class="org.apache.karaf.cellar.obr.shell.ObrAddUrlCommand">
                 <property name="clusterManager" ref="clusterManager"/>
                 <property name="groupManager" ref="groupManager"/>
-                <property name="eventTransportFactory" ref="eventTransportFactory"/>
+                <property name="eventProducer" ref="eventProducer"/>
                 <property name="obrService" ref="repositoryAdmin"/>
             </action>
             <completers>
@@ -65,7 +64,7 @@
             <action class="org.apache.karaf.cellar.obr.shell.ObrRemoveUrlCommand">
                 <property name="clusterManager" ref="clusterManager"/>
                 <property name="groupManager" ref="groupManager"/>
-                <property name="eventTransportFactory" ref="eventTransportFactory"/>
+                <property name="eventProducer" ref="eventProducer"/>
                 <property name="obrService" ref="repositoryAdmin"/>
             </action>
             <completers>