servicemix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ff...@apache.org
Subject svn commit: r751999 - /servicemix/smx4/nmr/trunk/jbi/commands/src/main/java/org/apache/servicemix/jbi/commands/ListCommand.java
Date Tue, 10 Mar 2009 06:39:30 GMT
Author: ffang
Date: Tue Mar 10 06:39:30 2009
New Revision: 751999

URL: http://svn.apache.org/viewvc?rev=751999&view=rev
Log:
[SMX4NMR-112]Refactor the output of jbi/list command to be more in line with the osgi/list
commands

Modified:
    servicemix/smx4/nmr/trunk/jbi/commands/src/main/java/org/apache/servicemix/jbi/commands/ListCommand.java

Modified: servicemix/smx4/nmr/trunk/jbi/commands/src/main/java/org/apache/servicemix/jbi/commands/ListCommand.java
URL: http://svn.apache.org/viewvc/servicemix/smx4/nmr/trunk/jbi/commands/src/main/java/org/apache/servicemix/jbi/commands/ListCommand.java?rev=751999&r1=751998&r2=751999&view=diff
==============================================================================
--- servicemix/smx4/nmr/trunk/jbi/commands/src/main/java/org/apache/servicemix/jbi/commands/ListCommand.java
(original)
+++ servicemix/smx4/nmr/trunk/jbi/commands/src/main/java/org/apache/servicemix/jbi/commands/ListCommand.java
Tue Mar 10 06:39:30 2009
@@ -18,6 +18,8 @@
 
 import java.util.List;
 
+import javax.jbi.management.LifeCycleMBean;
+
 import org.apache.servicemix.jbi.deployer.Component;
 import org.apache.servicemix.jbi.deployer.ServiceAssembly;
 import org.apache.servicemix.jbi.deployer.SharedLibrary;
@@ -26,6 +28,8 @@
  * List JBI artifacts
  */
 public class ListCommand extends JbiCommandSupport {
+    
+    private static final int NAME_COL_LENGTH = 30; 
 
     protected Object doExecute() throws Exception {
         List<SharedLibrary> libraries = getSharedLibraries();
@@ -42,8 +46,11 @@
         if (components != null && !components.isEmpty()) {
             io.out.println("Components");
             io.out.println("----------");
+            io.out.println("   State                  Name                  Description");
             for (Component component : components) {
-                io.out.println(component.getName() + " - " + component.getCurrentState()
+ " - " + component.getDescription());
+                io.out.println("[" + getStateString(component.getCurrentState())+ "] ["
+                        + getNameString(component.getName(), NAME_COL_LENGTH) + "]     "
+                        + component.getDescription());
             }
             io.out.println();
         }
@@ -52,11 +59,38 @@
         if (assemblies != null && !assemblies.isEmpty()) {
             io.out.println("Service Assemblies");
             io.out.println("------------------");
+            io.out.println("   State                  Name                  Description");
             for (ServiceAssembly assembly : assemblies) {
-                io.out.println(assembly.getName() + " - " + assembly.getCurrentState() +
" - " + assembly.getDescription());
+                io.out.println("[" + getStateString(assembly.getCurrentState())+ "] ["
+                        + getNameString(assembly.getName(), NAME_COL_LENGTH) + "]     "
+                        + assembly.getDescription());
             }
             io.out.println();
         }
         return null;  //To change body of implemented methods use File | Settings | File
Templates.
     }
+    
+    
+    
+
+    private String getNameString(String name, int colLength) {
+        String ret = name;
+        for (int i = 0; i < colLength - name.length(); i++) {
+            ret = ret + " ";
+        }
+        return ret;
+    }
+
+
+    private String getStateString(String state) {
+        if (state.equals(LifeCycleMBean.SHUTDOWN)) {
+            return "Shutdown";
+        } else if (state.equals(LifeCycleMBean.STARTED)) {
+            return "Started ";
+        } else if (state.equals(LifeCycleMBean.STOPPED)) {
+            return "Stopped ";
+        } else {
+            return "Unknown ";
+        }
+    }
 }



Mime
View raw message