geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gdam...@apache.org
Subject svn commit: r159100 - in geronimo/trunk/modules/deploy-tool/src/java/org/apache/geronimo/deployment: cli/ plugin/factories/ plugin/jmx/ plugin/local/
Date Sat, 26 Mar 2005 10:17:55 GMT
Author: gdamour
Date: Sat Mar 26 02:17:51 2005
New Revision: 159100

URL: http://svn.apache.org/viewcvs?view=rev&rev=159100
Log:
add two new general option switches:

o syserr: dump the errors to syserr if set to true; and
o verbose: dump the stack-trace of the returned exceptions if set to true.

The default value of these two switches is false. This avoids long pages
of messages upon deployment failures.

Modified:
    geronimo/trunk/modules/deploy-tool/src/java/org/apache/geronimo/deployment/cli/ServerConnection.java
    geronimo/trunk/modules/deploy-tool/src/java/org/apache/geronimo/deployment/plugin/factories/DeploymentFactoryImpl.java
    geronimo/trunk/modules/deploy-tool/src/java/org/apache/geronimo/deployment/plugin/jmx/JMXDeploymentManager.java
    geronimo/trunk/modules/deploy-tool/src/java/org/apache/geronimo/deployment/plugin/local/CommandSupport.java
    geronimo/trunk/modules/deploy-tool/src/java/org/apache/geronimo/deployment/plugin/local/DistributeCommand.java
    geronimo/trunk/modules/deploy-tool/src/java/org/apache/geronimo/deployment/plugin/local/RedeployCommand.java
    geronimo/trunk/modules/deploy-tool/src/java/org/apache/geronimo/deployment/plugin/local/StartCommand.java
    geronimo/trunk/modules/deploy-tool/src/java/org/apache/geronimo/deployment/plugin/local/StopCommand.java
    geronimo/trunk/modules/deploy-tool/src/java/org/apache/geronimo/deployment/plugin/local/UndeployCommand.java

Modified: geronimo/trunk/modules/deploy-tool/src/java/org/apache/geronimo/deployment/cli/ServerConnection.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/deploy-tool/src/java/org/apache/geronimo/deployment/cli/ServerConnection.java?view=diff&r1=159099&r2=159100
==============================================================================
--- geronimo/trunk/modules/deploy-tool/src/java/org/apache/geronimo/deployment/cli/ServerConnection.java
(original)
+++ geronimo/trunk/modules/deploy-tool/src/java/org/apache/geronimo/deployment/cli/ServerConnection.java
Sat Mar 26 02:17:51 2005
@@ -34,6 +34,7 @@
 import org.apache.geronimo.common.DeploymentException;
 import org.apache.geronimo.deployment.plugin.factories.AuthenticationFailedException;
 import org.apache.geronimo.deployment.plugin.factories.DeploymentFactoryImpl;
+import org.apache.geronimo.deployment.plugin.jmx.JMXDeploymentManager;
 import org.apache.geronimo.system.main.CommandLine;
 import org.apache.geronimo.system.main.CommandLineManifest;
 
@@ -63,13 +64,17 @@
                 "deployer will attempt to connect to the server with no password, and if
" +
                 "that fails, will prompt you for a password.");
         OPTION_HELP.put("--password", "Specifies a password to use to authenticate to the
server.");
+        OPTION_HELP.put("--syserr", "Log errors to syserr. Can be either true or false."
+
+                " The default value is false.");
+        OPTION_HELP.put("--verbose", "Verbose execution mode. Can be either true or false."
+
+                " The default value is false.");
     }
     public static Map getOptionHelp() {
         return OPTION_HELP;
     }
 
     private final static String DEFAULT_URI = "deployer:geronimo:jmx:rmi://localhost/jndi/rmi:/JMXConnector";
-
+    
     private DeploymentManager manager;
     private KernelWrapper kernel;
     private PrintWriter out;
