karaf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jbono...@apache.org
Subject git commit: [KARAF-2797] Add support of verbose and noRefresh on feature uninstall
Date Wed, 05 Mar 2014 06:38:57 GMT
Repository: karaf
Updated Branches:
  refs/heads/karaf-2.3.x b571278c0 -> 66e23c469


[KARAF-2797] Add support of verbose and noRefresh on feature uninstall


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

Branch: refs/heads/karaf-2.3.x
Commit: 66e23c4698c56fb33836d8705fbf18d84fa5d05d
Parents: b571278
Author: Jean-Baptiste Onofré <jbonofre@apache.org>
Authored: Wed Mar 5 07:25:06 2014 +0100
Committer: Jean-Baptiste Onofré <jbonofre@apache.org>
Committed: Wed Mar 5 07:28:45 2014 +0100

----------------------------------------------------------------------
 .../command/UninstallFeatureCommand.java        | 19 +++++++++++++++--
 .../apache/karaf/features/FeaturesService.java  |  4 ++++
 .../features/internal/FeaturesServiceImpl.java  | 22 ++++++++++++++++++--
 .../management/FeaturesServiceMBean.java        |  4 ++++
 .../internal/FeaturesServiceMBeanImpl.java      | 16 ++++++++++++++
 .../karaf/tooling/features/InstallKarsMojo.java |  6 ++++++
 6 files changed, 67 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/karaf/blob/66e23c46/features/command/src/main/java/org/apache/karaf/features/command/UninstallFeatureCommand.java
----------------------------------------------------------------------
diff --git a/features/command/src/main/java/org/apache/karaf/features/command/UninstallFeatureCommand.java
b/features/command/src/main/java/org/apache/karaf/features/command/UninstallFeatureCommand.java
index 0399046..154ffe9 100644
--- a/features/command/src/main/java/org/apache/karaf/features/command/UninstallFeatureCommand.java
+++ b/features/command/src/main/java/org/apache/karaf/features/command/UninstallFeatureCommand.java
@@ -18,8 +18,10 @@ package org.apache.karaf.features.command;
 
 import org.apache.felix.gogo.commands.Argument;
 import org.apache.felix.gogo.commands.Command;
+import org.apache.felix.gogo.commands.Option;
 import org.apache.karaf.features.FeaturesService;
 
