gump-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bode...@apache.org
Subject svn commit: r598135 - /gump/mvnrepo/trunk/src/java/org/apache/gump/mvnrepoproxy/restlets/Stop.java
Date Mon, 26 Nov 2007 05:33:07 GMT
Author: bodewig
Date: Sun Nov 25 21:33:04 2007
New Revision: 598135

URL: http://svn.apache.org/viewvc?rev=598135&view=rev
Log:
delay stopping Jetty, explicitly exit the VM

Modified:
    gump/mvnrepo/trunk/src/java/org/apache/gump/mvnrepoproxy/restlets/Stop.java

Modified: gump/mvnrepo/trunk/src/java/org/apache/gump/mvnrepoproxy/restlets/Stop.java
URL: http://svn.apache.org/viewvc/gump/mvnrepo/trunk/src/java/org/apache/gump/mvnrepoproxy/restlets/Stop.java?rev=598135&r1=598134&r2=598135&view=diff
==============================================================================
--- gump/mvnrepo/trunk/src/java/org/apache/gump/mvnrepoproxy/restlets/Stop.java (original)
+++ gump/mvnrepo/trunk/src/java/org/apache/gump/mvnrepoproxy/restlets/Stop.java Sun Nov 25
21:33:04 2007
@@ -18,6 +18,11 @@
 
 package org.apache.gump.mvnrepoproxy.restlets;
 
+import java.util.Timer;
+import java.util.TimerTask;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
 import org.restlet.Component;
 import org.restlet.Context;
 import org.restlet.Restlet;
@@ -29,6 +34,7 @@
  */
 public class Stop extends Restlet {
 
+    private final static Logger log = Logger.getLogger(Stop.class.getName());
     private final Component comp;
 
     public Stop(Context ctx, Component comp) {
@@ -38,10 +44,22 @@
 
     @Override
     public void handle(Request request, Response response) {
-        try {
-            comp.stop();
-        } catch (Exception e) {
-            throw new RuntimeException(e);
-        }
+        final Timer t = new Timer(true);
+        t.schedule(new TimerTask() {
+                @Override
+                public void run() {
+                    try {
+                        comp.stop();
+                    } catch (Exception e) {
+                        log.log(Level.WARNING, "failed to stop Jetty", e);
+                    }
+                    t.schedule(new TimerTask() {
+                            @Override
+                            public void run() {
+                                System.exit(0);
+                            }
+                        }, 1000);
+                }
+            }, 1000);
     }
 }



Mime
View raw message