Add support for enabling bundle activation policy when starting the bundle;
this is achieved by using "start -p" to enabled the bundle's declared
activation policy. (FELIX-1181)


git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@779753 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/shell/src/main/java/org/apache/felix/shell/impl/StartCommandImpl.java b/shell/src/main/java/org/apache/felix/shell/impl/StartCommandImpl.java
index 5d81fb5..4646254 100644
--- a/shell/src/main/java/org/apache/felix/shell/impl/StartCommandImpl.java
+++ b/shell/src/main/java/org/apache/felix/shell/impl/StartCommandImpl.java
@@ -29,6 +29,7 @@
 public class StartCommandImpl extends InstallCommandImpl implements Command
 {
     private static final String TRANSIENT_SWITCH = "-t";
+    private static final String POLICY_SWITCH = "-p";
 
     private BundleContext m_context = null;
 
@@ -45,7 +46,7 @@
 
     public String getUsage()
     {
-        return "start [-t] <id> [<id> <URL> ...]";
+        return "start [-t | -p] <id> [<id> <URL> ...]";
     }
 
     public String getShortDescription()
@@ -67,15 +68,23 @@
             tokens.add(st.nextToken());
         }
 
-        // Default switch value.
-        boolean isTransient = false;
+        // Default switch values.
+        int options = 0;
 
         // Check for "transient" switch.
         if (tokens.contains(TRANSIENT_SWITCH))
         {
             // Remove the switch and set boolean flag.
             tokens.remove(TRANSIENT_SWITCH);
-            isTransient = true;
+            options |= Bundle.START_TRANSIENT;
+        }
+
+        // Check for "start policy" switch.
+        if (tokens.contains(POLICY_SWITCH))
+        {
+            // Remove the switch and set boolean flag.
+            tokens.remove(POLICY_SWITCH);
+            options |= Bundle.START_ACTIVATION_POLICY;
         }
 
         // There should be at least one bundle id.
@@ -102,7 +111,7 @@
 
                     if (bundle != null)
                     {
-                        bundle.start(isTransient ? Bundle.START_TRANSIENT : 0);
+                        bundle.start(options);
                     }
                     else
                     {
diff --git a/shell/src/main/java/org/apache/felix/shell/impl/StopCommandImpl.java b/shell/src/main/java/org/apache/felix/shell/impl/StopCommandImpl.java
index 01b4d9c..89464a8 100644
--- a/shell/src/main/java/org/apache/felix/shell/impl/StopCommandImpl.java
+++ b/shell/src/main/java/org/apache/felix/shell/impl/StopCommandImpl.java
@@ -67,14 +67,14 @@
         }
 
         // Default switch value.
-        boolean isTransient = false;
+        int options = 0;
 
         // Check for "transient" switch.
         if (tokens.contains(TRANSIENT_SWITCH))
         {
             // Remove the switch and set boolean flag.
             tokens.remove(TRANSIENT_SWITCH);
-            isTransient = true;
+            options |= Bundle.STOP_TRANSIENT;
         }
 
         // There should be at least one bundle id.
@@ -90,7 +90,7 @@
                     Bundle bundle = m_context.getBundle(l);
                     if (bundle != null)
                     {
-                        bundle.stop(isTransient ? Bundle.STOP_TRANSIENT : 0);
+                        bundle.stop(options);
                     }
                     else
                     {