@@ -77,6 +82,7 @@
 
     public ServerConnection(String[] args, boolean forceLocal, PrintWriter out, BufferedReader
in) throws DeploymentException {
         String uri = null, driver = null, user = null, password = null;
+        JMXDeploymentManager.CommandContext commandContext = new JMXDeploymentManager.CommandContext();
         this.out = out;
         this.in = in;
         for(int i = 0; i < args.length; i++) {
@@ -109,6 +115,24 @@
                     throw new DeploymentSyntaxException("Must specify a password (--password
password)");
                 }
                 password = args[++i];
+            } else if (arg.equals("--verbose")) {
+                String value = args[++i];
+                if (value.equals("true")) {
+                    commandContext.setVerbose(true);
+                } else if (value.equals("false")) {
+                    commandContext.setVerbose(false);
+                } else {
+                    throw new DeploymentSyntaxException("--quiet must be either true or false.");
+                }
+            } else if (arg.equals("--syserr")) {
+                String value = args[++i];
+                if (value.equals("true")) {
+                    commandContext.setLogErrors(true);
+                } else if (value.equals("false")) {
+                    commandContext.setLogErrors(false);
+                } else {
+                    throw new DeploymentSyntaxException("--syserr must be either true or
false.");
+                }
             } else {
                 throw new DeploymentException("Invalid option "+arg);
             }
@@ -120,7 +144,7 @@
             throw new DeploymentSyntaxException("This command does not use normal server
connectivity.  No standard options are allowed.");
         }
         if(!forceLocal) {
-            tryToConnect(uri, driver, user, password, true);
+            tryToConnect(uri, commandContext, driver, user, password, true);
             if(manager == null) { // uri must be null too or we'd have thrown an exception
                 initializeKernel();
             }
@@ -146,18 +170,19 @@
         }
     }
 
-    private void tryToConnect(String uri, String driver, String user, String password, boolean
authPrompt) throws DeploymentException {
+    private void tryToConnect(String uri, JMXDeploymentManager.CommandContext commandContext,
String driver, String user, String password, boolean authPrompt) throws DeploymentException
{
         DeploymentFactoryManager mgr = DeploymentFactoryManager.getInstance();
         if(driver != null) {
             loadDriver(driver, mgr);
         } else {
             mgr.registerDeploymentFactory(new DeploymentFactoryImpl());
         }
+        
         try {
             manager = mgr.getDeploymentManager(uri == null ? DEFAULT_URI : uri, user, password);
         } catch(AuthenticationFailedException e) { // server's there, you just can't talk
to it
             if(authPrompt && (user == null || password == null)) {
-                doAuthPromptAndRetry(uri, user, password);
+                doAuthPromptAndRetry(uri, commandContext, user, password);
             } else {
                 throw new DeploymentException("Unable to connect to server", e);
             }
@@ -166,6 +191,11 @@
                 throw new DeploymentException("Unable to connect to server at "+uri+" --
"+e.getMessage());
             } //else, fall through and try local access
         }
+        
+        if (manager instanceof JMXDeploymentManager) {
+            JMXDeploymentManager deploymentManager = (JMXDeploymentManager) manager;
+            deploymentManager.setCommandContext(commandContext);
+        }
     }
 
     private void loadDriver(String driver, DeploymentFactoryManager mgr) throws DeploymentException
{
@@ -190,7 +220,7 @@
         }
     }
 
