]> source.dussan.org Git - vaadin-framework.git/commitdiff
development server now dies properly if address is already in use or another prevente...
authorMatti Tahvonen <matti.tahvonen@itmill.com>
Wed, 26 May 2010 08:57:16 +0000 (08:57 +0000)
committerMatti Tahvonen <matti.tahvonen@itmill.com>
Wed, 26 May 2010 08:57:16 +0000 (08:57 +0000)
svn changeset:13366/svn branch:6.4

src/com/vaadin/launcher/DemoLauncher.java
src/com/vaadin/launcher/DevelopmentServerLauncher.java

index d52df1f8ae2ca1d81b80953705f7113095c3b3a4..38b6060a27a08171896354c25a6f9d867a280b57 100644 (file)
@@ -34,7 +34,7 @@ import com.vaadin.launcher.util.BrowserLauncher;
  */
 public class DemoLauncher {
 
-    public static void main(String[] args) {
+    public static void main(String[] args) throws Exception {
 
         final Map serverArgs = DevelopmentServerLauncher.parseArguments(args);
         boolean deployed = false;
@@ -59,7 +59,7 @@ public class DemoLauncher {
             }
         }
 
-        // Start the Winstone servlet container
+        // Start the Jetty servlet container
         final String url = DevelopmentServerLauncher.runServer(serverArgs,
                 "Demo Server");
 
index b7caa881b13edfe485d01063c521a263342181c9..79e9775d5eb338a038b9413ef7f676e201f75b41 100644 (file)
@@ -30,8 +30,9 @@ public class DevelopmentServerLauncher {
      * for options.\r
      * \r
      * @param args\r
+     * @throws Exception\r
      */\r
-    public static void main(String[] args) {\r
+    public static void main(String[] args) throws Exception {\r
 \r
         // Pass-through of arguments for Jetty\r
         final Map<String, String> serverArgs = parseArguments(args);\r
@@ -55,9 +56,11 @@ public class DevelopmentServerLauncher {
      * \r
      * @param serverArgs\r
      * @return\r
+     * @throws Exception\r
+     * @throws Exception\r
      */\r
     protected static String runServer(Map<String, String> serverArgs,\r
-            String mode) {\r
+            String mode) throws Exception {\r
 \r
         // Assign default values for some arguments\r
         assignDefault(serverArgs, "webroot", "WebContent");\r
@@ -81,27 +84,27 @@ public class DevelopmentServerLauncher {
                         + serverPort\r
                         + "\n-------------------------------------------------\n");\r
 \r
-        try {\r
-            final Server server = new Server();\r
+        final Server server = new Server();\r
 \r
-            final Connector connector = new SelectChannelConnector();\r
+        final Connector connector = new SelectChannelConnector();\r
 \r
-            connector.setPort(port);\r
-            server.setConnectors(new Connector[] { connector });\r
+        connector.setPort(port);\r
+        server.setConnectors(new Connector[] { connector });\r
 \r
-            final WebAppContext webappcontext = new WebAppContext();\r
-            String path = DevelopmentServerLauncher.class.getPackage()\r
-                    .getName().replace(".", File.separator);\r
-            webappcontext.setDefaultsDescriptor(path + File.separator\r
-                    + "jetty-webdefault.xml");\r
-            webappcontext.setContextPath(serverArgs.get("context"));\r
-            webappcontext.setWar(serverArgs.get("webroot"));\r
-            server.setHandler(webappcontext);\r
+        final WebAppContext webappcontext = new WebAppContext();\r
+        String path = DevelopmentServerLauncher.class.getPackage().getName()\r
+                .replace(".", File.separator);\r
+        webappcontext.setDefaultsDescriptor(path + File.separator\r
+                + "jetty-webdefault.xml");\r
+        webappcontext.setContextPath(serverArgs.get("context"));\r
+        webappcontext.setWar(serverArgs.get("webroot"));\r
+        server.setHandler(webappcontext);\r
 \r
+        try {\r
             server.start();\r
-        } catch (final Exception e) {\r
-            e.printStackTrace();\r
-            return null;\r
+        } catch (Exception e) {\r
+            server.stop();\r
+            throw e;\r
         }\r
 \r
         return "http://localhost:" + port + serverArgs.get("context");\r