gump-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bode...@apache.org
Subject svn commit: r627687 - in /gump/mvnrepo/trunk/src/java/org/apache/gump/mvnrepoproxy: Main.java restlets/Stop.java
Date Thu, 14 Feb 2008 09:42:39 GMT
Author: bodewig
Date: Thu Feb 14 01:42:28 2008
New Revision: 627687

URL: http://svn.apache.org/viewvc?rev=627687&view=rev
Log:
for some reason Component.start() blocks on Solaris and MacOS X but not on vmgump's Ubuntu
system - block explicitly

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

Modified: gump/mvnrepo/trunk/src/java/org/apache/gump/mvnrepoproxy/Main.java
URL: http://svn.apache.org/viewvc/gump/mvnrepo/trunk/src/java/org/apache/gump/mvnrepoproxy/Main.java?rev=627687&r1=627686&r2=627687&view=diff
==============================================================================
--- gump/mvnrepo/trunk/src/java/org/apache/gump/mvnrepoproxy/Main.java (original)
+++ gump/mvnrepo/trunk/src/java/org/apache/gump/mvnrepoproxy/Main.java Thu Feb 14 01:42:28
2008
@@ -39,6 +39,24 @@
  */
 public class Main {
 
+    // yes, I know this is ugly, will revisit the locking logic once
+    // the code works on vmgump
+    private static final Object lock = new Object();
+    private static volatile boolean stopped = false;
+    public static void shutdown() {
+        synchronized (lock) {
+            stopped = true;
+            lock.notifyAll();
+        }
+     }
+     private static void waitForShutdown() throws InterruptedException {
+         synchronized (lock) {
+             while (!stopped) {
+                 lock.wait();
+             }
+         }
+     }
+
     /**
      * Starts Jetty with the application
      */
@@ -54,6 +72,8 @@
             c.getServers().add(Protocol.HTTP, port);
             c.getClients().add(Protocol.HTTP);
             c.start();
+            waitForShutdown();
+            System.err.println("Component finished");
         } catch (Throwable t) {
             t.printStackTrace();
             exitCode = -1;
@@ -108,4 +128,4 @@
         component.getDefaultHost().attach(repoApp);
         return component;
     }
-}
\ No newline at end of file
+}

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=627687&r1=627686&r2=627687&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 Thu Feb 14
01:42:28 2008
@@ -23,6 +23,8 @@
 import java.util.logging.Level;
 import java.util.logging.Logger;
 
+import org.apache.gump.mvnrepoproxy.Main;
+
 import org.restlet.Component;
 import org.restlet.Context;
 import org.restlet.Restlet;
@@ -58,7 +60,8 @@
                     } catch (Exception e) {
                         log.log(Level.WARNING, "failed to stop Jetty", e);
                     }
+                    Main.shutdown();
                 }
             }, 1000);
     }
-}
\ No newline at end of file
+}



Mime
View raw message