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 2013/12/18 13:23:17 UTC

[42/50] [abbrv] git commit: [KARAF-2204] cluster:feature-url-add, cluster:feature-url-remove and corresponding MBeans now support installAll and uninstallAll option

[KARAF-2204] cluster:feature-url-add, cluster:feature-url-remove and corresponding MBeans now support installAll and uninstallAll option

git-svn-id: https://svn.apache.org/repos/asf/karaf/cellar/trunk@1496596 13f79535-47bb-0310-9956-ffa450edef68


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

Branch: refs/heads/master
Commit: 83431c10bfebcec21dee67ed659fabfa27d418f6
Parents: 2e00e51
Author: jbonofre <jb...@13f79535-47bb-0310-9956-ffa450edef68>
Authored: Tue Jun 25 19:19:50 2013 +0000
Committer: jbonofre <jb...@13f79535-47bb-0310-9956-ffa450edef68>
Committed: Tue Jun 25 19:19:50 2013 +0000

----------------------------------------------------------------------
 .../cellar/features/ClusterRepositoryEvent.java | 20 +++++++++++++++++++-
 .../cellar/features/RepositoryEventHandler.java |  4 ++--
 .../cellar/features/shell/UrlAddCommand.java    |  5 +++++
 .../cellar/features/shell/UrlRemoveCommand.java |  5 +++++
 .../cellar/management/CellarFeaturesMBean.java  | 20 ++++++++++++++++++++
 .../internal/CellarFeaturesMBeanImpl.java       | 12 ++++++++++++
 6 files changed, 63 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/83431c10/features/src/main/java/org/apache/karaf/cellar/features/ClusterRepositoryEvent.java
