Author: anierbeck
Date: Tue May 21 20:11:26 2013
New Revision: 1484933

URL: http://svn.apache.org/r1484933
Log:
[KARAF-2298] - Karaf shell option for a "transient" bundle stop

Modified:
    
karaf/branches/karaf-2.x/shell/osgi/src/main/java/org/apache/karaf/shell/osgi/StopBundle.java

Modified: 
karaf/branches/karaf-2.x/shell/osgi/src/main/java/org/apache/karaf/shell/osgi/StopBundle.java
URL: 
http://svn.apache.org/viewvc/karaf/branches/karaf-2.x/shell/osgi/src/main/java/org/apache/karaf/shell/osgi/StopBundle.java?rev=1484933&r1=1484932&r2=1484933&view=diff
==============================================================================
--- 
karaf/branches/karaf-2.x/shell/osgi/src/main/java/org/apache/karaf/shell/osgi/StopBundle.java
 (original)
+++ 
karaf/branches/karaf-2.x/shell/osgi/src/main/java/org/apache/karaf/shell/osgi/StopBundle.java
 Tue May 21 20:11:26 2013
@@ -22,10 +22,14 @@ import java.util.List;
 import org.apache.karaf.shell.console.MultiException;
 import org.osgi.framework.Bundle;
 import org.apache.felix.gogo.commands.Command;
+import org.apache.felix.gogo.commands.Option;
 
 @Command(scope = "osgi", name = "stop", description = "Stop bundle(s).")
 public class StopBundle extends BundlesCommand {
        
+       @Option(name = "-t", aliases={"--transient"}, description="Keep the 
bundle as auto-start", required = false, multiValued = false)
+       boolean transientStop;
+       
        protected void doExecute(List<Bundle> bundles) throws Exception {
         if (bundles.isEmpty()) {
             System.err.println("No bundles specified.");
@@ -34,7 +38,11 @@ public class StopBundle extends BundlesC
         List<Exception> exceptions = new ArrayList<Exception>();
         for (Bundle bundle : bundles) {
             try {
-                bundle.stop();
+               if (transientStop) {
+                       bundle.stop(Bundle.STOP_TRANSIENT);
+               } else {
+                       bundle.stop();
+               }
             } catch (Exception e) {
                 exceptions.add(new Exception("Unable to stop bundle " + 
bundle.getBundleId() +
                         (e.getMessage() != null ? ": " + e.getMessage() : ""), 
e));


Reply via email to