-    private void doAuthPromptAndRetry(String uri, String user, String password) throws DeploymentException
{
+    private void doAuthPromptAndRetry(String uri, JMXDeploymentManager.CommandContext commandContext,
String user, String password) throws DeploymentException {
         try {
             if(user == null) {
                 out.print("Username: ");
@@ -205,7 +235,7 @@
         } catch(IOException e) {
             throw new DeploymentException("Unable to prompt for login", e);
         }
-        tryToConnect(uri, null, user, password, false);
+        tryToConnect(uri, commandContext, null, user, password, false);
     }
 
     public DeploymentManager getDeploymentManager() {

Modified: geronimo/trunk/modules/deploy-tool/src/java/org/apache/geronimo/deployment/plugin/factories/DeploymentFactoryImpl.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/deploy-tool/src/java/org/apache/geronimo/deployment/plugin/factories/DeploymentFactoryImpl.java?view=diff&r1=159099&r2=159100
==============================================================================
--- geronimo/trunk/modules/deploy-tool/src/java/org/apache/geronimo/deployment/plugin/factories/DeploymentFactoryImpl.java
(original)
+++ geronimo/trunk/modules/deploy-tool/src/java/org/apache/geronimo/deployment/plugin/factories/DeploymentFactoryImpl.java
Sat Mar 26 02:17:51 2005
@@ -76,17 +76,10 @@
                 String[] credentials = new String[]{username, password};
                 environment.put(JMXConnector.CREDENTIALS, credentials);
                 
-                boolean logErrors=false;
-				if( uri.endsWith("/debug") ) {
-					logErrors=true;
-					uri = uri.substring(0, uri.length() - "/debug".length());
-				}
-
                 try {
                     JMXServiceURL address = new JMXServiceURL("service:" + uri);
                     JMXConnector jmxConnector = JMXConnectorFactory.connect(address, environment);
                     JMXDeploymentManager manager = new JMXDeploymentManager(jmxConnector);
-                    manager.setLogErrors(logErrors);
                     return manager;
                 } catch (IOException e) {
                     throw (DeploymentManagerCreationException)new DeploymentManagerCreationException(e.getMessage()).initCause(e);

Modified: geronimo/trunk/modules/deploy-tool/src/java/org/apache/geronimo/deployment/plugin/jmx/JMXDeploymentManager.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/deploy-tool/src/java/org/apache/geronimo/deployment/plugin/jmx/JMXDeploymentManager.java?view=diff&r1=159099&r2=159100
==============================================================================
--- geronimo/trunk/modules/deploy-tool/src/java/org/apache/geronimo/deployment/plugin/jmx/JMXDeploymentManager.java
(original)
+++ geronimo/trunk/modules/deploy-tool/src/java/org/apache/geronimo/deployment/plugin/jmx/JMXDeploymentManager.java
Sat Mar 26 02:17:51 2005
@@ -60,7 +60,7 @@
     private JMXConnector jmxConnector;
     private MBeanServerConnection mbServerConnection;
     private KernelMBean kernel;
-	private boolean logErrors;
+	private CommandContext commandContext;
 
     public JMXDeploymentManager(JMXConnector jmxConnector) throws IOException {
         this.jmxConnector = jmxConnector;
@@ -157,7 +157,7 @@
             throw new IllegalStateException("Disconnected");
         }
         DistributeCommand command = new DistributeCommand(kernel, targetList, moduleArchive,
deploymentPlan);
-        command.setLogErrors(logErrors);
+        command.setCommandContext(commandContext);
         new Thread(command).start();
         return command;
     }
@@ -167,7 +167,7 @@
             throw new IllegalStateException("Disconnected");
         }
         DistributeCommand command = new DistributeCommand(kernel, targetList, moduleArchive,
deploymentPlan);
-        command.setLogErrors(logErrors);
+        command.setCommandContext(commandContext);
         new Thread(command).start();
         return command;
     }
@@ -177,7 +177,7 @@
             throw new IllegalStateException("Disconnected");
         }
         StartCommand command = new StartCommand(kernel, moduleIDList);
-        command.setLogErrors(logErrors);
+        command.setCommandContext(commandContext);
         new Thread(command).start();
         return command;
     }
@@ -187,7 +187,7 @@
             throw new IllegalStateException("Disconnected");
         }
         StopCommand command = new StopCommand(kernel, moduleIDList);
-        command.setLogErrors(logErrors);
+        command.setCommandContext(commandContext);
         new Thread(command).start();
         return command;
     }
@@ -197,7 +197,7 @@
             throw new IllegalStateException("Disconnected");
         }
         UndeployCommand command = new UndeployCommand(kernel, moduleIDList);
-        command.setLogErrors(logErrors);
+        command.setCommandContext(commandContext);
         new Thread(command).start();
         return command;
     }
@@ -211,7 +211,7 @@
             throw new IllegalStateException("Disconnected");
         }
         RedeployCommand command = new RedeployCommand(kernel, moduleIDList, moduleArchive,
deploymentPlan);
-        command.setLogErrors(logErrors);
+        command.setCommandContext(commandContext);
         new Thread(command).start();
         return command;
     }
@@ -221,7 +221,7 @@
             throw new IllegalStateException("Disconnected");
         }
         RedeployCommand command = new RedeployCommand(kernel, moduleIDList, moduleArchive,
deploymentPlan);
-        command.setLogErrors(logErrors);
+        command.setCommandContext(commandContext);
         new Thread(command).start();
         return command;
     }
@@ -264,7 +264,31 @@
         throw new InvalidModuleException("Not supported");
     }
 
-	public void setLogErrors(boolean logErrors) {
-		this.logErrors = logErrors;
+	public void setCommandContext(CommandContext commandContext) {
+		this.commandContext = commandContext;
 	}
+    
+    public static class CommandContext {
+        private boolean logErrors;
+        private boolean verbose;
+        
+        public CommandContext() {
+        }
+        
+        public boolean isLogErrors() {
+            return logErrors;
+        }
+
+        public void setLogErrors(boolean logErrors) {
+            this.logErrors = logErrors;
+        }
+        
+        public boolean isVerbose() {
+            return verbose;
+        }
+        
+        public void setVerbose(boolean verbose) {
+            this.verbose = verbose;
+        }
+    }
 }

