Author: gnodet
Date: Wed Dec  5 07:25:07 2007
New Revision: 601360

URL: http://svn.apache.org/viewvc?rev=601360&view=rev
Log:
Fix gshell layout, add osgi/install command, remove delay before starting gshell

Added:
    
servicemix/branches/servicemix-4.0/runtime/gshell/gshell-osgi/src/main/java/org/apache/geronimo/gshell/osgi/InstallBundle.java
Modified:
    
servicemix/branches/servicemix-4.0/runtime/gshell/gshell-core/src/main/java/org/apache/geronimo/gshell/spring/GShell.java
    
servicemix/branches/servicemix-4.0/runtime/gshell/gshell-osgi/src/main/java/org/apache/geronimo/gshell/osgi/BundleCommand.java
    
servicemix/branches/servicemix-4.0/runtime/gshell/gshell-osgi/src/main/java/org/apache/geronimo/gshell/osgi/BundleLevel.java
    
servicemix/branches/servicemix-4.0/runtime/gshell/gshell-osgi/src/main/java/org/apache/geronimo/gshell/osgi/StartLevel.java
    
servicemix/branches/servicemix-4.0/runtime/gshell/gshell-osgi/src/main/resources/META-INF/spring/gshell-osgi.xml
    
servicemix/branches/servicemix-4.0/runtime/minimum/src/main/release/etc/layout.xml

Modified: 
servicemix/branches/servicemix-4.0/runtime/gshell/gshell-core/src/main/java/org/apache/geronimo/gshell/spring/GShell.java
URL: 
http://svn.apache.org/viewvc/servicemix/branches/servicemix-4.0/runtime/gshell/gshell-core/src/main/java/org/apache/geronimo/gshell/spring/GShell.java?rev=601360&r1=601359&r2=601360&view=diff
==============================================================================
--- 
servicemix/branches/servicemix-4.0/runtime/gshell/gshell-core/src/main/java/org/apache/geronimo/gshell/spring/GShell.java
 (original)
+++ 
servicemix/branches/servicemix-4.0/runtime/gshell/gshell-core/src/main/java/org/apache/geronimo/gshell/spring/GShell.java
 Wed Dec  5 07:25:07 2007