----------------------------------------------------------------------
diff --git a/features/src/main/java/org/apache/karaf/cellar/features/ClusterRepositoryEvent.java b/features/src/main/java/org/apache/karaf/cellar/features/ClusterRepositoryEvent.java
index 2073d36..9480483 100644
--- a/features/src/main/java/org/apache/karaf/cellar/features/ClusterRepositoryEvent.java
+++ b/features/src/main/java/org/apache/karaf/cellar/features/ClusterRepositoryEvent.java
@@ -22,6 +22,8 @@ import org.apache.karaf.features.RepositoryEvent.EventType;
 public class ClusterRepositoryEvent extends Event {
 
 	private EventType type;
+    private Boolean install;
+    private Boolean uninstall;
 
     public ClusterRepositoryEvent(String id, EventType type) {
         super(id);
@@ -32,7 +34,23 @@ public class ClusterRepositoryEvent extends Event {
         return type;
     }
 
-	@Override
+    public Boolean getInstall() {
+        return install;
+    }
+
+    public void setInstall(Boolean install) {
+        this.install = install;
+    }
+
+    public Boolean getUninstall() {
+        return uninstall;
+    }
+
+    public void setUninstall(Boolean uninstall) {
+        this.uninstall = uninstall;
+    }
+
+    @Override
 	public String toString() {
 		return "ClusterRepositoryEvent [type=" + type + ", id=" + id
 				+ ", sourceNode=" + sourceNode + ", sourceGroup=" + sourceGroup

http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/83431c10/features/src/main/java/org/apache/karaf/cellar/features/RepositoryEventHandler.java
----------------------------------------------------------------------
diff --git a/features/src/main/java/org/apache/karaf/cellar/features/RepositoryEventHandler.java b/features/src/main/java/org/apache/karaf/cellar/features/RepositoryEventHandler.java
index 4077c57..21d43c7 100644
--- a/features/src/main/java/org/apache/karaf/cellar/features/RepositoryEventHandler.java
+++ b/features/src/main/java/org/apache/karaf/cellar/features/RepositoryEventHandler.java
@@ -77,14 +77,14 @@ public class RepositoryEventHandler extends FeaturesSupport implements EventHand
             if (RepositoryEvent.EventType.RepositoryAdded.equals(type)) {
                 if (!isRepositoryRegisteredLocally(uri)) {
                     LOGGER.debug("CELLAR FEATURES: adding repository URI {}", uri);
-                    featuresService.addRepository(new URI(uri));
+                    featuresService.addRepository(new URI(uri), event.getInstall());
                 } else {
                     LOGGER.debug("CELLAR FEATURES: repository URI {} is already registered locally");
                 }
             } else {
                 if (isRepositoryRegisteredLocally(uri)) {
                     LOGGER.debug("CELLAR FEATURES: removing repository URI {}", uri);
-                    featuresService.removeRepository(new URI(uri));
+                    featuresService.removeRepository(new URI(uri), event.getUninstall());
                 } else {
                     LOGGER.debug("CELLAR FEATURES: repository URI {} is not registered locally");
                 }

http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/83431c10/features/src/main/java/org/apache/karaf/cellar/features/shell/UrlAddCommand.java
----------------------------------------------------------------------
diff --git a/features/src/main/java/org/apache/karaf/cellar/features/shell/UrlAddCommand.java b/features/src/main/java/org/apache/karaf/cellar/features/shell/UrlAddCommand.java
index 83f3e01..2f66c2a 100644
--- a/features/src/main/java/org/apache/karaf/cellar/features/shell/UrlAddCommand.java
+++ b/features/src/main/java/org/apache/karaf/cellar/features/shell/UrlAddCommand.java
@@ -25,6 +25,7 @@ import org.apache.karaf.features.Repository;
 import org.apache.karaf.features.RepositoryEvent;
 import org.apache.karaf.shell.commands.Argument;
 import org.apache.karaf.shell.commands.Command;
+import org.apache.karaf.shell.commands.Option;
 
 import java.net.URI;
 import java.util.List;
@@ -39,6 +40,9 @@ public class UrlAddCommand extends FeatureCommandSupport {
     @Argument(index = 1, name = "urls", description = "One or more features repository URLs separated by whitespaces", required = true, multiValued = true)
     List<String> urls;
 
+    @Option(name = "-i", aliases = { "--install-all" }, description = "Install all features contained in the repository URLs", required = false, multiValued = false)
+    boolean install;
+
     private EventProducer eventProducer;
 
     @Override
@@ -118,6 +122,7 @@ public class UrlAddCommand extends FeatureCommandSupport {
 
                     // broadcast the cluster event
                     ClusterRepositoryEvent event = new ClusterRepositoryEvent(url, RepositoryEvent.EventType.RepositoryAdded);
+                    event.setInstall(install);
                     event.setSourceGroup(group);
                     eventProducer.produce(event);
                 } else {

http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/83431c10/features/src/main/java/org/apache/karaf/cellar/features/shell/UrlRemoveCommand.java
----------------------------------------------------------------------
diff --git a/features/src/main/java/org/apache/karaf/cellar/features/shell/UrlRemoveCommand.java b/features/src/main/java/org/apache/karaf/cellar/features/shell/UrlRemoveCommand.java
index 2e25b3b..d579282 100644
--- a/features/src/main/java/org/apache/karaf/cellar/features/shell/UrlRemoveCommand.java
+++ b/features/src/main/java/org/apache/karaf/cellar/features/shell/UrlRemoveCommand.java
@@ -25,6 +25,7 @@ import org.apache.karaf.features.Repository;
 import org.apache.karaf.features.RepositoryEvent;
 import org.apache.karaf.shell.commands.Argument;
 import org.apache.karaf.shell.commands.Command;
+import org.apache.karaf.shell.commands.Option;
 
 import java.net.URI;
 import java.util.List;
@@ -39,6 +40,9 @@ public class UrlRemoveCommand extends FeatureCommandSupport {
     @Argument(index = 1, name = "urls", description = "One or more features repository URLs separated by whitespaces", required = true, multiValued = true)
     List<String> urls;
 
+    @Option(name = "-u", aliases = { "--uninstall-all" }, description = "Uninstall all features contained in the repository URLs", required = false, multiValued = false)
+    boolean uninstall;
+
     private EventProducer eventProducer;
 
     @Override
@@ -115,6 +119,7 @@ public class UrlRemoveCommand extends FeatureCommandSupport {
 
                 // broadcast a cluster event
                 ClusterRepositoryEvent event = new ClusterRepositoryEvent(url, RepositoryEvent.EventType.RepositoryRemoved);
+                event.setUninstall(uninstall);
                 event.setSourceGroup(group);
                 eventProducer.produce(event);
             } else {

http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/83431c10/management/src/main/java/org/apache/karaf/cellar/management/CellarFeaturesMBean.java
----------------------------------------------------------------------
diff --git a/management/src/main/java/org/apache/karaf/cellar/management/CellarFeaturesMBean.java b/management/src/main/java/org/apache/karaf/cellar/management/CellarFeaturesMBean.java
index b380b41..7e85c17 100644
--- a/management/src/main/java/org/apache/karaf/cellar/management/CellarFeaturesMBean.java
+++ b/management/src/main/java/org/apache/karaf/cellar/management/CellarFeaturesMBean.java
@@ -31,6 +31,16 @@ public interface CellarFeaturesMBean {
     void addUrl(String group, String url) throws Exception;
 
     /**
+     * Add a features repository URL in a cluster group, eventually installing all features described in the repository.
+     *
+     * @param group the cluster group name.
+     * @param url the features repository URL.
+     * @param install true to install all features described in the repository URL.
+     * @throws Exception
+     */
+    void addUrl(String group, String url, boolean install) throws Exception;
+
+    /**
      * Remove a features repository URL from a cluster group.
      *
      * @param group the cluster group name.
@@ -40,6 +50,16 @@ public interface CellarFeaturesMBean {
     void removeUrl(String group, String url) throws Exception;
 
     /**
+     * Remove a features repository URL from a cluster group, eventually uninstalling all features described in the repository.
+     *
+     * @param group the cluster group name.
+     * @param url the features repository URL.
+     * @param uninstall true to uninstall all features described in the repository URL.
+     * @throws Exception
+     */
+    void removeUrl(String group, String url, boolean uninstall) throws Exception;
+
+    /**
      * Install a feature in a cluster group.
      *
      * @param group the cluster group name.

http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/83431c10/management/src/main/java/org/apache/karaf/cellar/management/internal/CellarFeaturesMBeanImpl.java
----------------------------------------------------------------------
diff --git a/management/src/main/java/org/apache/karaf/cellar/management/internal/CellarFeaturesMBeanImpl.java b/management/src/main/java/org/apache/karaf/cellar/management/internal/CellarFeaturesMBeanImpl.java
index b75c149..d353554 100644
--- a/management/src/main/java/org/apache/karaf/cellar/management/internal/CellarFeaturesMBeanImpl.java
+++ b/management/src/main/java/org/apache/karaf/cellar/management/internal/CellarFeaturesMBeanImpl.java
@@ -303,6 +303,11 @@ public class CellarFeaturesMBeanImpl extends StandardMBean implements CellarFeat
 
     @Override
     public void addUrl(String groupName, String url) throws Exception {
+        this.addUrl(groupName, url, false);
+    }
+
+    @Override
+    public void addUrl(String groupName, String url, boolean install) throws Exception {
         // check if the group exists
         Group group = groupManager.findGroupByName(groupName);
         if (group == null) {
@@ -373,6 +378,7 @@ public class CellarFeaturesMBeanImpl extends StandardMBean implements CellarFeat
 
                 // broadcast the cluster event
                 ClusterRepositoryEvent event = new ClusterRepositoryEvent(url, RepositoryEvent.EventType.RepositoryAdded);
+                event.setInstall(install);
                 event.setSourceGroup(group);
                 eventProducer.produce(event);
             } else {
@@ -385,6 +391,11 @@ public class CellarFeaturesMBeanImpl extends StandardMBean implements CellarFeat
 
     @Override
     public void removeUrl(String groupName, String url) throws Exception {
+        this.removeUrl(groupName, url, false);
+    }
+
+    @Override
+    public void removeUrl(String groupName, String url, boolean uninstall) throws Exception {
         // check if the group exists
         Group group = groupManager.findGroupByName(groupName);
         if (group == null) {
@@ -452,6 +463,7 @@ public class CellarFeaturesMBeanImpl extends StandardMBean implements CellarFeat
 
             // broadcast a cluster event
             ClusterRepositoryEvent event = new ClusterRepositoryEvent(url, RepositoryEvent.EventType.RepositoryRemoved);
+            event.setUninstall(uninstall);
             event.setSourceGroup(group);
             eventProducer.produce(event);
         } else {