You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@karaf.apache.org by an...@apache.org on 2012/06/14 01:33:47 UTC

svn commit: r1350055 - in /karaf/trunk/web/command: pom.xml src/main/java/org/apache/karaf/web/commands/List.java

Author: anierbeck
Date: Wed Jun 13 23:33:47 2012
New Revision: 1350055

URL: http://svn.apache.org/viewvc?rev=1350055&view=rev
Log:
[KARAF-1528] - Web:List command not working anymore

Modified:
    karaf/trunk/web/command/pom.xml
    karaf/trunk/web/command/src/main/java/org/apache/karaf/web/commands/List.java

Modified: karaf/trunk/web/command/pom.xml
URL: http://svn.apache.org/viewvc/karaf/trunk/web/command/pom.xml?rev=1350055&r1=1350054&r2=1350055&view=diff
==============================================================================
--- karaf/trunk/web/command/pom.xml (original)
+++ karaf/trunk/web/command/pom.xml Wed Jun 13 23:33:47 2012
@@ -65,6 +65,11 @@
             <artifactId>org.apache.karaf.util</artifactId>
             <scope>provided</scope>
         </dependency>
+        <dependency>
+            <groupId>org.apache.karaf.shell</groupId>
+            <artifactId>org.apache.karaf.shell.table</artifactId>
+            <scope>provided</scope>
+        </dependency>
     </dependencies>
 
     <build>

Modified: karaf/trunk/web/command/src/main/java/org/apache/karaf/web/commands/List.java
URL: http://svn.apache.org/viewvc/karaf/trunk/web/command/src/main/java/org/apache/karaf/web/commands/List.java?rev=1350055&r1=1350054&r2=1350055&view=diff
==============================================================================
--- karaf/trunk/web/command/src/main/java/org/apache/karaf/web/commands/List.java (original)
+++ karaf/trunk/web/command/src/main/java/org/apache/karaf/web/commands/List.java Wed Jun 13 23:33:47 2012
@@ -18,9 +18,12 @@ package org.apache.karaf.web.commands;
 
 import org.apache.karaf.shell.commands.Command;
 import org.apache.karaf.shell.console.OsgiCommandSupport;
+import org.apache.karaf.shell.table.Col;
+import org.apache.karaf.shell.table.ShellTable;
 import org.apache.karaf.web.WebBundle;
 import org.apache.karaf.web.WebContainerService;
 
+
 @Command(scope = "web", name = "list", description = "Lists details for war bundles.")
 public class List extends OsgiCommandSupport {
     
@@ -31,22 +34,28 @@ public class List extends OsgiCommandSup
     }
     
     public Object doExecute() throws Exception {
+    	ShellTable table = new ShellTable();
+        table.column(new Col("ID"));
+        table.column(new Col("State"));
+        table.column(new Col("Web-State"));
+        table.column(new Col("Level"));
+        table.column(new Col("Web-ContextPath"));
+        table.column(new Col("Name"));
+        
         java.util.List<WebBundle> webBundles = webContainerService.list();
         if (webBundles != null && !webBundles.isEmpty()) {
-            String headers = String.format("%d4 %s6 %s6 %s6 %s4 %s30 %s30", "ID", "State", "Web-State", "Level", "Web-ContextPath", "Name");
-            System.out.println(headers);
             for (WebBundle webBundle : webBundles) {
-                String display = String.format("%d4 %s6 %s6 %s6 %d4 %s30 %s30",
+            	table.addRow().addContent(
                         webBundle.getBundleId(),
                         webBundle.getState(),
                         webBundle.getWebState(),
                         webBundle.getLevel(),
                         webBundle.getContextPath(),
                         webBundle.getName());
-                System.out.println(display);
             }
             
-        }        
+        }
+        table.print(System.out);
         return null;
     }