geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jdil...@apache.org
Subject svn commit: r439883 - in /geronimo/server/trunk/maven-plugins/geronimo-maven-plugin/src/main/java/org/apache/geronimo/mavenplugins/geronimo: ServerMojoSupport.java ServerProxy.java StopServerMojo.java
Date Mon, 04 Sep 2006 00:23:12 GMT
Author: jdillon
Date: Sun Sep  3 17:23:12 2006
New Revision: 439883

URL: http://svn.apache.org/viewvc?view=rev&rev=439883
Log:
Added ServerProxy.shutdown() and using this for geronimo:stop

Modified:
    geronimo/server/trunk/maven-plugins/geronimo-maven-plugin/src/main/java/org/apache/geronimo/mavenplugins/geronimo/ServerMojoSupport.java
    geronimo/server/trunk/maven-plugins/geronimo-maven-plugin/src/main/java/org/apache/geronimo/mavenplugins/geronimo/ServerProxy.java
    geronimo/server/trunk/maven-plugins/geronimo-maven-plugin/src/main/java/org/apache/geronimo/mavenplugins/geronimo/StopServerMojo.java

Modified: geronimo/server/trunk/maven-plugins/geronimo-maven-plugin/src/main/java/org/apache/geronimo/mavenplugins/geronimo/ServerMojoSupport.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/maven-plugins/geronimo-maven-plugin/src/main/java/org/apache/geronimo/mavenplugins/geronimo/ServerMojoSupport.java?view=diff&rev=439883&r1=439882&r2=439883
==============================================================================
--- geronimo/server/trunk/maven-plugins/geronimo-maven-plugin/src/main/java/org/apache/geronimo/mavenplugins/geronimo/ServerMojoSupport.java
(original)
+++ geronimo/server/trunk/maven-plugins/geronimo-maven-plugin/src/main/java/org/apache/geronimo/mavenplugins/geronimo/ServerMojoSupport.java
Sun Sep  3 17:23:12 2006
@@ -59,6 +59,10 @@
      */
     protected String password = null;
 
+    //
+    // TODO: Move assembly bits to InstallerMojoSupport
+    //
+    
     /**
      * List of assembly artifact configurations.  Artifacts need to point to ZIP archives.
      *

Modified: geronimo/server/trunk/maven-plugins/geronimo-maven-plugin/src/main/java/org/apache/geronimo/mavenplugins/geronimo/ServerProxy.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/maven-plugins/geronimo-maven-plugin/src/main/java/org/apache/geronimo/mavenplugins/geronimo/ServerProxy.java?view=diff&rev=439883&r1=439882&r2=439883
==============================================================================
--- geronimo/server/trunk/maven-plugins/geronimo-maven-plugin/src/main/java/org/apache/geronimo/mavenplugins/geronimo/ServerProxy.java
(original)
+++ geronimo/server/trunk/maven-plugins/geronimo-maven-plugin/src/main/java/org/apache/geronimo/mavenplugins/geronimo/ServerProxy.java
Sun Sep  3 17:23:12 2006
@@ -102,10 +102,6 @@
         return mbeanConnection;
     }
 
-    //
-    // TODO: Add shutdown related methods so we can shutdown via JMX and not require an assembly
to be installed
-    //
-    
     public boolean isFullyStarted() {
         boolean fullyStarted = true;
 
@@ -128,7 +124,7 @@
             lastError = e;
         }
         catch (Exception e) {
-            log.warn("Unable to determine if the kernel is fully started", e);
+            log.warn("Unable to determine if the server is fully started", e);
             fullyStarted = false;
             lastError = e;
         }
@@ -140,6 +136,16 @@
         return lastError;
     }
 
+    public void shutdown() {
+        try {
+            invoke("shutdown");
+        }
+        catch (Exception e) {
+            log.warn("Unable to shutdown the server", e);
+            lastError = e;
+        }
+    }
+
     //
     // Kernel invocation helpers
     //
@@ -161,6 +167,10 @@
         }
 
         return invoke(operation, args, signature);
+    }
+
+    private Object invoke(final String operation) throws Exception {
+        return invoke(operation, new Object[0]);
     }
 
     private Set listGBeans(final AbstractNameQuery query) throws Exception {

Modified: geronimo/server/trunk/maven-plugins/geronimo-maven-plugin/src/main/java/org/apache/geronimo/mavenplugins/geronimo/StopServerMojo.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/maven-plugins/geronimo-maven-plugin/src/main/java/org/apache/geronimo/mavenplugins/geronimo/StopServerMojo.java?view=diff&rev=439883&r1=439882&r2=439883
==============================================================================
--- geronimo/server/trunk/maven-plugins/geronimo-maven-plugin/src/main/java/org/apache/geronimo/mavenplugins/geronimo/StopServerMojo.java
(original)
+++ geronimo/server/trunk/maven-plugins/geronimo-maven-plugin/src/main/java/org/apache/geronimo/mavenplugins/geronimo/StopServerMojo.java
Sun Sep  3 17:23:12 2006
@@ -18,10 +18,6 @@
 
 import org.apache.maven.plugin.MojoExecutionException;
 
-import java.io.File;
-
-import org.apache.tools.ant.taskdefs.Java;
-
 /**
  * Stop the Geronimo server.
  *
@@ -32,58 +28,24 @@
 public class StopServerMojo
     extends ServerMojoSupport
 {
-    /**
-     * Time in seconds to wait before timing out the stop operation.
-     *
-     * @parameter default-value="60"
-     * @required
-     */
-    private int timeout = -1;
-
     protected void doExecute() throws Exception {
-        log.info("Stopping Geronimo server...");
+        ServerProxy server = new ServerProxy(port, username, password);
 
         //
-        // TODO: Might want to add a marker to the build when start completes...
-        //       so stop can pick up the right dir w/o assembly configuration
+        // TODO: Maybe we just need isStarted() not need to be fully started?
         //
-
-        if (!installDir.exists()) {
-            // Complain if there is no assemblyDir, as that probably means that 'start' was
not executed.
-            throw new MojoExecutionException("Missing assembly directory: " + installDir);
-        }
-
-        Java java = (Java)createTask("java");
-        java.setJar(new File(installDir, "bin/shutdown.jar"));
-        java.setDir(installDir);
-        java.setFailonerror(true);
-        java.setFork(true);
-        java.setLogError(true);
-
-        if (timeout > 0) {
-            // Convert to milliseconds
-            java.setTimeout(new Long(timeout * 1000));
-        }
-
-        if (port > 0) {
-            java.createArg().setValue("--port");
-            java.createArg().setValue(String.valueOf(port));
-        }
-
-        if (username != null) {
-            java.createArg().setValue("--user");
-            java.createArg().setValue(username);
+        
+        if (!server.isFullyStarted()) {
+            throw new MojoExecutionException("Server does not appear to be started");
         }
-
-        if (password != null) {
-            java.createArg().setValue("--password");
-            java.createArg().setValue(password);
+        else {
+            log.info("Stopping Geronimo server...");
+            
+            server.shutdown();
+
+            //
+            // TODO: Verify its down?
+            //
         }
-
-        java.execute();
-
-        //
-        // TODO: Verify that it actually stopped?
-        //
     }
 }



Mime
View raw message