servicemix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gno...@apache.org
Subject svn commit: r584592 - in /incubator/servicemix/branches/servicemix-4.0: bundles/ bundles/cglib/ gshell/ gshell/gshell-core/ gshell/gshell-core/src/main/resources/META-INF/spring/ gshell/gshell-osgi/ gshell/gshell-osgi/src/main/java/org/apache/geronimo/...
Date Sun, 14 Oct 2007 19:35:59 GMT
Author: gnodet
Date: Sun Oct 14 12:35:57 2007
New Revision: 584592

URL: http://svn.apache.org/viewvc?rev=584592&view=rev
Log:
Use out own version of cglib bundle, improve osgi commands

Added:
    incubator/servicemix/branches/servicemix-4.0/bundles/cglib/   (with props)
    incubator/servicemix/branches/servicemix-4.0/bundles/cglib/pom.xml
    incubator/servicemix/branches/servicemix-4.0/gshell/gshell-osgi/src/main/java/org/apache/geronimo/gshell/osgi/BundleLevel.java
      - copied, changed from r584225, incubator/servicemix/branches/servicemix-4.0/gshell/gshell-osgi/src/main/java/org/apache/geronimo/gshell/osgi/StartLevel.java
    incubator/servicemix/branches/servicemix-4.0/gshell/gshell-osgi/src/main/java/org/apache/geronimo/gshell/osgi/BundlesCommand.java
      - copied, changed from r584225, incubator/servicemix/branches/servicemix-4.0/gshell/gshell-osgi/src/main/java/org/apache/geronimo/gshell/osgi/BundleCommand.java
    incubator/servicemix/branches/servicemix-4.0/gshell/gshell-osgi/src/main/java/org/apache/geronimo/gshell/osgi/Headers.java
      - copied, changed from r584225, incubator/servicemix/branches/servicemix-4.0/gshell/gshell-osgi/src/main/java/org/apache/geronimo/gshell/osgi/StartBundle.java
    incubator/servicemix/branches/servicemix-4.0/gshell/gshell-osgi/src/main/java/org/apache/geronimo/gshell/osgi/ListServices.java
      - copied, changed from r584225, incubator/servicemix/branches/servicemix-4.0/gshell/gshell-osgi/src/main/java/org/apache/geronimo/gshell/osgi/ListBundles.java
    incubator/servicemix/branches/servicemix-4.0/gshell/gshell-osgi/src/main/java/org/apache/geronimo/gshell/osgi/Util.java
Removed:
    incubator/servicemix/branches/servicemix-4.0/gshell/pax-runner.txt
Modified:
    incubator/servicemix/branches/servicemix-4.0/bundles/pom.xml
    incubator/servicemix/branches/servicemix-4.0/gshell/gshell-core/pom.xml
    incubator/servicemix/branches/servicemix-4.0/gshell/gshell-core/src/main/resources/META-INF/spring/gshell-local.xml
    incubator/servicemix/branches/servicemix-4.0/gshell/gshell-core/src/main/resources/META-INF/spring/gshell-osgi.xml
    incubator/servicemix/branches/servicemix-4.0/gshell/gshell-osgi/pom.xml
    incubator/servicemix/branches/servicemix-4.0/gshell/gshell-osgi/src/main/java/org/apache/geronimo/gshell/osgi/OsgiCommandSupport.java
    incubator/servicemix/branches/servicemix-4.0/gshell/gshell-osgi/src/main/java/org/apache/geronimo/gshell/osgi/StartLevel.java
    incubator/servicemix/branches/servicemix-4.0/gshell/gshell-osgi/src/main/resources/META-INF/spring/gshell-commands.xml
    incubator/servicemix/branches/servicemix-4.0/gshell/gshell-osgi/src/main/resources/META-INF/spring/gshell-osgi.xml
    incubator/servicemix/branches/servicemix-4.0/gshell/pom.xml

Propchange: incubator/servicemix/branches/servicemix-4.0/bundles/cglib/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Sun Oct 14 12:35:57 2007
@@ -0,0 +1 @@
+target

Added: incubator/servicemix/branches/servicemix-4.0/bundles/cglib/pom.xml
URL: http://svn.apache.org/viewvc/incubator/servicemix/branches/servicemix-4.0/bundles/cglib/pom.xml?rev=584592&view=auto
==============================================================================
--- incubator/servicemix/branches/servicemix-4.0/bundles/cglib/pom.xml (added)
+++ incubator/servicemix/branches/servicemix-4.0/bundles/cglib/pom.xml Sun Oct 14 12:35:57
2007
@@ -0,0 +1,58 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!-- 
+    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. 
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+    <parent>
+        <groupId>org.apache.servicemix</groupId>
+        <artifactId>bundles</artifactId>
+        <version>4.0-SNAPSHOT</version>
+    </parent>
+    <properties>
+        <pkgArtifactId>cglib</pkgArtifactId>
+        <pkgVersion>2.1_3</pkgVersion>
+        <pomVersion>4.0-SNAPSHOT</pomVersion>
+	    <servicemix.osgi.export.pkg>
+            net.sf.cglib*
+        </servicemix.osgi.export.pkg>
+	    <servicemix.osgi.import.pkg>
+            org.apache.tools.ant*;resolution:=optional,
+            org.codehaus.aspectwerkz.hook;resolution:=optional,
+            *
+	    </servicemix.osgi.import.pkg>
+    </properties>
+    <groupId>org.apache.servicemix.bundles</groupId>
+    <artifactId>${pom.groupId}.${pkgArtifactId}</artifactId>
+    <version>${pkgVersion}-${pomVersion}</version>
+    <packaging>bundle</packaging>
+    <name>ServiceMix OSGI Common Bundles: ${pkgArtifactId}</name>
+    <description>
+        This bundle simply wraps ${pkgArtifactId}-${pkgVersion}.jar.
+    </description>
+    <dependencies>
+        <dependency>
+            <groupId>cglib</groupId>
+            <artifactId>cglib-nodep</artifactId>
+            <version>${pkgVersion}</version>
+        </dependency>
+    </dependencies>
+
+</project>

