geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From djen...@apache.org
Subject svn commit: r514826 - /geronimo/server/branches/1.2/modules/geronimo-deploy-tool/src/main/java/org/apache/geronimo/deployment/cli/CommandListModules.java
Date Mon, 05 Mar 2007 19:14:23 GMT
Author: djencks
Date: Mon Mar  5 11:14:22 2007
New Revision: 514826

URL: http://svn.apache.org/viewvc?view=rev&rev=514826
Log:
GERONIMO-2900 make list-modules more readable

Modified:
    geronimo/server/branches/1.2/modules/geronimo-deploy-tool/src/main/java/org/apache/geronimo/deployment/cli/CommandListModules.java

Modified: geronimo/server/branches/1.2/modules/geronimo-deploy-tool/src/main/java/org/apache/geronimo/deployment/cli/CommandListModules.java
URL: http://svn.apache.org/viewvc/geronimo/server/branches/1.2/modules/geronimo-deploy-tool/src/main/java/org/apache/geronimo/deployment/cli/CommandListModules.java?view=diff&rev=514826&r1=514825&r2=514826
==============================================================================
--- geronimo/server/branches/1.2/modules/geronimo-deploy-tool/src/main/java/org/apache/geronimo/deployment/cli/CommandListModules.java
(original)
+++ geronimo/server/branches/1.2/modules/geronimo-deploy-tool/src/main/java/org/apache/geronimo/deployment/cli/CommandListModules.java
Mon Mar  5 11:14:22 2007
@@ -94,25 +94,48 @@
             notrunning = new TargetModuleID[0];
         }
 
+        // print the module count, and if there are more than one
+        // targets print that count, too
         int total = running.length+notrunning.length;
-        out.println("Found "+total+" module"+(total != 1 ? "s" : ""));
-        for (int i = 0; i < running.length; i++) {
-            TargetModuleID result = running[i];
-            out.println("  + "+result.getModuleID()+(tlist.length > 1 ? " on "+result.getTarget().getName():
"")+(result.getWebURL() == null ? "" : " @ "+result.getWebURL()));
-            if(result.getChildTargetModuleID() != null) {
-                for (int j = 0; j < result.getChildTargetModuleID().length; j++) {
-                    TargetModuleID child = result.getChildTargetModuleID()[j];
-                    out.println("      `-> "+child.getModuleID()+(child.getWebURL() ==
null ? "" : " @ "+child.getWebURL()));
-                }
-            }
+        out.print("Found "+total+" module"+(total != 1 ? "s" : ""));
+        if (tlist.length > 1)
+            out.println(" deployed to " + tlist.length + " target" + (tlist.length != 1 ?
"s" : ""));
+        else
+            out.println("");
+
+        // for each target, print the modules that were deployed to it
+        for (int i = 0; i < tlist.length; i++) {
+            Target target = tlist[i];
+            if (tlist.length > 1)
+                out.println("\n Target " + target);
+            printTargetModules(out, target, running, "  + ");
+            printTargetModules(out, target, notrunning, "    ");
         }
-        for (int i = 0; i < notrunning.length; i++) {
-            TargetModuleID result = notrunning[i];
-            out.println("    "+result.getModuleID()+(tlist.length > 1 ? " on "+result.getTarget().getName():
""));
-            if(result.getChildTargetModuleID() != null) {
-                for (int j = 0; j < result.getChildTargetModuleID().length; j++) {
-                    TargetModuleID child = result.getChildTargetModuleID()[j];
-                    out.println("      `-> "+child.getModuleID());
+    }
+
+
+    /**
+     * Prints the names of the modules (that belong to the target) on
+     * the provided PrintWriter.
+     *
+     * @param out a <code>PrintWriter</code> 
+     * @param target a <code>Target</code> value; only the modules
+     * whose target equals this one will be listed.  Must not be null.
+     * @param modules a <code>TargetModuleID[]</code> value, must not
+     * be null.
+     * @param prefix a <code>String</code> value that will be
+     * prepended to each module
+     */
+    void printTargetModules(PrintWriter out, Target target, TargetModuleID[] modules, String
prefix) {
+        for (int i = 0; i < modules.length; i++) {
+            TargetModuleID result = modules[i];
+            if (result.getTarget().equals(target)) {
+                out.println(prefix+result.getModuleID());
+                if(result.getChildTargetModuleID() != null) {
+                    for (int j = 0; j < result.getChildTargetModuleID().length; j++) {
+                        TargetModuleID child = result.getChildTargetModuleID()[j];
+                        out.println("      `-> "+child.getModuleID());
+                    }
                 }
             }
         }



Mime
View raw message