tomee-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rmannibu...@apache.org
Subject svn commit: r1405038 - in /openejb/trunk/openejb: container/openejb-core/src/main/java/org/apache/openejb/config/ maven/tomee-maven-plugin/src/main/java/org/apache/openejb/maven/plugin/
Date Fri, 02 Nov 2012 16:34:51 GMT
Author: rmannibucau
Date: Fri Nov  2 16:34:50 2012
New Revision: 1405038

URL: http://svn.apache.org/viewvc?rev=1405038&view=rev
Log:
updating tomee maven plugin to use remoteserver properly

Modified:
    openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/config/RemoteServer.java
    openejb/trunk/openejb/maven/tomee-maven-plugin/src/main/java/org/apache/openejb/maven/plugin/AbstractTomEEMojo.java
    openejb/trunk/openejb/maven/tomee-maven-plugin/src/main/java/org/apache/openejb/maven/plugin/StopTomEEMojo.java

Modified: openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/config/RemoteServer.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/config/RemoteServer.java?rev=1405038&r1=1405037&r2=1405038&view=diff
==============================================================================
--- openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/config/RemoteServer.java
(original)
+++ openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/config/RemoteServer.java
Fri Nov  2 16:34:50 2012
@@ -26,7 +26,12 @@ import java.io.OutputStream;
 import java.lang.reflect.Field;
 import java.net.InetSocketAddress;
 import java.net.Socket;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Properties;
 
 /**
  * @version $Rev$ $Date$
@@ -423,18 +428,22 @@ public class RemoteServer {
     public void stop() {
         if (!serverHasAlreadyBeenStarted) {
             try {
-                shutdown();
-
-                // check tomcat was effectively shutted down
-                // we can have some concurrent shutdown commands (catalina shutdown hook
for instance)
-                // so we can have to wait here since it is important to be synchronous in
this method
-                waitForServerShutdown();
+                forceStop();
             } catch (Exception e) {
                 e.printStackTrace(System.err);
             }
         }
     }
 
+    public void forceStop() throws Exception {
+        shutdown();
+
+        // check tomcat was effectively shutted down
+        // we can have some concurrent shutdown commands (catalina shutdown hook for instance)
+        // so we can have to wait here since it is important to be synchronous in this method
+        waitForServerShutdown();
+    }
+
     private void waitForServerShutdown() throws InterruptedException {
         if (verbose) {
             System.out.print("Waiting for TomEE shutdown.");

Modified: openejb/trunk/openejb/maven/tomee-maven-plugin/src/main/java/org/apache/openejb/maven/plugin/AbstractTomEEMojo.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb/maven/tomee-maven-plugin/src/main/java/org/apache/openejb/maven/plugin/AbstractTomEEMojo.java?rev=1405038&r1=1405037&r2=1405038&view=diff
==============================================================================
--- openejb/trunk/openejb/maven/tomee-maven-plugin/src/main/java/org/apache/openejb/maven/plugin/AbstractTomEEMojo.java
(original)
+++ openejb/trunk/openejb/maven/tomee-maven-plugin/src/main/java/org/apache/openejb/maven/plugin/AbstractTomEEMojo.java
Fri Nov  2 16:34:50 2012
@@ -525,15 +525,21 @@ public abstract class AbstractTomEEMojo 
 
         System.setProperty("server.shutdown.port", Integer.toString(tomeeShutdownPort));
         final RemoteServer server = new RemoteServer(getConnectAttempts(), false);
-        if (!getNoShutdownHook()) {
-            addShutdownHooks(server);
+        addShutdownHooks(server); // some shutdown hooks are always added (see UpdatableTomEEMojo)
+
+        if (getNoShutdownHook()) {
+            Runtime.getRuntime().addShutdownHook(new Thread() {
+                @Override public void run() {
+                    server.stop();
+                }
+            });
         }
 
         getLog().info("Running '" + getClass().getSimpleName().replace("TomEEMojo", "").toLowerCase(Locale.ENGLISH)
                 + "'. Configured TomEE in plugin is " + tomeeHost + ":" + tomeeHttpPort
                 + " (plugin shutdown port is " + tomeeShutdownPort + ")");
 
-        server.start(strings, getCmd(), false);
+        serverCmd(server, strings);
 
         if (!getNoShutdownHook()) {
             try {
@@ -544,12 +550,12 @@ public abstract class AbstractTomEEMojo 
         }
     }
 
+    protected void serverCmd(final RemoteServer server, final List<String> strings)
{
+        server.start(strings, getCmd(), false);
+    }
+
     protected void addShutdownHooks(final RemoteServer server) {
-        Runtime.getRuntime().addShutdownHook(new Thread() {
-            @Override public void run() {
-                server.stop();
-            }
-        });
+        // no-op
     }
 
     protected  int getConnectAttempts() {

Modified: openejb/trunk/openejb/maven/tomee-maven-plugin/src/main/java/org/apache/openejb/maven/plugin/StopTomEEMojo.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb/maven/tomee-maven-plugin/src/main/java/org/apache/openejb/maven/plugin/StopTomEEMojo.java?rev=1405038&r1=1405037&r2=1405038&view=diff
==============================================================================
--- openejb/trunk/openejb/maven/tomee-maven-plugin/src/main/java/org/apache/openejb/maven/plugin/StopTomEEMojo.java
(original)
+++ openejb/trunk/openejb/maven/tomee-maven-plugin/src/main/java/org/apache/openejb/maven/plugin/StopTomEEMojo.java
Fri Nov  2 16:34:50 2012
@@ -21,6 +21,9 @@ import org.apache.maven.plugin.MojoExecu
 import org.apache.maven.plugin.MojoFailureException;
 import org.apache.maven.plugins.annotations.Mojo;
 import org.apache.maven.plugins.annotations.ResolutionScope;
+import org.apache.openejb.config.RemoteServer;
+
+import java.util.List;
 
 
 @Mojo(name = "stop", requiresDependencyResolution = ResolutionScope.RUNTIME_PLUS_SYSTEM)
@@ -34,4 +37,13 @@ public class StopTomEEMojo extends Abstr
     public void execute() throws MojoExecutionException, MojoFailureException {
         run(); // skip other processings which are useless for a stop
     }
+
+    @Override
+    protected void serverCmd(final RemoteServer server, final List<String> strings)
{
+        try {
+            server.forceStop();
+        } catch (Exception e) {
+            getLog().error(e.getMessage(), e);
+        }
+    }
 }



Mime
View raw message