Modified: incubator/servicemix/branches/servicemix-4.0/bundles/pom.xml
URL: http://svn.apache.org/viewvc/incubator/servicemix/branches/servicemix-4.0/bundles/pom.xml?rev=584592&r1=584591&r2=584592&view=diff
==============================================================================
--- incubator/servicemix/branches/servicemix-4.0/bundles/pom.xml (original)
+++ incubator/servicemix/branches/servicemix-4.0/bundles/pom.xml Sun Oct 14 12:35:57 2007
@@ -35,6 +35,7 @@
 
   <modules>
     <module>aopalliance</module>
+	<module>cglib</module>
     <module>jaxb-api</module>
     <module>jaxb-impl</module>
 	<module>httpcore</module>

Modified: incubator/servicemix/branches/servicemix-4.0/gshell/gshell-core/pom.xml
URL: http://svn.apache.org/viewvc/incubator/servicemix/branches/servicemix-4.0/gshell/gshell-core/pom.xml?rev=584592&r1=584591&r2=584592&view=diff
==============================================================================
--- incubator/servicemix/branches/servicemix-4.0/gshell/gshell-core/pom.xml (original)
+++ incubator/servicemix/branches/servicemix-4.0/gshell/gshell-core/pom.xml Sun Oct 14 12:35:57
2007
@@ -31,7 +31,7 @@
     </parent>
     
     <groupId>org.apache.servicemix.gshell</groupId>
-    <artifactId>gshell-core</artifactId>
+    <artifactId>org.apache.servicemix.gshell.core</artifactId>
     <packaging>bundle</packaging>
     <name>GShell Core</name>
     
@@ -55,13 +55,11 @@
             *
         </gshell.osgi.import>
         <gshell.osgi.export>
-            org.apache.geronimo.gshell.command*,
-            org.apache.geronimo.gshell.clp*
+            org.apache.geronimo.gshell*,
         </gshell.osgi.export>
         <gshell.osgi.private>
             jline*,
             org.apache.commons.jexl*,
-            org.apache.geronimo.gshell*,
             org.codehaus.plexus.personality.plexus.lifecycle.phase*,
             org.codehaus.plexus.util*,
             META-INF.spring*

Modified: incubator/servicemix/branches/servicemix-4.0/gshell/gshell-core/src/main/resources/META-INF/spring/gshell-local.xml
URL: http://svn.apache.org/viewvc/incubator/servicemix/branches/servicemix-4.0/gshell/gshell-core/src/main/resources/META-INF/spring/gshell-local.xml?rev=584592&r1=584591&r2=584592&view=diff
==============================================================================
--- incubator/servicemix/branches/servicemix-4.0/gshell/gshell-core/src/main/resources/META-INF/spring/gshell-local.xml
(original)
+++ incubator/servicemix/branches/servicemix-4.0/gshell/gshell-core/src/main/resources/META-INF/spring/gshell-local.xml
Sun Oct 14 12:35:57 2007
@@ -29,7 +29,7 @@
     <bean id="gshell" class="org.apache.geronimo.gshell.spring.GShell"
                       init-method="start" destroy-method="stop">
         <constructor-arg ref="interactiveShell" />
-        <property name="start" value="true" />
+        <property name="start" value="${startLocalConsole}" />
     </bean>
     
 

Modified: incubator/servicemix/branches/servicemix-4.0/gshell/gshell-core/src/main/resources/META-INF/spring/gshell-osgi.xml
URL: http://svn.apache.org/viewvc/incubator/servicemix/branches/servicemix-4.0/gshell/gshell-core/src/main/resources/META-INF/spring/gshell-osgi.xml?rev=584592&r1=584591&r2=584592&view=diff
==============================================================================
--- incubator/servicemix/branches/servicemix-4.0/gshell/gshell-core/src/main/resources/META-INF/spring/gshell-osgi.xml
(original)
+++ incubator/servicemix/branches/servicemix-4.0/gshell/gshell-core/src/main/resources/META-INF/spring/gshell-osgi.xml
Sun Oct 14 12:35:57 2007
@@ -20,6 +20,7 @@
 <beans xmlns="http://www.springframework.org/schema/beans"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xmlns:osgi="http://www.springframework.org/schema/osgi"
+       xmlns:osgix="http://www.springframework.org/schema/osgi-compendium"
        xmlns:util="http://www.springframework.org/schema/util"
        xsi:schemaLocation="
   http://www.springframework.org/schema/beans
@@ -27,9 +28,11 @@
   http://www.springframework.org/schema/util
   http://www.springframework.org/schema/util/spring-util.xsd
   http://www.springframework.org/schema/osgi
-  http://www.springframework.org/schema/osgi/spring-osgi.xsd">
+  http://www.springframework.org/schema/osgi/spring-osgi-1.0-m3.xsd
+  http://www.springframework.org/schema/osgi-compendium
+  http://www.springframework.org/schema/osgi/spring-osgi-compendium.xsd">
 
-    <osgi:list id="commands" interface="org.apache.geronimo.gshell.command.Command" cardinality="0..N">
+    <osgi:list id="commands" interface="org.apache.geronimo.gshell.command.Command">
         <osgi:listener ref="commandRegistry" bind-method="register" unbind-method="unregister"
/>
     </osgi:list>
 
@@ -44,5 +47,11 @@
     <osgi:service ref="source" interface="org.apache.geronimo.gshell.command.Command"
/>
 
     <osgi:service ref="echo" interface="org.apache.geronimo.gshell.command.Command" />
+
+    <osgix:property-placeholder persistent-id="org.apache.servicemix.shell">
+        <osgix:default-properties>
+            <prop key="startLocalConsole">true</prop>
+        </osgix:default-properties>
+    </osgix:property-placeholder>
 
 </beans>