+import java.util.EnumSet;
 import java.util.List;
 
 @Command(scope = "features", name = "uninstall", description = "Uninstalls a feature with
the specified name and version.")
@@ -28,8 +30,21 @@ public class UninstallFeatureCommand extends FeaturesCommandSupport {
     @Argument(index = 0, name = "features", description = "The name and version of the features
to uninstall. A feature id looks like name/version. The version is optional.", required =
true, multiValued = true)
     List<String> features;
 
+    @Option(name = "-r", aliases = "--no-auto-refresh", description = "Do not automatically
refresh bundles", required = false, multiValued = false)
+    boolean noRefresh;
+
+    @Option(name = "-v", aliases = "--verbose", description = "Explain what is being done",
required = false, multiValued = false)
+    boolean verbose;
+
     protected void doExecute(FeaturesService admin) throws Exception {
         // iterate in the provided feature
+        EnumSet<FeaturesService.Option> options = EnumSet.noneOf(FeaturesService.Option.class);
+        if (noRefresh) {
+            options.add(FeaturesService.Option.NoAutoRefreshBundles);
+        }
+        if (verbose) {
+            options.add(FeaturesService.Option.Verbose);
+        }
         for (String feature : features) {
             String[] split = feature.split("/");
             String name = split[0];
@@ -38,9 +53,9 @@ public class UninstallFeatureCommand extends FeaturesCommandSupport {
                 version = split[1];
             }
     	    if (version != null && version.length() > 0) {
-    		    admin.uninstallFeature(name, version);
+    		    admin.uninstallFeature(name, version, options);
     	    } else {
-    		    admin.uninstallFeature(name );
+    		    admin.uninstallFeature(name, options);
     	    }
         }
     }

http://git-wip-us.apache.org/repos/asf/karaf/blob/66e23c46/features/core/src/main/java/org/apache/karaf/features/FeaturesService.java
----------------------------------------------------------------------
diff --git a/features/core/src/main/java/org/apache/karaf/features/FeaturesService.java b/features/core/src/main/java/org/apache/karaf/features/FeaturesService.java
index c3a2795..62fc96b 100644
--- a/features/core/src/main/java/org/apache/karaf/features/FeaturesService.java
+++ b/features/core/src/main/java/org/apache/karaf/features/FeaturesService.java
@@ -66,9 +66,13 @@ public interface FeaturesService {
     void installFeatures(Set<Feature> features, EnumSet<Option> options) throws
Exception;
 
     void uninstallFeature(String name) throws Exception;
+
+    void uninstallFeature(String name, EnumSet<Option> options) throws Exception;
     
     void uninstallFeature(String name, String version) throws Exception;
 
+    void uninstallFeature(String name, String version, EnumSet<Option> options) throws
Exception;
+
     Feature[] listFeatures() throws Exception;
 
     Feature[] listInstalledFeatures();

http://git-wip-us.apache.org/repos/asf/karaf/blob/66e23c46/features/core/src/main/java/org/apache/karaf/features/internal/FeaturesServiceImpl.java
----------------------------------------------------------------------
diff --git a/features/core/src/main/java/org/apache/karaf/features/internal/FeaturesServiceImpl.java
b/features/core/src/main/java/org/apache/karaf/features/internal/FeaturesServiceImpl.java
index eec1ec0..2114692 100644
--- a/features/core/src/main/java/org/apache/karaf/features/internal/FeaturesServiceImpl.java
+++ b/features/core/src/main/java/org/apache/karaf/features/internal/FeaturesServiceImpl.java
@@ -946,6 +946,10 @@ public class FeaturesServiceImpl implements FeaturesService, FrameworkListener
{
     }
 
     public void uninstallFeature(String name) throws Exception {
+        uninstallFeature(name, EnumSet.noneOf(Option.class));
+    }
+
+    public void uninstallFeature(String name, EnumSet<Option> options) throws Exception
{
         List<String> versions = new ArrayList<String>();
         for (Feature f : installed.keySet()) {
             if (name.equals(f.getName())) {
@@ -966,15 +970,24 @@ public class FeaturesServiceImpl implements FeaturesService, FrameworkListener
{
             sb.append("). Please specify the version to uninstall.");
             throw new Exception(sb.toString());
         }
-        uninstallFeature(name, versions.get(0));
+        uninstallFeature(name, versions.get(0), options);
     }
 
     public void uninstallFeature(String name, String version) throws Exception {
+        uninstallFeature(name, version, EnumSet.noneOf(Option.class));
+    }
+
+    public void uninstallFeature(String name, String version, EnumSet<Option> options)
throws Exception {
         Feature feature = getFeature(name, version);
         if (feature == null || !installed.containsKey(feature)) {
             throw new Exception("Feature named '" + name
                     + "' with version '" + version + "' is not installed");
         }
+        boolean verbose = options != null && options.contains(Option.Verbose);
+        boolean refresh = options == null || !options.contains(Option.NoAutoRefreshBundles);
+        if (verbose) {
+            System.out.println("Uninstalling feature " + feature.getName() + " " + feature.getVersion());
+        }
         // Grab all the bundles installed by this feature
         // and remove all those who will still be in use.
         // This gives this list of bundles to uninstall.
@@ -988,7 +1001,12 @@ public class FeaturesServiceImpl implements FeaturesService, FrameworkListener
{
                 b.uninstall();
             }
         }
-        refreshPackages(null);
+        if (refresh) {
+            if (verbose) {
+                System.out.println("Refreshing packages");
+            }
+            refreshPackages(null);
+        }
         callListeners(new FeatureEvent(feature, FeatureEvent.EventType.FeatureUninstalled,
false));
         saveState();
     }

http://git-wip-us.apache.org/repos/asf/karaf/blob/66e23c46/features/management/src/main/java/org/apache/karaf/features/management/FeaturesServiceMBean.java
----------------------------------------------------------------------
diff --git a/features/management/src/main/java/org/apache/karaf/features/management/FeaturesServiceMBean.java
b/features/management/src/main/java/org/apache/karaf/features/management/FeaturesServiceMBean.java
index 4dc65a8..da4a36e 100644
--- a/features/management/src/main/java/org/apache/karaf/features/management/FeaturesServiceMBean.java
+++ b/features/management/src/main/java/org/apache/karaf/features/management/FeaturesServiceMBean.java
@@ -46,8 +46,12 @@ public interface FeaturesServiceMBean {
 
     void uninstallFeature(String name) throws Exception;
 
+    void uninstallFeature(String name, boolean noRefresh) throws Exception;
+
     void uninstallFeature(String name, String version) throws Exception;
 
+    void uninstallFeature(String name, String version, boolean noRefresh) throws Exception;
+
     String FEATURE_NAME = "Name";
 
     String FEATURE_VERSION = "Version";

http://git-wip-us.apache.org/repos/asf/karaf/blob/66e23c46/features/management/src/main/java/org/apache/karaf/features/management/internal/FeaturesServiceMBeanImpl.java
----------------------------------------------------------------------
diff --git a/features/management/src/main/java/org/apache/karaf/features/management/internal/FeaturesServiceMBeanImpl.java
b/features/management/src/main/java/org/apache/karaf/features/management/internal/FeaturesServiceMBeanImpl.java
index a8a01ea..576da91 100644
--- a/features/management/src/main/java/org/apache/karaf/features/management/internal/FeaturesServiceMBeanImpl.java
+++ b/features/management/src/main/java/org/apache/karaf/features/management/internal/FeaturesServiceMBeanImpl.java
@@ -206,10 +206,26 @@ public class FeaturesServiceMBeanImpl extends StandardEmitterMBean implements
         featuresService.uninstallFeature(name);
     }
 
+    public void uninstallFeature(String name, boolean noRefresh) throws Exception {
+        EnumSet<FeaturesService.Option> options = EnumSet.noneOf(FeaturesService.Option.class);
+        if (noRefresh) {
+            options.add(FeaturesService.Option.NoAutoRefreshBundles);
+        }
+        featuresService.uninstallFeature(name, options);
+    }
+
     public void uninstallFeature(String name, String version) throws Exception {
         featuresService.uninstallFeature(name, version);
     }
 
+    public void uninstallFeature(String name, String version, boolean noRefresh) throws Exception
{
+        EnumSet<FeaturesService.Option> options = EnumSet.noneOf(FeaturesService.Option.class);
+        if (noRefresh) {
+            options.add(FeaturesService.Option.NoAutoRefreshBundles);
+        }
+        featuresService.uninstallFeature(name, version, options);
+    }
+
     public void setBundleContext(BundleContext bundleContext) {
         this.bundleContext = bundleContext;
     }

http://git-wip-us.apache.org/repos/asf/karaf/blob/66e23c46/tooling/features-maven-plugin/src/main/java/org/apache/karaf/tooling/features/InstallKarsMojo.java
----------------------------------------------------------------------
diff --git a/tooling/features-maven-plugin/src/main/java/org/apache/karaf/tooling/features/InstallKarsMojo.java
b/tooling/features-maven-plugin/src/main/java/org/apache/karaf/tooling/features/InstallKarsMojo.java
index c9062e8..d647160 100644
--- a/tooling/features-maven-plugin/src/main/java/org/apache/karaf/tooling/features/InstallKarsMojo.java
+++ b/tooling/features-maven-plugin/src/main/java/org/apache/karaf/tooling/features/InstallKarsMojo.java
@@ -162,9 +162,15 @@ public class InstallKarsMojo extends MojoSupport {
         public void uninstallFeature(String name) throws Exception {
         }
 
+        public void uninstallFeature(String name, EnumSet<Option> options) {
+        }
+
         public void uninstallFeature(String name, String version) throws Exception {
         }
 
+        public void uninstallFeature(String name, String version, EnumSet<Option> options)
{
+        }
+
         public Feature[] listFeatures() throws Exception {
             return new Feature[0];
         }


Mime
View raw message