You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@felix.apache.org by ri...@apache.org on 2010/05/12 17:55:30 UTC

svn commit: r943560 - /felix/trunk/gogo/runtime/src/main/java/org/apache/felix/gogo/runtime/osgi/OSGiConverters.java

Author: rickhall
Date: Wed May 12 15:55:29 2010
New Revision: 943560

URL: http://svn.apache.org/viewvc?rev=943560&view=rev
Log:
Align bundle formatter with "lb" command. (FELIX-2042)

Modified:
    felix/trunk/gogo/runtime/src/main/java/org/apache/felix/gogo/runtime/osgi/OSGiConverters.java

Modified: felix/trunk/gogo/runtime/src/main/java/org/apache/felix/gogo/runtime/osgi/OSGiConverters.java
URL: http://svn.apache.org/viewvc/felix/trunk/gogo/runtime/src/main/java/org/apache/felix/gogo/runtime/osgi/OSGiConverters.java?rev=943560&r1=943559&r2=943560&view=diff
==============================================================================
--- felix/trunk/gogo/runtime/src/main/java/org/apache/felix/gogo/runtime/osgi/OSGiConverters.java (original)
+++ felix/trunk/gogo/runtime/src/main/java/org/apache/felix/gogo/runtime/osgi/OSGiConverters.java Wed May 12 15:55:29 2010
@@ -32,6 +32,7 @@ import org.osgi.framework.InvalidSyntaxE
 import org.osgi.framework.ServiceReference;
 import org.osgi.service.command.Converter;
 import org.osgi.service.command.Function;
+import org.osgi.service.startlevel.StartLevel;
 
 public class OSGiConverters implements Converter
 {
@@ -43,13 +44,25 @@ public class OSGiConverters implements C
 
     private CharSequence print(Bundle bundle)
     {
-        String version = (String) bundle.getHeaders().get("Bundle-Version");
-        if (version == null)
+        // [ ID ] [STATE      ] [ SL ] symname
+        StartLevel sl = null;
+        ServiceReference ref = context.getServiceReference(StartLevel.class.getName());
+        if (ref != null)
         {
-            version = "0.0.0";
+            sl = (StartLevel) context.getService(ref);
         }
-        return String.format("%06d %s %s-%s", bundle.getBundleId(), getState(bundle),
-            bundle.getSymbolicName(), version);
+
+        if (sl == null)
+        {
+            return String.format("%5d|%-11s|%s (%s)", bundle.getBundleId(),
+                getState(bundle), bundle.getSymbolicName(), bundle.getVersion());
+        }
+
+        int level = sl.getBundleStartLevel(bundle);
+        context.ungetService(ref);
+
+        return String.format("%5d|%-11s|%5d|%s (%s)", bundle.getBundleId(),
+            getState(bundle), level, bundle.getSymbolicName(), bundle.getVersion());
     }
 
     private CharSequence print(ServiceReference ref)
@@ -101,22 +114,22 @@ public class OSGiConverters implements C
         switch (bundle.getState())
         {
             case Bundle.ACTIVE:
-                return "ACT";
+                return "Active";
 
             case Bundle.INSTALLED:
-                return "INS";
+                return "Installed";
 
             case Bundle.RESOLVED:
-                return "RES";
+                return "Resolved";
 
             case Bundle.STARTING:
-                return "STA";
+                return "Starting";
 
             case Bundle.STOPPING:
-                return "STO";
+                return "Stopping";
 
             case Bundle.UNINSTALLED:
-                return "UNI ";
+                return "Uninstalled ";
         }
         return null;
     }