geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From djen...@apache.org
Subject svn commit: r595732 [2/2] - in /geronimo/server/trunk: assemblies/geronimo-boilerplate-minimal/src/main/underlay/etc/ framework/modules/geronimo-cli/src/main/java/org/apache/geronimo/cli/deployer/ framework/modules/geronimo-commands/ framework/modules/...
Date Fri, 16 Nov 2007 16:46:17 GMT
Modified: geronimo/server/trunk/framework/modules/geronimo-deploy-tool/src/main/java/org/apache/geronimo/deployment/cli/CommandStart.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/framework/modules/geronimo-deploy-tool/src/main/java/org/apache/geronimo/deployment/cli/CommandStart.java?rev=595732&r1=595731&r2=595732&view=diff
==============================================================================
--- geronimo/server/trunk/framework/modules/geronimo-deploy-tool/src/main/java/org/apache/geronimo/deployment/cli/CommandStart.java
(original)
+++ geronimo/server/trunk/framework/modules/geronimo-deploy-tool/src/main/java/org/apache/geronimo/deployment/cli/CommandStart.java
Fri Nov 16 08:46:15 2007
@@ -18,6 +18,7 @@
 package org.apache.geronimo.deployment.cli;
 
 import java.io.PrintWriter;
+import java.io.IOException;
 import java.util.ArrayList;
 import java.util.List;
 
@@ -29,6 +30,7 @@
 
 import org.apache.geronimo.cli.deployer.CommandArgs;
 import org.apache.geronimo.common.DeploymentException;
