Author: gnodet
Date: Fri Feb 22 04:33:39 2008
New Revision: 630174
URL: http://svn.apache.org/viewvc?rev=630174&view=rev
Log:
SMX4KNL-4: Add a start option on the 'osgi install' command so that the bundle
is automatically started
Modified:
servicemix/smx4/kernel/trunk/gshell/gshell-osgi/src/main/java/org/apache/geronimo/gshell/osgi/InstallBundle.java
Modified:
servicemix/smx4/kernel/trunk/gshell/gshell-osgi/src/main/java/org/apache/geronimo/gshell/osgi/InstallBundle.java
URL:
http://svn.apache.org/viewvc/servicemix/smx4/kernel/trunk/gshell/gshell-osgi/src/main/java/org/apache/geronimo/gshell/osgi/InstallBundle.java?rev=630174&r1=630173&r2=630174&view=diff
==============================================================================
---
servicemix/smx4/kernel/trunk/gshell/gshell-osgi/src/main/java/org/apache/geronimo/gshell/osgi/InstallBundle.java
(original)
+++
servicemix/smx4/kernel/trunk/gshell/gshell-osgi/src/main/java/org/apache/geronimo/gshell/osgi/InstallBundle.java
Fri Feb 22 04:33:39 2008
@@ -17,9 +17,11 @@
package org.apache.geronimo.gshell.osgi;
import java.io.PrintWriter;
+import java.util.ArrayList;
import java.util.List;
import org.apache.geronimo.gshell.clp.Argument;
+import org.apache.geronimo.gshell.clp.Option;
import org.apache.geronimo.gshell.command.annotation.CommandComponent;
import org.apache.geronimo.gshell.support.OsgiCommandSupport;
import org.osgi.framework.Bundle;
@@ -38,15 +40,25 @@
@Argument(required = true, multiValued = true, description = "Bundle URLs")
List<String> urls;
+ @Option(name = "-s", aliases={"--start"}, description="Start the bundles
after installation")
+ boolean start;
+
protected Object doExecute() throws Exception {
+ List<Bundle> bundles = new ArrayList<Bundle>();
StringBuffer sb = new StringBuffer();
for (String url : urls) {
Bundle bundle = install(url, io.out, io.err);
+ bundles.add(bundle);
if (bundle != null) {
if (sb.length() > 0) {
sb.append(", ");
}
sb.append(bundle.getBundleId());
+ }
+ }
+ if (start) {
+ for (Bundle bundle : bundles) {
+ bundle.start();
}
}
if (sb.toString().indexOf(',') > 0) {