Modified: incubator/servicemix/branches/servicemix-4.0/gshell/gshell-osgi/pom.xml
URL: http://svn.apache.org/viewvc/incubator/servicemix/branches/servicemix-4.0/gshell/gshell-osgi/pom.xml?rev=584592&r1=584591&r2=584592&view=diff
==============================================================================
--- incubator/servicemix/branches/servicemix-4.0/gshell/gshell-osgi/pom.xml (original)
+++ incubator/servicemix/branches/servicemix-4.0/gshell/gshell-osgi/pom.xml Sun Oct 14 12:35:57
2007
@@ -31,7 +31,7 @@
     </parent>
 
     <groupId>org.apache.servicemix.gshell</groupId>
-    <artifactId>gshell-osgi</artifactId>
+    <artifactId>org.apache.servicemix.gshell.osgi</artifactId>
     <packaging>bundle</packaging>
     <name>GShell OSGi Commands</name>
     

Copied: incubator/servicemix/branches/servicemix-4.0/gshell/gshell-osgi/src/main/java/org/apache/geronimo/gshell/osgi/BundleLevel.java
(from r584225, incubator/servicemix/branches/servicemix-4.0/gshell/gshell-osgi/src/main/java/org/apache/geronimo/gshell/osgi/StartLevel.java)
URL: http://svn.apache.org/viewvc/incubator/servicemix/branches/servicemix-4.0/gshell/gshell-osgi/src/main/java/org/apache/geronimo/gshell/osgi/BundleLevel.java?p2=incubator/servicemix/branches/servicemix-4.0/gshell/gshell-osgi/src/main/java/org/apache/geronimo/gshell/osgi/BundleLevel.java&p1=incubator/servicemix/branches/servicemix-4.0/gshell/gshell-osgi/src/main/java/org/apache/geronimo/gshell/osgi/StartLevel.java&r1=584225&r2=584592&rev=584592&view=diff
==============================================================================
--- incubator/servicemix/branches/servicemix-4.0/gshell/gshell-osgi/src/main/java/org/apache/geronimo/gshell/osgi/StartLevel.java
(original)
+++ incubator/servicemix/branches/servicemix-4.0/gshell/gshell-osgi/src/main/java/org/apache/geronimo/gshell/osgi/BundleLevel.java
Sun Oct 14 12:35:57 2007
@@ -29,8 +29,8 @@
  * Time: 12:37:30 PM
  * To change this template use File | Settings | File Templates.
  */
