geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jdil...@apache.org
Subject svn commit: r440010 - in /geronimo/server/trunk/maven-plugins/geronimo-maven-plugin/src/main/java/org/apache/geronimo/mavenplugins/geronimo: InstallerMojoSupport.java StartServerMojo.java
Date Mon, 04 Sep 2006 10:15:52 GMT
Author: jdillon
Date: Mon Sep  4 03:15:51 2006
New Revision: 440010

URL: http://svn.apache.org/viewvc?view=rev&rev=440010
Log:
Use ObjectHolder instead of Throwable to hold errors in the runner thread
Add support for `mvn geronimo:start -Ddebug=true` to enable a predefined set of JVM debug
flags
Add support for server.jar's --override via geronimo:start's startModules configuration

Modified:
    geronimo/server/trunk/maven-plugins/geronimo-maven-plugin/src/main/java/org/apache/geronimo/mavenplugins/geronimo/InstallerMojoSupport.java
    geronimo/server/trunk/maven-plugins/geronimo-maven-plugin/src/main/java/org/apache/geronimo/mavenplugins/geronimo/StartServerMojo.java

Modified: geronimo/server/trunk/maven-plugins/geronimo-maven-plugin/src/main/java/org/apache/geronimo/mavenplugins/geronimo/InstallerMojoSupport.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/maven-plugins/geronimo-maven-plugin/src/main/java/org/apache/geronimo/mavenplugins/geronimo/InstallerMojoSupport.java?view=diff&rev=440010&r1=440009&r2=440010
==============================================================================
--- geronimo/server/trunk/maven-plugins/geronimo-maven-plugin/src/main/java/org/apache/geronimo/mavenplugins/geronimo/InstallerMojoSupport.java
(original)
+++ geronimo/server/trunk/maven-plugins/geronimo-maven-plugin/src/main/java/org/apache/geronimo/mavenplugins/geronimo/InstallerMojoSupport.java
Mon Sep  4 03:15:51 2006
@@ -23,16 +23,17 @@
 import java.util.Map;
 import java.util.HashMap;
 
-import org.apache.tools.ant.taskdefs.Expand;
-import org.apache.maven.project.MavenProject;
 import org.apache.maven.artifact.factory.ArtifactFactory;
 import org.apache.maven.artifact.resolver.ArtifactResolver;
 import org.apache.maven.artifact.repository.ArtifactRepository;
 import org.apache.maven.artifact.Artifact;
+
 import org.apache.maven.plugin.MojoExecutionException;
 import org.apache.maven.plugin.MojoFailureException;
 
 import org.codehaus.plexus.util.FileUtils;
+
+import org.apache.tools.ant.taskdefs.Expand;
 
 /**
  * Common assembly install support.

Modified: geronimo/server/trunk/maven-plugins/geronimo-maven-plugin/src/main/java/org/apache/geronimo/mavenplugins/geronimo/StartServerMojo.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/maven-plugins/geronimo-maven-plugin/src/main/java/org/apache/geronimo/mavenplugins/geronimo/StartServerMojo.java?view=diff&rev=440010&r1=440009&r2=440010
==============================================================================
--- geronimo/server/trunk/maven-plugins/geronimo-maven-plugin/src/main/java/org/apache/geronimo/mavenplugins/geronimo/StartServerMojo.java
(original)
+++ geronimo/server/trunk/maven-plugins/geronimo-maven-plugin/src/main/java/org/apache/geronimo/mavenplugins/geronimo/StartServerMojo.java
Mon Sep  4 03:15:51 2006
@@ -87,6 +87,27 @@
      */
     private int verifyTimeout = -1;
 
+    /**
+     * JVM arguments to be applied when debug is enabled.
+     *
+     * @parameter
+     */
+    private String[] debugArguments = null;
+
+    /**
+     * Enable debug mode.  When true, debugArguments are added to the JVM.
+     *
+     * @parameter expression="${debug}" default-value="false"
+     */
+    private boolean debug = false;
+
+    /**
+     * A list of module names to be started using --override.
+     *
+     * @parameter
+     */
+    private String[] startModules = null;
+
     private Timer timer = new Timer(true);
 
     protected void doExecute() throws Exception {
@@ -114,6 +135,21 @@
             java.setMaxmemory(maximumMemory);
         }
 
+        if (debug) {
+            if (debugArguments == null) {
+                throw new MojoExecutionException("To enable debug mode a set of debugArguments
needs to be configured");
+            }
+            else if (debugArguments.length == 0) {
+                throw new MojoExecutionException("At least one argument must be configured
with debugArguments");
+            }
+
+            log.info("Enabling debug JVM arguments");
+
+            for (int i=0; i < debugArguments.length; i++) {
+                java.createJvmarg().setValue(debugArguments[i]);
+            }
+        }
+
         if (quiet) {
             java.createArg().setValue("--quiet");
         }
@@ -129,16 +165,22 @@
             java.createArg().setValue("--veryverbose");
         }
 
-        //
-        // TODO: Support --override
-        //
+        if (startModules != null) {
+            if (startModules.length == 0) {
+                throw new MojoExecutionException("At least one module name must be configured
with startModule");
+            }
 
-        //
-        // TODO: Support JVM args for debug mode, add debug flag to enable or disable
-        //
+            log.info("Overriding the set of modules to be started");
+
+            java.createArg().setValue("--override");
 
-        // Holds any exception that was thrown during startup (as the cause)
-        final Throwable errorHolder = new Throwable();
+            for (int i=0; i < startModules.length; i++) {
+                java.createArg().setValue(startModules[i]);
+            }
+        }
+        
+        // Holds any exception that was thrown during startup
+        final ObjectHolder errorHolder = new ObjectHolder();
 
         // Start the server int a seperate thread
         Thread t = new Thread("Geronimo Server Runner") {
@@ -147,7 +189,7 @@
                     java.execute();
                 }
                 catch (Exception e) {
-                    errorHolder.initCause(e);
+                    errorHolder.set(e);
 
                     //
                     // NOTE: Don't log here, as when the JVM exists an exception will get
thrown by Ant
@@ -183,8 +225,8 @@
                 throw new MojoExecutionException("Unable to verify if the server was started
in the given time");
             }
 
-            if (errorHolder.getCause() != null) {
-                throw new MojoExecutionException("Failed to start Geronimo server", errorHolder.getCause());
+            if (errorHolder.isSet()) {
+                throw new MojoExecutionException("Failed to start Geronimo server", (Throwable)errorHolder.get());
             }
 
             started = server.isFullyStarted();



Mime
View raw message