FELIX-5001 clean up scr:info command output

git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@1702491 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/scr/src/main/java/org/apache/felix/scr/impl/ScrCommand.java b/scr/src/main/java/org/apache/felix/scr/impl/ScrCommand.java
index ac5deb3..a1ebf22 100644
--- a/scr/src/main/java/org/apache/felix/scr/impl/ScrCommand.java
+++ b/scr/src/main/java/org/apache/felix/scr/impl/ScrCommand.java
@@ -120,27 +120,17 @@
     {
         /*
          * Register the Gogo Command as a service of its own class.
-         * Due to a race condition during project building (this class is
-         * compiled for Java 1.3 compatibility before the required
-         * ScrGogoCommand class compiled for Java 5 compatibility) this uses
-         * reflection to load and instantiate the class. Any failure during this
-         * process is just ignored.
          */
         try
         {
-            final String scrGogoCommandClassName = "org.apache.felix.scr.impl.ScrGogoCommand";
-            final Class<?> scrGogoCommandClass = scrService.getClass().getClassLoader().loadClass(scrGogoCommandClassName);
-            final Constructor c = scrGogoCommandClass.getConstructor(new Class[]
-                { ScrCommand.class });
-            final Object gogoCmd = c.newInstance(new Object[]
-                { this });
+            final ScrGogoCommand gogoCmd = new ScrGogoCommand(this);
             final Hashtable<String, Object> props = new Hashtable<String, Object>();
             props.put("osgi.command.scope", "scr");
             props.put("osgi.command.function", new String[]
                 { "config", "disable", "enable", "info", "list" });
             props.put(Constants.SERVICE_DESCRIPTION, "SCR Gogo Shell Support");
             props.put(Constants.SERVICE_VENDOR, "The Apache Software Foundation");
-            gogoReg = bundleContext.registerService(scrGogoCommandClassName, gogoCmd, props);
+            gogoReg = bundleContext.registerService(ScrGogoCommand.class, gogoCmd, props);
         }
         catch (Throwable t)
         {
@@ -305,7 +295,7 @@
             return;
         }
 
-        Collections.sort( new ArrayList<ComponentDescriptionDTO>(result.components), DESCRIPTION_COMP);
+        Collections.sort( result.components, DESCRIPTION_COMP );
 
         long bundleId = -1;
 
@@ -316,7 +306,6 @@
                 if ( bundleId != -1 )
                 {
                     out.println();
-                    out.println();
                 }
                 bundleId = component.bundle.id;
                 out.println(String.format("*** Bundle: %1$s (%2$d)", component.bundle.symbolicName, bundleId));
@@ -362,7 +351,7 @@
             String[] services = component.serviceInterfaces;
             if ( services != null )
             {
-                out.print( "  Services: " );
+                out.println( "  Services: " );
                 for ( String service: services )
                 {
                     out.print( "          " );
@@ -411,6 +400,7 @@
                     info(cc, out);
                 }
             }
+            out.println();
         }
 
         out.flush();
@@ -467,7 +457,7 @@
             out.print( "      Target: " );
             out.println( ref.target );
             ServiceReferenceDTO[] serviceRefs = ref.boundServices;
-            if ( serviceRefs != null )
+            if ( serviceRefs.length > 0 )
             {
                 out.print( "      Bound to:" );
                 for ( ServiceReferenceDTO sr: serviceRefs )
@@ -490,7 +480,7 @@
             out.print( "      Target: " );
             out.println( ref.target );
             ServiceReferenceDTO[] serviceRefs = ref.targetServices;
-            if ( serviceRefs != null )
+            if ( serviceRefs.length > 0 )
             {
                 out.print( "      Target services:" );
                 for ( ServiceReferenceDTO sr: serviceRefs )
@@ -501,7 +491,7 @@
             }
             else
             {
-                out.println( "      (unbound)" );
+                out.println( "      (no target services)" );
             }
 
         }
@@ -583,7 +573,7 @@
     }
 
     private static final class Result {
-        public Collection<ComponentDescriptionDTO> components = new ArrayList<ComponentDescriptionDTO>();
+        public List<ComponentDescriptionDTO> components = new ArrayList<ComponentDescriptionDTO>();
         public ComponentConfigurationDTO configuration;
     }