-@CommandComponent(id="startlevel", description="Get or set the start level")
-public class StartLevel extends BundleCommand {
+@CommandComponent(id="bundlelevel", description="Get or set the start level of a given bundle")
+public class BundleLevel extends BundleCommand {
 
     @Argument
     Integer level;
@@ -50,10 +50,10 @@
             }
 
             if (level == null) {
-                io.out.println("Level " + sl.getStartLevel());
+                io.out.println("Level " + sl.getBundleStartLevel(bundle));
             }
             else {
-                sl.setStartLevel(level);
+                sl.setBundleStartLevel(bundle, level);
             }
         }
         finally {

Copied: incubator/servicemix/branches/servicemix-4.0/gshell/gshell-osgi/src/main/java/org/apache/geronimo/gshell/osgi/BundlesCommand.java
(from r584225, incubator/servicemix/branches/servicemix-4.0/gshell/gshell-osgi/src/main/java/org/apache/geronimo/gshell/osgi/BundleCommand.java)
URL: http://svn.apache.org/viewvc/incubator/servicemix/branches/servicemix-4.0/gshell/gshell-osgi/src/main/java/org/apache/geronimo/gshell/osgi/BundlesCommand.java?p2=incubator/servicemix/branches/servicemix-4.0/gshell/gshell-osgi/src/main/java/org/apache/geronimo/gshell/osgi/BundlesCommand.java&p1=incubator/servicemix/branches/servicemix-4.0/gshell/gshell-osgi/src/main/java/org/apache/geronimo/gshell/osgi/BundleCommand.java&r1=584225&r2=584592&rev=584592&view=diff
==============================================================================
--- incubator/servicemix/branches/servicemix-4.0/gshell/gshell-osgi/src/main/java/org/apache/geronimo/gshell/osgi/BundleCommand.java
(original)
+++ incubator/servicemix/branches/servicemix-4.0/gshell/gshell-osgi/src/main/java/org/apache/geronimo/gshell/osgi/BundlesCommand.java
Sun Oct 14 12:35:57 2007
@@ -16,8 +16,10 @@
  */
 package org.apache.geronimo.gshell.osgi;
 
+import java.util.ArrayList;
+import java.util.List;
+
 import org.apache.geronimo.gshell.clp.Argument;
-import org.apache.geronimo.gshell.osgi.OsgiCommandSupport;
 import org.osgi.framework.Bundle;
 
 /**
@@ -27,20 +29,26 @@
  * Time: 12:10:32 PM
  * To change this template use File | Settings | File Templates.
  */
-public abstract class BundleCommand extends OsgiCommandSupport {
+public abstract class BundlesCommand extends OsgiCommandSupport {
 
-    @Argument(required = true)
-    long id;
+    @Argument(required = false, multiValued = true, description = "Bundle IDs")
+    List<Long> ids;
 
     protected Object doExecute() throws Exception {
-        Bundle bundle = getBundleContext().getBundle(id);
-        if (bundle == null) {
-            io.out.println("Bundle " + id + " not found");
-            return FAILURE;
+        List<Bundle> bundles = new ArrayList<Bundle>();
+        if (ids != null && !ids.isEmpty()) {
+            for (long id : ids) {
+                Bundle bundle = getBundleContext().getBundle(id);
+                if (bundle == null) {
+                    io.err.println("Bundle ID" + id + " is invalid");
+                } else {
+                    bundles.add(bundle);
+                }
+            }
         }
-        doExecute(bundle);
+        doExecute(bundles);
         return SUCCESS;
     }
 
-    protected abstract void doExecute(Bundle bundle) throws Exception;
-}
+    protected abstract void doExecute(List<Bundle> bundles) throws Exception;
+}
\ No newline at end of file

Copied: incubator/servicemix/branches/servicemix-4.0/gshell/gshell-osgi/src/main/java/org/apache/geronimo/gshell/osgi/Headers.java
(from r584225, incubator/servicemix/branches/servicemix-4.0/gshell/gshell-osgi/src/main/java/org/apache/geronimo/gshell/osgi/StartBundle.java)
URL: http://svn.apache.org/viewvc/incubator/servicemix/branches/servicemix-4.0/gshell/gshell-osgi/src/main/java/org/apache/geronimo/gshell/osgi/Headers.java?p2=incubator/servicemix/branches/servicemix-4.0/gshell/gshell-osgi/src/main/java/org/apache/geronimo/gshell/osgi/Headers.java&p1=incubator/servicemix/branches/servicemix-4.0/gshell/gshell-osgi/src/main/java/org/apache/geronimo/gshell/osgi/StartBundle.java&r1=584225&r2=584592&rev=584592&view=diff
==============================================================================
--- incubator/servicemix/branches/servicemix-4.0/gshell/gshell-osgi/src/main/java/org/apache/geronimo/gshell/osgi/StartBundle.java
(original)
+++ incubator/servicemix/branches/servicemix-4.0/gshell/gshell-osgi/src/main/java/org/apache/geronimo/gshell/osgi/Headers.java
Sun Oct 14 12:35:57 2007
@@ -16,8 +16,15 @@
  */
 package org.apache.geronimo.gshell.osgi;
 
-import org.osgi.framework.Bundle;
+import java.io.PrintWriter;
+import java.util.Dictionary;
+import java.util.Enumeration;
+import java.util.List;
+
 import org.apache.geronimo.gshell.command.annotation.CommandComponent;
+import org.apache.geronimo.gshell.clp.Argument;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.Constants;
 
 /**
  * Created by IntelliJ IDEA.
@@ -26,11 +33,45 @@
  * Time: 12:10:15 PM
  * To change this template use File | Settings | File Templates.
  */
-@CommandComponent(id="start", description="Start bundle")
-public class StartBundle extends BundleCommand {
+@CommandComponent(id="headers", description="Display headers")
+public class Headers extends OsgiCommandSupport {
+
+    @Argument(required = false, multiValued = true, description = "Bundles ids")
+    List<Long> ids;
+
+    protected Object doExecute() throws Exception {
+        if (ids != null && !ids.isEmpty()) {
+            for (long id : ids) {
+                Bundle bundle = getBundleContext().getBundle(id);
+                if (bundle != null) {
+                    printHeaders(bundle);
+                }
+                else {
+                    io.err.println("Bundle ID " + id + " is invalid.");
+                }
+            }
+        }
+        else {
+            Bundle[] bundles = getBundleContext().getBundles();
+            for (int i = 0; i < bundles.length; i++) {
+                printHeaders(bundles[i]);
+            }
+        }
+        return SUCCESS;
+    }
 
-    protected void doExecute(Bundle bundle) throws Exception {
-        bundle.start();
+    protected void printHeaders(Bundle bundle) throws Exception {
+        String title = Util.getBundleName(bundle);
+        io.out.println("\n" + title);
+        io.out.println(Util.getUnderlineString(title));
+        Dictionary dict = bundle.getHeaders();
+        Enumeration keys = dict.keys();
+        while (keys.hasMoreElements())
+        {
+            Object k = (String) keys.nextElement();
+            Object v = dict.get(k);
+            io.out.println(k + " = " + Util.getValueString(v));
+        }
     }
 
-}
+}
\ No newline at end of file

Copied: incubator/servicemix/branches/servicemix-4.0/gshell/gshell-osgi/src/main/java/org/apache/geronimo/gshell/osgi/ListServices.java
(from r584225, incubator/servicemix/branches/servicemix-4.0/gshell/gshell-osgi/src/main/java/org/apache/geronimo/gshell/osgi/ListBundles.java)
URL: http://svn.apache.org/viewvc/incubator/servicemix/branches/servicemix-4.0/gshell/gshell-osgi/src/main/java/org/apache/geronimo/gshell/osgi/ListServices.java?p2=incubator/servicemix/branches/servicemix-4.0/gshell/gshell-osgi/src/main/java/org/apache/geronimo/gshell/osgi/ListServices.java&p1=incubator/servicemix/branches/servicemix-4.0/gshell/gshell-osgi/src/main/java/org/apache/geronimo/gshell/osgi/ListBundles.java&r1=584225&r2=584592&rev=584592&view=diff
==============================================================================
--- incubator/servicemix/branches/servicemix-4.0/gshell/gshell-osgi/src/main/java/org/apache/geronimo/gshell/osgi/ListBundles.java
(original)
+++ incubator/servicemix/branches/servicemix-4.0/gshell/gshell-osgi/src/main/java/org/apache/geronimo/gshell/osgi/ListServices.java
Sun Oct 14 12:35:57 2007
@@ -16,12 +16,14 @@
  */
 package org.apache.geronimo.gshell.osgi;
 
+import java.util.List;
+
+import org.apache.geronimo.gshell.clp.Argument;
 import org.apache.geronimo.gshell.clp.Option;
+import org.apache.geronimo.gshell.command.Command;
 import org.apache.geronimo.gshell.command.annotation.CommandComponent;
 import org.osgi.framework.Bundle;
-import org.osgi.framework.Constants;
 import org.osgi.framework.ServiceReference;
-import org.osgi.service.startlevel.StartLevel;
 
 /**
  * Created by IntelliJ IDEA.
@@ -30,115 +32,151 @@
  * Time: 9:44:20 AM
  * To change this template use File | Settings | File Templates.
  */
-@CommandComponent(id="lb", description="List bundles")
-public class ListBundles extends OsgiCommandSupport {
+@CommandComponent(id = "ls", description = "List services")
+public class ListServices extends OsgiCommandSupport {
 
-    @Option(name = "-l", description = "Show locations")
-    boolean showLoc;
+    @Option(name = "-a", description = "Show all")
+    boolean showAll;
 
-    @Option(name = "-s", description = "Show symbolic name")
-    boolean showSymbolic;
+    @Option(name = "-u", description = "Show in use")
+    boolean inUse;
 
-    @Option(name = "-u", description = "Show update")
-    boolean showUpdate;
+    @Argument(required = false, multiValued = true, description = "Bundles ids")
+    List<Long> ids;
 
     protected Object doExecute() throws Exception {
-        ServiceReference ref = getBundleContext().getServiceReference(StartLevel.class.getName());
-        StartLevel sl = null;
-        if (ref != null) {
-            sl = (StartLevel) getBundleContext().getService(ref);
-        }
-        if (sl == null) {
-            io.out.println("StartLevel service is unavailable.");
-        }
-        try {
-            Bundle[] bundles = getBundleContext().getBundles();
-            if (bundles != null) {
-                // Display active start level.
-                if (sl != null) {
-                    io.out.println("START LEVEL " + sl.getStartLevel());
-                }
+        if (ids != null && !ids.isEmpty()) {
+            for (long id : ids) {
+                Bundle bundle = getBundleContext().getBundle(id);
+                if (bundle != null) {
+                    boolean headerPrinted = false;
+                    boolean needSeparator = false;
+                    ServiceReference[] refs = null;
+
+                    // Get registered or in-use services.
+                    if (inUse) {
+                        refs = bundle.getServicesInUse();
+                    } else {
+                        refs = bundle.getRegisteredServices();
+                    }
+
+                    // Print properties for each service.
+                    for (int refIdx = 0;
+                         (refs != null) && (refIdx < refs.length);
+                         refIdx++) {
+                        String[] objectClass = (String[])
+                                refs[refIdx].getProperty("objectClass");
+
+                        // Determine if we need to print the service, depending
+                        // on whether it is a command service or not.
+                        boolean print = true;
+                        for (int ocIdx = 0;
+                             !showAll && (ocIdx < objectClass.length);
+                             ocIdx++) {
+                            if (objectClass[ocIdx].equals(Command.class.getName())) {
+                                print = false;
+                            }
+                        }
+
+                        // Print header if we have not already done so.
+                        if (!headerPrinted) {
+                            headerPrinted = true;
+                            String title = Util.getBundleName(bundle);
+                            title = (inUse)
+                                    ? title + " uses:"
+                                    : title + " provides:";
+                            io.out.println("");
+                            io.out.println(title);
+                            io.out.println(Util.getUnderlineString(title));
+                        }
+
+                        if (showAll || print) {
+                            // Print service separator if necessary.
+                            if (needSeparator) {
+                                io.out.println("----");
+                            }
+
+                            // Print service properties.
+                            String[] keys = refs[refIdx].getPropertyKeys();
+                            for (int keyIdx = 0;
+                                 (keys != null) && (keyIdx < keys.length);
+                                 keyIdx++) {
+                                Object v = refs[refIdx].getProperty(keys[keyIdx]);
+                                io.out.println(
+                                        keys[keyIdx] + " = " + Util.getValueString(v));
+                            }
 
-                // Print column headers.
-                String msg = " Name";
-                if (showLoc) {
-                   msg = " Location";
-                }
-                else if (showSymbolic) {
-                   msg = " Symbolic name";
-                }
-                else if (showUpdate) {
-                   msg = " Update location";
-                }
-                String level = (sl == null) ? "" : "  Level ";
-                io.out.println("   ID " + "  State       " + level + msg);
-                for (int i = 0; i < bundles.length; i++) {
-                    // Get the bundle name or location.
-                    String name = (String) bundles[i].getHeaders().get(Constants.BUNDLE_NAME);
-                    // If there is no name, then default to symbolic name.
-                    name = (name == null) ? bundles[i].getSymbolicName() : name;
-                    // If there is no symbolic name, resort to location.
-                    name = (name == null) ? bundles[i].getLocation() : name;
-
-                    // Overwrite the default value is the user specifically
-                    // requested to display one or the other.
-                    if (showLoc) {
-                        name = bundles[i].getLocation();
-                    }
-                    else if (showSymbolic) {
-                        name = bundles[i].getSymbolicName();
-                        name = (name == null) ? "<no symbolic name>" : name;
-                    }
-                    else if (showUpdate) {
-                        name = (String) bundles[i].getHeaders().get(Constants.BUNDLE_UPDATELOCATION);
-                        name = (name == null) ? bundles[i].getLocation() : name;
+                            needSeparator = true;
+                        }
                     }
-                    // Show bundle version if not showing location.
-                    String version = (String) bundles[i].getHeaders().get(Constants.BUNDLE_VERSION);
-                    name = (!showLoc && !showUpdate && (version != null))
? name + " (" + version + ")" : name;
-                    long l = bundles[i].getBundleId();
-                    String id = String.valueOf(l);
-                    if (sl == null) {
-                        level = "1";
-                    }
-                    else {
-                        level = String.valueOf(sl.getBundleStartLevel(bundles[i]));
-                    }
-                    while (level.length() < 5) {
-                        level = " " + level;
-                    }
-                    while (id.length() < 4) {
-                        id = " " + id;
-                    }
-                    io.out.println("[" + id + "] ["
-                        + getStateString(bundles[i].getState())
-                        + "] [" + level + "] " + name);
+                } else {
+                    io.err.println("Bundle ID " + id + " is invalid.");
                 }
             }
-            else {
-                io.out.println("There are no installed bundles.");
-            }
-            return SUCCESS;
         }
-        finally {
-            if (ref != null) {
-                getBundleContext().ungetService(ref);
+        else
+        {
+            Bundle[] bundles = getBundleContext().getBundles();
+            if (bundles != null)
+            {
+                // TODO: Sort list.
+                for (int bundleIdx = 0; bundleIdx < bundles.length; bundleIdx++)
+                {
+                    boolean headerPrinted = false;
+                    ServiceReference[] refs = null;
+
+                    // Get registered or in-use services.
+                    if (inUse)
+                    {
+                        refs = bundles[bundleIdx].getServicesInUse();
+                    }
+                    else
+                    {
+                        refs = bundles[bundleIdx].getRegisteredServices();
+                    }
+
+                    for (int refIdx = 0; (refs != null) && (refIdx < refs.length);
refIdx++)
+                    {
+                        String[] objectClass = (String[])
+                            refs[refIdx].getProperty("objectClass");
+
+                        // Determine if we need to print the service, depending
+                        // on whether it is a command service or not.
+                        boolean print = true;
+                        for (int ocIdx = 0;
+                            !showAll && (ocIdx < objectClass.length);
+                            ocIdx++)
+                        {
+                            if (objectClass[ocIdx].equals(Command.class.getName()))
+                            {
+                                print = false;
+                            }
+                        }
+
+                        // Print the service if necessary.
+                        if (showAll || print)
+                        {
+                            if (!headerPrinted)
+                            {
+                                headerPrinted = true;
+                                String title = Util.getBundleName(bundles[bundleIdx]);
+                                title = (inUse)
+                                    ? title + " uses:"
+                                    : title + " provides:";
+                                io.out.println("\n" + title);
+                                io.out.println(Util.getUnderlineString(title));
+                            }
+                            io.out.println(Util.getValueString(objectClass));
+                        }
+                    }
+                }
+            }
+            else
+            {
+                io.out.println("There are no registered services.");
             }
         }
+        return null;
     }
 
-    public String getStateString(int i)
-    {
-        if (i == Bundle.ACTIVE)
-            return "Active     ";
-        else if (i == Bundle.INSTALLED)
-            return "Installed  ";
-        else if (i == Bundle.RESOLVED)
-            return "Resolved   ";
-        else if (i == Bundle.STARTING)
-            return "Starting   ";
-        else if (i == Bundle.STOPPING)
-            return "Stopping   ";
-        return "Unknown    ";
-    }
-}
+}
\ No newline at end of file

Modified: incubator/servicemix/branches/servicemix-4.0/gshell/gshell-osgi/src/main/java/org/apache/geronimo/gshell/osgi/OsgiCommandSupport.java
URL: http://svn.apache.org/viewvc/incubator/servicemix/branches/servicemix-4.0/gshell/gshell-osgi/src/main/java/org/apache/geronimo/gshell/osgi/OsgiCommandSupport.java?rev=584592&r1=584591&r2=584592&view=diff
==============================================================================
--- incubator/servicemix/branches/servicemix-4.0/gshell/gshell-osgi/src/main/java/org/apache/geronimo/gshell/osgi/OsgiCommandSupport.java
(original)
+++ incubator/servicemix/branches/servicemix-4.0/gshell/gshell-osgi/src/main/java/org/apache/geronimo/gshell/osgi/OsgiCommandSupport.java
Sun Oct 14 12:35:57 2007
@@ -16,8 +16,22 @@
  */
 package org.apache.geronimo.gshell.osgi;
 
-import org.apache.geronimo.gshell.command.CommandSupport;
+import java.util.List;
+import java.util.ArrayList;
+
+import org.apache.geronimo.gshell.clp.CommandLineProcessor;
+import org.apache.geronimo.gshell.clp.Option;
+import org.apache.geronimo.gshell.clp.Printer;
+import org.apache.geronimo.gshell.command.Command;
+import org.apache.geronimo.gshell.command.CommandContext;
+import org.apache.geronimo.gshell.command.IO;
+import org.apache.geronimo.gshell.command.Variables;
+import org.apache.geronimo.gshell.command.annotation.CommandComponent;
+import org.apache.geronimo.gshell.common.Arguments;
+import org.osgi.framework.Bundle;
 import org.osgi.framework.BundleContext;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 import org.springframework.osgi.context.BundleContextAware;
 
 /**
@@ -27,10 +41,37 @@
  * Time: 9:44:39 AM
  * To change this template use File | Settings | File Templates.
  */
-public abstract class OsgiCommandSupport extends CommandSupport implements BundleContextAware
{
+public abstract class OsgiCommandSupport implements Command, BundleContextAware {
 
     private BundleContext bundleContext;
 
+    protected Logger log = LoggerFactory.getLogger(getClass());
+
+    protected CommandContext context;
+
+    protected IO io;
+
+    protected Variables variables;
+
+    @Option(name="-h", aliases={"--help"}, description="Display this help message")
+    private boolean displayHelp;
+
+    public String getId() {
+        CommandComponent cmd = getClass().getAnnotation(CommandComponent.class);
+        if (cmd == null) {
+            throw new IllegalStateException("Command id not found");
+        }
+        return cmd.id();
+    }
+
+    public String getDescription() {
+        CommandComponent cmd = getClass().getAnnotation(CommandComponent.class);
+        if (cmd == null) {
+            throw new IllegalStateException("Command description not found");
+        }
+        return cmd.description();
+    }
+
     public void setBundleContext(BundleContext context) {
         bundleContext = context;
     }
@@ -38,4 +79,67 @@
     public BundleContext getBundleContext() {
         return bundleContext;
     }
+
+    public Object execute(final CommandContext context, final Object... args) throws Exception
{
+        OsgiCommandSupport cmd = getClass().newInstance();
+        cmd.setBundleContext(bundleContext);
+        cmd.init(context);
+        return cmd.doExecute(args);
+    }
+
+    public void init(final CommandContext context) {
+        assert context != null;
+
+        this.context = context;
+        this.io = context.getIO();
+        this.variables = context.getVariables();
+
+        // Re-setup logging using our id
+        String id = getId();
+        log = LoggerFactory.getLogger(getClass().getName() + "." + id);
+    }
+
+    public Object doExecute(final Object... args) throws Exception {
+        assert args != null;
+
+        log.info("Executing w/args: [{}]", Arguments.asString(args));
+
+        CommandLineProcessor clp = new CommandLineProcessor(this);
+        clp.process(Arguments.toStringArray(args));
+
+        // Handle --help/-h automatically for the command
+        if (displayHelp) {
+            //
+            // TODO: Make a special PrinterHandler to abstrat this muck from having to process
it by hand
+            //
+
+            displayHelp(clp);
+
+            return SUCCESS;
+        }
+
+        assert io != null;
+        assert variables != null;
+
+        return doExecute();
+    }
+
+    protected abstract Object doExecute() throws Exception;
+
+    protected void displayHelp(final CommandLineProcessor clp) {
+        assert clp != null;
+
+        //
+        // TODO: Need to ask the LayoutManager what the real name is for our command's ID
+        //
+
+        io.out.println(getId());
+        io.out.println(" -- ");
+        io.out.println();
+
+        Printer printer = new Printer(clp);
+        printer.printUsage(io.out);
+        io.out.println();
+    }
+
 }

Modified: incubator/servicemix/branches/servicemix-4.0/gshell/gshell-osgi/src/main/java/org/apache/geronimo/gshell/osgi/StartLevel.java
URL: http://svn.apache.org/viewvc/incubator/servicemix/branches/servicemix-4.0/gshell/gshell-osgi/src/main/java/org/apache/geronimo/gshell/osgi/StartLevel.java?rev=584592&r1=584591&r2=584592&view=diff
==============================================================================
--- incubator/servicemix/branches/servicemix-4.0/gshell/gshell-osgi/src/main/java/org/apache/geronimo/gshell/osgi/StartLevel.java
(original)
+++ incubator/servicemix/branches/servicemix-4.0/gshell/gshell-osgi/src/main/java/org/apache/geronimo/gshell/osgi/StartLevel.java
Sun Oct 14 12:35:57 2007
@@ -30,23 +30,23 @@
  * To change this template use File | Settings | File Templates.
  */
 @CommandComponent(id="startlevel", description="Get or set the start level")
-public class StartLevel extends BundleCommand {
+public class StartLevel extends OsgiCommandSupport {
 
     @Argument
     Integer level;
 
-    protected void doExecute(Bundle bundle) throws Exception {
+    protected Object doExecute() throws Exception {
         // Get package admin service.
         ServiceReference ref = getBundleContext().getServiceReference(org.osgi.service.startlevel.StartLevel.class.getName());
         if (ref == null) {
             io.out.println("StartLevel service is unavailable.");
-            return;
+            return null;
         }
         try {
             org.osgi.service.startlevel.StartLevel sl = (org.osgi.service.startlevel.StartLevel)
getBundleContext().getService(ref);
             if (sl == null) {
                 io.out.println("StartLevel service is unavailable.");
-                return;
+                return null;
             }
 
             if (level == null) {
@@ -59,6 +59,7 @@
         finally {
             getBundleContext().ungetService(ref);
         }
+        return null;
     }
 
 }

Added: incubator/servicemix/branches/servicemix-4.0/gshell/gshell-osgi/src/main/java/org/apache/geronimo/gshell/osgi/Util.java
URL: http://svn.apache.org/viewvc/incubator/servicemix/branches/servicemix-4.0/gshell/gshell-osgi/src/main/java/org/apache/geronimo/gshell/osgi/Util.java?rev=584592&view=auto
==============================================================================
--- incubator/servicemix/branches/servicemix-4.0/gshell/gshell-osgi/src/main/java/org/apache/geronimo/gshell/osgi/Util.java
(added)
+++ incubator/servicemix/branches/servicemix-4.0/gshell/gshell-osgi/src/main/java/org/apache/geronimo/gshell/osgi/Util.java
Sun Oct 14 12:35:57 2007
@@ -0,0 +1,103 @@
+/*
+ * 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 org.osgi.framework.Bundle;
+import org.osgi.framework.Constants;
+
+public class Util
+{
+    public static String getBundleName(Bundle bundle)
+    {
+        if (bundle != null)
+        {
+            String name = (String) bundle.getHeaders().get(Constants.BUNDLE_NAME);
+            return (name == null)
+                ? "Bundle " + Long.toString(bundle.getBundleId())
+                : name + " (" + Long.toString(bundle.getBundleId()) + ")";
+        }
+        return "[STALE BUNDLE]";
+    }
+
+    private static StringBuffer m_sb = new StringBuffer();
+
+    public static String getUnderlineString(String s)
+    {
+        synchronized (m_sb)
+        {
+            m_sb.delete(0, m_sb.length());
+            for (int i = 0; i < s.length(); i++)
+            {
+                m_sb.append('-');
+            }
+            return m_sb.toString();
+        }
+    }
+
+    public static String getValueString(Object obj)
+    {
+        synchronized (m_sb)
+        {
+            if (obj instanceof String)
+            {
+                return (String) obj;
+            }
+            else if (obj instanceof String[])
+            {
+                String[] array = (String[]) obj;
+                m_sb.delete(0, m_sb.length());
+                for (int i = 0; i < array.length; i++)
+                {
+                    if (i != 0)
+                    {
+                        m_sb.append(", ");
+                    }
+                    m_sb.append(array[i].toString());
+                }
+                return m_sb.toString();
+            }
+            else if (obj instanceof Boolean)
+            {
+                return ((Boolean) obj).toString();
+            }
+            else if (obj instanceof Long)
+            {
+                return ((Long) obj).toString();
+            }
+            else if (obj instanceof Integer)
+            {
+                return ((Integer) obj).toString();
+            }
+            else if (obj instanceof Short)
+            {
+                return ((Short) obj).toString();
+            }
+            else if (obj instanceof Double)
+            {
+                return ((Double) obj).toString();
+            }
+            else if (obj instanceof Float)
+            {
+                return ((Float) obj).toString();
+            }
+
+            return "<unknown value type>";
+        }
+    }
+}
\ No newline at end of file

Modified: incubator/servicemix/branches/servicemix-4.0/gshell/gshell-osgi/src/main/resources/META-INF/spring/gshell-commands.xml
URL: http://svn.apache.org/viewvc/incubator/servicemix/branches/servicemix-4.0/gshell/gshell-osgi/src/main/resources/META-INF/spring/gshell-commands.xml?rev=584592&r1=584591&r2=584592&view=diff
==============================================================================
--- incubator/servicemix/branches/servicemix-4.0/gshell/gshell-osgi/src/main/resources/META-INF/spring/gshell-commands.xml
(original)
+++ incubator/servicemix/branches/servicemix-4.0/gshell/gshell-osgi/src/main/resources/META-INF/spring/gshell-commands.xml
Sun Oct 14 12:35:57 2007
@@ -26,7 +26,11 @@
   http://www.springframework.org/schema/util
   http://www.springframework.org/schema/util/spring-util.xsd">
 
+    <bean id="bundle-level" class="org.apache.geronimo.gshell.osgi.BundleLevel" />
+
     <bean id="list-bundles" class="org.apache.geronimo.gshell.osgi.ListBundles" />
+
+    <bean id="list-services" class="org.apache.geronimo.gshell.osgi.ListServices" />
 
     <bean id="refresh-bundle" class="org.apache.geronimo.gshell.osgi.RefreshBundle" />
 

Modified: incubator/servicemix/branches/servicemix-4.0/gshell/gshell-osgi/src/main/resources/META-INF/spring/gshell-osgi.xml
URL: http://svn.apache.org/viewvc/incubator/servicemix/branches/servicemix-4.0/gshell/gshell-osgi/src/main/resources/META-INF/spring/gshell-osgi.xml?rev=584592&r1=584591&r2=584592&view=diff
==============================================================================
--- incubator/servicemix/branches/servicemix-4.0/gshell/gshell-osgi/src/main/resources/META-INF/spring/gshell-osgi.xml
(original)
+++ incubator/servicemix/branches/servicemix-4.0/gshell/gshell-osgi/src/main/resources/META-INF/spring/gshell-osgi.xml
Sun Oct 14 12:35:57 2007
@@ -31,6 +31,8 @@
 
     <osgi:service ref="list-bundles" interface="org.apache.geronimo.gshell.command.Command"
/>
 
+    <osgi:service ref="list-services" interface="org.apache.geronimo.gshell.command.Command"
/>
+
     <osgi:service ref="refresh-bundle" interface="org.apache.geronimo.gshell.command.Command"
/>
 
     <osgi:service ref="resolve-bundle" interface="org.apache.geronimo.gshell.command.Command"
/>

Modified: incubator/servicemix/branches/servicemix-4.0/gshell/pom.xml
URL: http://svn.apache.org/viewvc/incubator/servicemix/branches/servicemix-4.0/gshell/pom.xml?rev=584592&r1=584591&r2=584592&view=diff
==============================================================================
--- incubator/servicemix/branches/servicemix-4.0/gshell/pom.xml (original)
+++ incubator/servicemix/branches/servicemix-4.0/gshell/pom.xml Sun Oct 14 12:35:57 2007
@@ -52,9 +52,23 @@
                   </executableDependency>
                   <mainClass>org.ops4j.pax.runner.Run</mainClass>
                   <arguments>
-                      <argument>${basedir}/pax-runner.txt</argument>
                       <argument>--vmOptions=-Dbundles.configuration.location=${basedir}/src/test/configs</argument>
                       <argument>--noConsole</argument>
+                      <argument>mvn:org.apache.felix/org.apache.felix.configadmin/0.9.0-SNAPSHOT</argument>
+                      <argument>mvn:org.ops4j.pax.confman/pax-confman-propsloader/0.3.0-SNAPSHOT</argument>
+                      <argument>mvn:org.ops4j.pax.logging/pax-logging-api/0.9.7-SNAPSHOT</argument>
+                      <argument>mvn:org.ops4j.pax.logging/pax-logging-service/0.9.7-SNAPSHOT</argument>
+                      <argument>mvn:org.springframework.osgi/spring-osgi-core/${spring.osgi.version}</argument>
+                      <argument>mvn:org.springframework.osgi/spring-osgi-extender/${spring.osgi.version}</argument>
+                      <argument>mvn:org.springframework.osgi/spring-osgi-io/${spring.osgi.version}</argument>
+                      <argument>mvn:org.springframework/spring-aop/${spring.version}</argument>
+                      <argument>mvn:org.springframework/spring-beans/${spring.version}</argument>
+                      <argument>mvn:org.springframework/spring-context/${spring.version}</argument>
+                      <argument>mvn:org.springframework/spring-core/${spring.version}</argument>
+                      <argument>mvn:org.apache.servicemix.bundles/org.apache.servicemix.bundles.aopalliance/1.0-${project.version}</argument>
+                      <argument>mvn:org.apache.servicemix.bundles/org.apache.servicemix.bundles.cglib/2.1_3-${project.version}</argument>
+                      <argument>mvn:org.apache.servicemix.gshell/org.apache.servicemix.gshell.core/${project.version}</argument>
+                      <argument>mvn:org.apache.servicemix.gshell/org.apache.servicemix.gshell.osgi/${project.version}</argument>
                   </arguments>
                 </configuration>
                 <dependencies>



Mime
View raw message