+import jline.ConsoleReader;
 
 /**
  * The CLI deployer logic to start.
@@ -37,55 +39,60 @@
  */
 public class CommandStart extends AbstractCommand {
 
-    public void execute(PrintWriter out, ServerConnection connection, CommandArgs commandArgs)
throws DeploymentException {
-        String[] args = commandArgs.getArgs();
-        
-        DeploymentManager mgr = connection.getDeploymentManager();
-        Target[] allTargets = mgr.getTargets();
-        TargetModuleID[] allModules;
+    public void execute(ConsoleReader consoleReader, ServerConnection connection, CommandArgs
commandArgs) throws DeploymentException {
+        ProgressObject po = null;
         try {
-            allModules = mgr.getAvailableModules(null, allTargets);
-        } catch(TargetException e) {
-            throw new DeploymentException("Unable to load module list from server", e);
-        }
-        List modules = new ArrayList();
-        for(int i=0; i<args.length; i++) {
-            modules.addAll(DeployUtils.identifyTargetModuleIDs(allModules, args[i], false));
-        }
-        TargetModuleID[] ids = (TargetModuleID[]) modules.toArray(new TargetModuleID[modules.size()]);
-        boolean multiple = isMultipleTargets(ids);
-        ProgressObject po = runCommand(out, mgr, ids);
-        TargetModuleID[] done = po.getResultTargetModuleIDs();
-        out.println();
-        for(int i = 0; i < done.length; i++) {
-            TargetModuleID id = done[i];
-            out.print(DeployUtils.reformat(getAction()+" "+id.getModuleID()+((multiple &&
id.getTarget() != null) ? " on "+ id.getTarget().getName() : "")+(id.getWebURL() == null ||
!getAction().equals("Started") ? "" : " @ "+id.getWebURL()),4, 72));
-            if(id.getChildTargetModuleID() != null) {
-                for (int j = 0; j < id.getChildTargetModuleID().length; j++) {
-                    TargetModuleID child = id.getChildTargetModuleID()[j];
-                    out.print(DeployUtils.reformat("  `-> "+child.getModuleID()+(child.getWebURL()
== null || getAction().toLowerCase().indexOf("started") == -1 ? "" : " @ "+child.getWebURL()),4,
72));
-                }
-            } // Also print childs if existing in earlier configuration
-            else{
-                java.util.Iterator iterator = DeployUtils.identifyTargetModuleIDs(allModules,
id.getModuleID(), false).iterator();
-                if(iterator.hasNext()){
-                    TargetModuleID childs = (TargetModuleID)iterator.next();
-                    if(childs.getChildTargetModuleID() != null) {
-                        for (int j = 0; j < childs.getChildTargetModuleID().length; j++)
{
-                            TargetModuleID child = childs.getChildTargetModuleID()[j];
-                            out.print(DeployUtils.reformat("  `-> "+child.getModuleID()+(child.getWebURL()
== null || getAction().toLowerCase().indexOf("started") == -1 ? "" : " @ "+child.getWebURL()),4,
72));
+            String[] args = commandArgs.getArgs();
+
+            DeploymentManager mgr = connection.getDeploymentManager();
+            Target[] allTargets = mgr.getTargets();
+            TargetModuleID[] allModules;
+            try {
+                allModules = mgr.getAvailableModules(null, allTargets);
+            } catch(TargetException e) {
+                throw new DeploymentException("Unable to load module list from server", e);
+            }
+            List modules = new ArrayList();
+            for(int i=0; i<args.length; i++) {
+                modules.addAll(DeployUtils.identifyTargetModuleIDs(allModules, args[i], false));
+            }
+            TargetModuleID[] ids = (TargetModuleID[]) modules.toArray(new TargetModuleID[modules.size()]);
+            boolean multiple = isMultipleTargets(ids);
+            po = runCommand(consoleReader, mgr, ids);
+            TargetModuleID[] done = po.getResultTargetModuleIDs();
+            consoleReader.printNewline();
+            for(int i = 0; i < done.length; i++) {
+                TargetModuleID id = done[i];
+                consoleReader.printString(DeployUtils.reformat(getAction()+" "+id.getModuleID()+((multiple
&& id.getTarget() != null) ? " on "+ id.getTarget().getName() : "")+(id.getWebURL()
== null || !getAction().equals("Started") ? "" : " @ "+id.getWebURL()),4, 72));
+                if(id.getChildTargetModuleID() != null) {
+                    for (int j = 0; j < id.getChildTargetModuleID().length; j++) {
+                        TargetModuleID child = id.getChildTargetModuleID()[j];
+                        consoleReader.printString(DeployUtils.reformat("  `-> "+child.getModuleID()+(child.getWebURL()
== null || getAction().toLowerCase().indexOf("started") == -1 ? "" : " @ "+child.getWebURL()),4,
72));
+                    }
+                } // Also print childs if existing in earlier configuration
+                else{
+                    java.util.Iterator iterator = DeployUtils.identifyTargetModuleIDs(allModules,
id.getModuleID(), false).iterator();
+                    if(iterator.hasNext()){
+                        TargetModuleID childs = (TargetModuleID)iterator.next();
+                        if(childs.getChildTargetModuleID() != null) {
+                            for (int j = 0; j < childs.getChildTargetModuleID().length;
j++) {
+                                TargetModuleID child = childs.getChildTargetModuleID()[j];
+                                consoleReader.printString(DeployUtils.reformat("  `->
"+child.getModuleID()+(child.getWebURL() == null || getAction().toLowerCase().indexOf("started")
== -1 ? "" : " @ "+child.getWebURL()),4, 72));
+                            }
                         }
                     }
                 }
+                consoleReader.printNewline();
             }
-            out.println();
+        } catch (IOException e) {
+            throw new DeploymentException("could not write to console", e);
         }
         if(po.getDeploymentStatus().isFailed()) {
             throw new DeploymentException("Operation failed: "+po.getDeploymentStatus().getMessage());
         }
     }
 
-    protected ProgressObject runCommand(PrintWriter out, DeploymentManager mgr, TargetModuleID[]
ids) {
+    protected ProgressObject runCommand(ConsoleReader out, DeploymentManager mgr, TargetModuleID[]
ids) {
         ProgressObject po = mgr.start(ids);
         waitForProgress(out, po);
         return po;

Modified: geronimo/server/trunk/framework/modules/geronimo-deploy-tool/src/main/java/org/apache/geronimo/deployment/cli/CommandStop.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/framework/modules/geronimo-deploy-tool/src/main/java/org/apache/geronimo/deployment/cli/CommandStop.java?rev=595732&r1=595731&r2=595732&view=diff
==============================================================================
--- geronimo/server/trunk/framework/modules/geronimo-deploy-tool/src/main/java/org/apache/geronimo/deployment/cli/CommandStop.java
(original)
+++ geronimo/server/trunk/framework/modules/geronimo-deploy-tool/src/main/java/org/apache/geronimo/deployment/cli/CommandStop.java
Fri Nov 16 08:46:15 2007
@@ -23,6 +23,8 @@
 import javax.enterprise.deploy.spi.TargetModuleID;
 import javax.enterprise.deploy.spi.status.ProgressObject;
 
+import jline.ConsoleReader;
+
 /**
  * The CLI deployer logic to stop.
  *
@@ -30,7 +32,7 @@
  */
 public class CommandStop extends CommandStart {
 
-    protected ProgressObject runCommand(PrintWriter out, DeploymentManager mgr, TargetModuleID[]
ids) {
+    protected ProgressObject runCommand(ConsoleReader out, DeploymentManager mgr, TargetModuleID[]
ids) {
         ProgressObject po = mgr.stop(ids);
         waitForProgress(out, po);
         return po;

Modified: geronimo/server/trunk/framework/modules/geronimo-deploy-tool/src/main/java/org/apache/geronimo/deployment/cli/CommandUndeploy.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/framework/modules/geronimo-deploy-tool/src/main/java/org/apache/geronimo/deployment/cli/CommandUndeploy.java?rev=595732&r1=595731&r2=595732&view=diff
==============================================================================
--- geronimo/server/trunk/framework/modules/geronimo-deploy-tool/src/main/java/org/apache/geronimo/deployment/cli/CommandUndeploy.java
(original)
+++ geronimo/server/trunk/framework/modules/geronimo-deploy-tool/src/main/java/org/apache/geronimo/deployment/cli/CommandUndeploy.java
Fri Nov 16 08:46:15 2007
@@ -23,6 +23,8 @@
 import javax.enterprise.deploy.spi.TargetModuleID;
 import javax.enterprise.deploy.spi.status.ProgressObject;
 
+import jline.ConsoleReader;
+
 /**
  * the CLI deployer logic to undeploy.
  *
@@ -30,7 +32,7 @@
  */
 public class CommandUndeploy extends CommandStart {
 
-    protected ProgressObject runCommand(PrintWriter out, DeploymentManager mgr, TargetModuleID[]
ids) {
+    protected ProgressObject runCommand(ConsoleReader out, DeploymentManager mgr, TargetModuleID[]
ids) {
         ProgressObject po = mgr.undeploy(ids);
         waitForProgress(out, po);
         return po;

Modified: geronimo/server/trunk/framework/modules/geronimo-deploy-tool/src/main/java/org/apache/geronimo/deployment/cli/DeployCommand.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/framework/modules/geronimo-deploy-tool/src/main/java/org/apache/geronimo/deployment/cli/DeployCommand.java?rev=595732&r1=595731&r2=595732&view=diff
==============================================================================
--- geronimo/server/trunk/framework/modules/geronimo-deploy-tool/src/main/java/org/apache/geronimo/deployment/cli/DeployCommand.java
(original)
+++ geronimo/server/trunk/framework/modules/geronimo-deploy-tool/src/main/java/org/apache/geronimo/deployment/cli/DeployCommand.java
Fri Nov 16 08:46:15 2007
@@ -21,6 +21,10 @@
 import org.apache.geronimo.common.DeploymentException;
 
 import java.io.PrintWriter;
+import java.io.Reader;
+import java.io.BufferedReader;
+
+import jline.ConsoleReader;
 
 /**
  * An abstraction of various CLI deployer commands.
@@ -30,5 +34,5 @@
 public interface DeployCommand {
     boolean isLocalOnly();
 
-    void execute(PrintWriter out, ServerConnection connection, CommandArgs commandArgs) throws
DeploymentException;
+    void execute(ConsoleReader consoleReader, ServerConnection connection, CommandArgs commandArgs)
throws DeploymentException;
 }

Modified: geronimo/server/trunk/framework/modules/geronimo-deploy-tool/src/main/java/org/apache/geronimo/deployment/cli/DeployTool.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/framework/modules/geronimo-deploy-tool/src/main/java/org/apache/geronimo/deployment/cli/DeployTool.java?rev=595732&r1=595731&r2=595732&view=diff
==============================================================================
--- geronimo/server/trunk/framework/modules/geronimo-deploy-tool/src/main/java/org/apache/geronimo/deployment/cli/DeployTool.java
(original)
+++ geronimo/server/trunk/framework/modules/geronimo-deploy-tool/src/main/java/org/apache/geronimo/deployment/cli/DeployTool.java
Fri Nov 16 08:46:15 2007
@@ -53,6 +53,7 @@
 import org.apache.geronimo.gbean.GBeanInfoBuilder;
 import org.apache.geronimo.kernel.Kernel;
 import org.apache.geronimo.kernel.util.Main;
+import jline.ConsoleReader;
 
 
 /**
@@ -158,10 +159,12 @@
                         con = new ServerConnection(parser, out, in, kernel, deploymentFactory);
                     }
                     try {
-                        dc.execute(out, con, commandArgs);
+                        dc.execute(new ConsoleReader(in, out), con, commandArgs);
                     } catch (DeploymentSyntaxException e) {
                         processException(out, e);
                     } catch (DeploymentException e) {
+                        processException(out, e);
+                    } catch (IOException e) {
                         processException(out, e);
                     } finally {
                         if(!multipleCommands) {

Modified: geronimo/server/trunk/framework/modules/geronimo-deploy-tool/src/main/java/org/apache/geronimo/deployment/cli/ServerConnection.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/framework/modules/geronimo-deploy-tool/src/main/java/org/apache/geronimo/deployment/cli/ServerConnection.java?rev=595732&r1=595731&r2=595732&view=diff
==============================================================================
--- geronimo/server/trunk/framework/modules/geronimo-deploy-tool/src/main/java/org/apache/geronimo/deployment/cli/ServerConnection.java
(original)
+++ geronimo/server/trunk/framework/modules/geronimo-deploy-tool/src/main/java/org/apache/geronimo/deployment/cli/ServerConnection.java
Fri Nov 16 08:46:15 2007
@@ -25,6 +25,7 @@
 import java.io.InputStream;
 import java.io.PrintWriter;
 import java.io.Serializable;
+import java.io.Writer;
 import java.util.Properties;
 import java.util.jar.JarFile;
 
@@ -33,7 +34,7 @@
 import javax.enterprise.deploy.spi.exceptions.DeploymentManagerCreationException;
 import javax.enterprise.deploy.spi.factories.DeploymentFactory;
 
-import org.apache.geronimo.cli.deployer.DeployerCLParser;
+import org.apache.geronimo.cli.deployer.ConnectionParams;
 import org.apache.geronimo.common.DeploymentException;
 import org.apache.geronimo.deployment.plugin.factories.AuthenticationFailedException;
 import org.apache.geronimo.deployment.plugin.jmx.JMXDeploymentManager;
@@ -54,13 +55,13 @@
     private final DeploymentFactory geronimoDeploymentFactory;
 
     private DeploymentManager manager;
-    private PrintWriter out;
+    private Writer out;
     private InputStream in;
     private SavedAuthentication auth;
     private boolean logToSysErr;
     private boolean verboseMessages;
 
-    public ServerConnection(DeployerCLParser parser, PrintWriter out, InputStream in, Kernel
kernel, DeploymentFactory geronimoDeploymentFactory) throws DeploymentException {
+    public ServerConnection(ConnectionParams params, PrintWriter out, InputStream in, Kernel
kernel, DeploymentFactory geronimoDeploymentFactory) throws DeploymentException {
         if (null == kernel) {
             throw new IllegalArgumentException("kernel is required");
         }
@@ -70,15 +71,15 @@
         this.in = in;
         boolean offline = false;
 
-        String uri = parser.getURI();
-        String driver = parser.getDriver();
-        String user = parser.getUser();
-        String password = parser.getPassword();
-        String host = parser.getHost();
-        Integer port = parser.getPort();
-        verboseMessages = parser.isVerbose();
-        logToSysErr = parser.isSyserr();
-        offline = parser.isOffline();
+        String uri = params.getURI();
+        String driver = params.getDriver();
+        String user = params.getUser();
+        String password = params.getPassword();
+        String host = params.getHost();
+        Integer port = params.getPort();
+        verboseMessages = params.isVerbose();
+        logToSysErr = params.isSyserr();
+        offline = params.isOffline();
 
         if ((driver != null) && uri == null) {
             throw new DeploymentSyntaxException("A custom driver requires a custom URI");



Mime
View raw message