Modified: geronimo/trunk/modules/deploy-tool/src/java/org/apache/geronimo/deployment/plugin/local/CommandSupport.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/deploy-tool/src/java/org/apache/geronimo/deployment/plugin/local/CommandSupport.java?view=diff&r1=159099&r2=159100
==============================================================================
--- geronimo/trunk/modules/deploy-tool/src/java/org/apache/geronimo/deployment/plugin/local/CommandSupport.java
(original)
+++ geronimo/trunk/modules/deploy-tool/src/java/org/apache/geronimo/deployment/plugin/local/CommandSupport.java
Sat Mar 26 02:17:51 2005
@@ -35,6 +35,8 @@
 import javax.enterprise.deploy.spi.status.ProgressObject;
 import javax.management.MBeanException;
 
+import org.apache.geronimo.deployment.plugin.jmx.JMXDeploymentManager.CommandContext;
+
 /**
  * @version $Rev$ $Date$
  */
@@ -45,7 +47,7 @@
     private String message;
     private final Set listeners = new HashSet();
     private final List moduleIDs = new ArrayList();
-    private boolean logErrors;
+    private CommandContext commandContext;
 
     private ProgressEvent event = null;
 
@@ -117,15 +119,24 @@
             e = ((MBeanException) e).getTargetException();
         }
 
-        if (logErrors) {
+        if (commandContext.isLogErrors()) {
             System.err.println("Deployer operation failed: " + e.getMessage());
-            e.printStackTrace(System.err);
+            if (commandContext.isVerbose()) {
+                e.printStackTrace(System.err);
+            }
         }
 
         StringWriter writer = new StringWriter();
         PrintWriter printWriter = new PrintWriter(writer);
         printWriter.println(e.getMessage());
-        e.printStackTrace(printWriter);
+        if (commandContext.isVerbose()) {
+            e.printStackTrace(printWriter);
+        } else {
+            Throwable throwable = e;
+            while (null != (throwable = throwable.getCause())) {
+                printWriter.println("\t" + throwable.getMessage());
+            }
+        }
         fail(writer.toString());
     }
 
@@ -201,11 +212,11 @@
         }
     }
 