@@ -65,7 +65,6 @@
         IOTargetSource.setIO(io);
         EnvironmentTargetSource.setEnvironment(env);
         try {
-            Thread.sleep(5000);
             shell.run();
         } catch (Exception e) {
             e.printStackTrace();

Modified: 
servicemix/branches/servicemix-4.0/runtime/gshell/gshell-osgi/src/main/java/org/apache/geronimo/gshell/osgi/BundleCommand.java
URL: 
http://svn.apache.org/viewvc/servicemix/branches/servicemix-4.0/runtime/gshell/gshell-osgi/src/main/java/org/apache/geronimo/gshell/osgi/BundleCommand.java?rev=601360&r1=601359&r2=601360&view=diff
==============================================================================
--- 
servicemix/branches/servicemix-4.0/runtime/gshell/gshell-osgi/src/main/java/org/apache/geronimo/gshell/osgi/BundleCommand.java
 (original)
+++ 
servicemix/branches/servicemix-4.0/runtime/gshell/gshell-osgi/src/main/java/org/apache/geronimo/gshell/osgi/BundleCommand.java
 Wed Dec  5 07:25:07 2007
@@ -29,7 +29,7 @@
  */
 public abstract class BundleCommand extends OsgiCommandSupport {
 
-    @Argument(required = true)
+    @Argument(required = true, index = 0)
     long id;
 
     protected Object doExecute() throws Exception {

Modified: 
servicemix/branches/servicemix-4.0/runtime/gshell/gshell-osgi/src/main/java/org/apache/geronimo/gshell/osgi/BundleLevel.java
URL: 
http://svn.apache.org/viewvc/servicemix/branches/servicemix-4.0/runtime/gshell/gshell-osgi/src/main/java/org/apache/geronimo/gshell/osgi/BundleLevel.java?rev=601360&r1=601359&r2=601360&view=diff
==============================================================================
--- 
servicemix/branches/servicemix-4.0/runtime/gshell/gshell-osgi/src/main/java/org/apache/geronimo/gshell/osgi/BundleLevel.java
 (original)
+++ 
servicemix/branches/servicemix-4.0/runtime/gshell/gshell-osgi/src/main/java/org/apache/geronimo/gshell/osgi/BundleLevel.java
 Wed Dec  5 07:25:07 2007
@@ -29,10 +29,10 @@
  * Time: 12:37:30 PM
  * To change this template use File | Settings | File Templates.
  */
[EMAIL PROTECTED](id="osgi:bundlelevel", description="Get or set the start 
level of a given bundle")
[EMAIL PROTECTED](id="osgi:bundleLevel", description="Get or set the start 
level of a given bundle")
 public class BundleLevel extends BundleCommand {
 
-    @Argument
+    @Argument(required = false, index = 1)
     Integer level;
 
     protected void doExecute(Bundle bundle) throws Exception {

Added: 
servicemix/branches/servicemix-4.0/runtime/gshell/gshell-osgi/src/main/java/org/apache/geronimo/gshell/osgi/InstallBundle.java
URL: 
http://svn.apache.org/viewvc/servicemix/branches/servicemix-4.0/runtime/gshell/gshell-osgi/src/main/java/org/apache/geronimo/gshell/osgi/InstallBundle.java?rev=601360&view=auto
==============================================================================
--- 
servicemix/branches/servicemix-4.0/runtime/gshell/gshell-osgi/src/main/java/org/apache/geronimo/gshell/osgi/InstallBundle.java
 (added)
+++ 
servicemix/branches/servicemix-4.0/runtime/gshell/gshell-osgi/src/main/java/org/apache/geronimo/gshell/osgi/InstallBundle.java
 Wed Dec  5 07:25:07 2007
@@ -0,0 +1,76 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.geronimo.gshell.osgi;
+
+import java.io.PrintWriter;
+import java.util.List;
+
+import org.apache.geronimo.gshell.clp.Argument;
+import org.apache.geronimo.gshell.command.annotation.CommandComponent;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleException;
+
+/**
+ * Created by IntelliJ IDEA.
+ * User: gnodet
+ * Date: Dec 5, 2007
+ * Time: 3:32:15 PM
+ * To change this template use File | Settings | File Templates.
+ */
[EMAIL PROTECTED](id="osgi:install", description="Install bundle")
+public class InstallBundle extends OsgiCommandSupport {
+
+    @Argument(required = true, multiValued = true, description = "Bundle URLs")
+    List<String> urls;
+
+    protected Object doExecute() throws Exception {
+        StringBuffer sb = new StringBuffer();
+        for (String url : urls) {
+            Bundle bundle = install(url, io.out, io.err);
+            if (bundle != null) {
+                if (sb.length() > 0) {
+                    sb.append(", ");
+                }
+                sb.append(bundle.getBundleId());
+            }
+        }
+        if (sb.toString().indexOf(',') > 0) {
+            io.out.println("Bundle IDs: " + sb.toString());
+        } else if (sb.length() > 0) {
+            io.out.println("Bundle ID: " + sb.toString());
+        }
+        return null;
+    }
+
+    protected Bundle install(String location, PrintWriter out, PrintWriter 
err) {
+        try {
+            return getBundleContext().installBundle(location, null);
+        } catch (IllegalStateException ex) {
+            err.println(ex.toString());
+        } catch (BundleException ex) {
+            if (ex.getNestedException() != null) {
+                err.println(ex.getNestedException().toString());
+            } else {
+                err.println(ex.toString());
+            }
+        } catch (Exception ex) {
+            err.println(ex.toString());
+        }
+        return null;
+    }
+
+}

Modified: 
servicemix/branches/servicemix-4.0/runtime/gshell/gshell-osgi/src/main/java/org/apache/geronimo/gshell/osgi/StartLevel.java
URL: 
http://svn.apache.org/viewvc/servicemix/branches/servicemix-4.0/runtime/gshell/gshell-osgi/src/main/java/org/apache/geronimo/gshell/osgi/StartLevel.java?rev=601360&r1=601359&r2=601360&view=diff
==============================================================================
--- 
servicemix/branches/servicemix-4.0/runtime/gshell/gshell-osgi/src/main/java/org/apache/geronimo/gshell/osgi/StartLevel.java
 (original)
+++ 
servicemix/branches/servicemix-4.0/runtime/gshell/gshell-osgi/src/main/java/org/apache/geronimo/gshell/osgi/StartLevel.java
 Wed Dec  5 07:25:07 2007
@@ -29,10 +29,10 @@
  * Time: 12:37:30 PM
  * To change this template use File | Settings | File Templates.
  */
[EMAIL PROTECTED](id="osgi:startlevel", description="Get or set the start 
level")
[EMAIL PROTECTED](id="osgi:startLevel", description="Get or set the start 
level")
 public class StartLevel extends OsgiCommandSupport {
 
-    @Argument
+    @Argument(required = false, index = 0)
     Integer level;
 
     protected Object doExecute() throws Exception {

Modified: 
servicemix/branches/servicemix-4.0/runtime/gshell/gshell-osgi/src/main/resources/META-INF/spring/gshell-osgi.xml
URL: 
http://svn.apache.org/viewvc/servicemix/branches/servicemix-4.0/runtime/gshell/gshell-osgi/src/main/resources/META-INF/spring/gshell-osgi.xml?rev=601360&r1=601359&r2=601360&view=diff
==============================================================================
--- 
servicemix/branches/servicemix-4.0/runtime/gshell/gshell-osgi/src/main/resources/META-INF/spring/gshell-osgi.xml
 (original)
+++ 
servicemix/branches/servicemix-4.0/runtime/gshell/gshell-osgi/src/main/resources/META-INF/spring/gshell-osgi.xml
 Wed Dec  5 07:25:07 2007
@@ -33,6 +33,8 @@
 
     <bean id="headers" class="org.apache.geronimo.gshell.osgi.Headers" />
 
+    <bean id="install-bundle" 
class="org.apache.geronimo.gshell.osgi.InstallBundle" />
+
     <bean id="list-bundles" 
class="org.apache.geronimo.gshell.osgi.ListBundles" />
 
     <bean id="list-services" 
class="org.apache.geronimo.gshell.osgi.ListServices" />
@@ -54,6 +56,8 @@
     <osgi:service ref="bundle-level" 
interface="org.apache.geronimo.gshell.command.Command" />
 
     <osgi:service ref="headers" 
interface="org.apache.geronimo.gshell.command.Command" />
+
+    <osgi:service ref="install-bundle" 
interface="org.apache.geronimo.gshell.command.Command" />
 
     <osgi:service ref="list-bundles" 
interface="org.apache.geronimo.gshell.command.Command" />
 

Modified: 
servicemix/branches/servicemix-4.0/runtime/minimum/src/main/release/etc/layout.xml
URL: 
http://svn.apache.org/viewvc/servicemix/branches/servicemix-4.0/runtime/minimum/src/main/release/etc/layout.xml?rev=601360&r1=601359&r2=601360&view=diff
==============================================================================
--- 
servicemix/branches/servicemix-4.0/runtime/minimum/src/main/release/etc/layout.xml
 (original)
+++ 
servicemix/branches/servicemix-4.0/runtime/minimum/src/main/release/etc/layout.xml
 Wed Dec  5 07:25:07 2007
@@ -93,12 +93,16 @@
                     <id>osgi:headers</id>
                 </command>
                 <command>
+                    <name>install</name>
+                    <id>osgi:install</id>
+                </command>
+                <command>
                     <name>listBundles</name>
                     <id>osgi:listBundles</id>
                 </command>
                 <alias>
                     <name>lb</name>
-                    <command>osgi:listBundles</command>
+                    <command>osgi/listBundles</command>
                 </alias>
                 <command>
                     <name>listBundles</name>
@@ -110,7 +114,7 @@
                 </command>
                 <alias>
                     <name>ls</name>
-                    <command>osgi:listServices</command>
+                    <command>osgi/listServices</command>
                 </alias>
                 <command>
                     <name>refresh</name>
@@ -185,4 +189,4 @@
     </nodes>
 
 </layout>
-        
\ No newline at end of file
+        


Reply via email to