-    public boolean isLogErrors() {
-        return logErrors;
+    public CommandContext getCommandContext() {
+        return commandContext;
     }
 
-    public void setLogErrors(boolean logErrors) {
-        this.logErrors = logErrors;
+    public void setCommandContext(CommandContext commandContext) {
+        this.commandContext = commandContext;
     }
 }

Modified: geronimo/trunk/modules/deploy-tool/src/java/org/apache/geronimo/deployment/plugin/local/DistributeCommand.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/deploy-tool/src/java/org/apache/geronimo/deployment/plugin/local/DistributeCommand.java?view=diff&r1=159099&r2=159100
==============================================================================
--- geronimo/trunk/modules/deploy-tool/src/java/org/apache/geronimo/deployment/plugin/local/DistributeCommand.java
(original)
+++ geronimo/trunk/modules/deploy-tool/src/java/org/apache/geronimo/deployment/plugin/local/DistributeCommand.java
Sat Mar 26 02:17:51 2005
@@ -18,20 +18,12 @@
 package org.apache.geronimo.deployment.plugin.local;
 
 import java.io.File;
-import java.io.FileOutputStream;
-import java.io.IOException;
 import java.io.InputStream;
-import java.io.OutputStream;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Set;
+
 import javax.enterprise.deploy.shared.CommandType;
 import javax.enterprise.deploy.spi.Target;
-import javax.enterprise.deploy.spi.TargetModuleID;
 import javax.management.ObjectName;
 
-import org.apache.geronimo.common.DeploymentException;
-import org.apache.geronimo.deployment.plugin.TargetModuleIDImpl;
 import org.apache.geronimo.deployment.util.DeploymentUtil;
 import org.apache.geronimo.kernel.jmx.KernelMBean;
 

Modified: geronimo/trunk/modules/deploy-tool/src/java/org/apache/geronimo/deployment/plugin/local/RedeployCommand.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/deploy-tool/src/java/org/apache/geronimo/deployment/plugin/local/RedeployCommand.java?view=diff&r1=159099&r2=159100
==============================================================================
--- geronimo/trunk/modules/deploy-tool/src/java/org/apache/geronimo/deployment/plugin/local/RedeployCommand.java
(original)
+++ geronimo/trunk/modules/deploy-tool/src/java/org/apache/geronimo/deployment/plugin/local/RedeployCommand.java
Sat Mar 26 02:17:51 2005
@@ -19,9 +19,9 @@
 import java.io.File;
 import java.io.InputStream;
 import java.net.URI;
+
 import javax.enterprise.deploy.shared.CommandType;
 import javax.enterprise.deploy.spi.TargetModuleID;
-import javax.enterprise.deploy.spi.Target;
 import javax.management.ObjectName;
 
 import org.apache.geronimo.deployment.plugin.TargetImpl;
@@ -33,7 +33,6 @@
  * @version $Rev$ $Date$
  */
 public class RedeployCommand extends AbstractDeployCommand {
-    private static final String[] DEPLOY_SIG = {File.class.getName(), File.class.getName()};
     private static final String[] UNINSTALL_SIG = {URI.class.getName()};
     private final TargetModuleID[] modules;
 

Modified: geronimo/trunk/modules/deploy-tool/src/java/org/apache/geronimo/deployment/plugin/local/StartCommand.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/deploy-tool/src/java/org/apache/geronimo/deployment/plugin/local/StartCommand.java?view=diff&r1=159099&r2=159100
==============================================================================
--- geronimo/trunk/modules/deploy-tool/src/java/org/apache/geronimo/deployment/plugin/local/StartCommand.java
(original)
+++ geronimo/trunk/modules/deploy-tool/src/java/org/apache/geronimo/deployment/plugin/local/StartCommand.java
Sat Mar 26 02:17:51 2005
@@ -18,11 +18,11 @@
 package org.apache.geronimo.deployment.plugin.local;
 
 import java.net.URI;
+
 import javax.enterprise.deploy.shared.CommandType;
 import javax.enterprise.deploy.spi.TargetModuleID;
 
 import org.apache.geronimo.kernel.jmx.KernelMBean;
-import org.apache.geronimo.kernel.jmx.KernelMBean;
 
 /**
  *
@@ -45,7 +45,6 @@
                 TargetModuleID module = modules[i];
 
                 URI moduleID = URI.create(module.getModuleID());
-//                System.err.println("Starting module " + moduleID);
                 kernel.startConfiguration(moduleID);
                 addModule(module);
             }

Modified: geronimo/trunk/modules/deploy-tool/src/java/org/apache/geronimo/deployment/plugin/local/StopCommand.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/deploy-tool/src/java/org/apache/geronimo/deployment/plugin/local/StopCommand.java?view=diff&r1=159099&r2=159100
==============================================================================
--- geronimo/trunk/modules/deploy-tool/src/java/org/apache/geronimo/deployment/plugin/local/StopCommand.java
(original)
+++ geronimo/trunk/modules/deploy-tool/src/java/org/apache/geronimo/deployment/plugin/local/StopCommand.java
Sat Mar 26 02:17:51 2005
@@ -18,6 +18,7 @@
 package org.apache.geronimo.deployment.plugin.local;
 
 import java.net.URI;
+
 import javax.enterprise.deploy.shared.CommandType;
 import javax.enterprise.deploy.spi.TargetModuleID;
 

Modified: geronimo/trunk/modules/deploy-tool/src/java/org/apache/geronimo/deployment/plugin/local/UndeployCommand.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/deploy-tool/src/java/org/apache/geronimo/deployment/plugin/local/UndeployCommand.java?view=diff&r1=159099&r2=159100
==============================================================================
--- geronimo/trunk/modules/deploy-tool/src/java/org/apache/geronimo/deployment/plugin/local/UndeployCommand.java
(original)
+++ geronimo/trunk/modules/deploy-tool/src/java/org/apache/geronimo/deployment/plugin/local/UndeployCommand.java
Sat Mar 26 02:17:51 2005
@@ -17,14 +17,15 @@
 package org.apache.geronimo.deployment.plugin.local;
 
 import java.net.URI;
+
 import javax.enterprise.deploy.shared.CommandType;
 import javax.enterprise.deploy.spi.TargetModuleID;
 import javax.management.ObjectName;
 
 import org.apache.geronimo.deployment.plugin.TargetImpl;
 import org.apache.geronimo.deployment.plugin.TargetModuleIDImpl;
-import org.apache.geronimo.kernel.jmx.KernelMBean;
 import org.apache.geronimo.kernel.config.NoSuchConfigException;
+import org.apache.geronimo.kernel.jmx.KernelMBean;
 
 /**
  * @version $Rev$ $Date$



Mime
View raw message