summaryrefslogtreecommitdiffstats
path: root/src/com/itmill/toolkit/launcher/ITMillToolkitWebMode.java
diff options
context:
space:
mode:
authorMarc Englund <marc.englund@itmill.com>2008-04-29 11:57:11 +0000
committerMarc Englund <marc.englund@itmill.com>2008-04-29 11:57:11 +0000
commit6febb1db3e1a8723cf8b07e3c180663f8724789c (patch)
treea86284cafbd80e82546ecca98d56c3fe4f38ce80 /src/com/itmill/toolkit/launcher/ITMillToolkitWebMode.java
parentffbea78a4430950b624e6e22e3347bcd1feec6be (diff)
downloadvaadin-framework-6febb1db3e1a8723cf8b07e3c180663f8724789c.tar.gz
vaadin-framework-6febb1db3e1a8723cf8b07e3c180663f8724789c.zip
formatted
svn changeset:4282/svn branch:trunk
Diffstat (limited to 'src/com/itmill/toolkit/launcher/ITMillToolkitWebMode.java')
-rw-r--r--src/com/itmill/toolkit/launcher/ITMillToolkitWebMode.java210
1 files changed, 105 insertions, 105 deletions
diff --git a/src/com/itmill/toolkit/launcher/ITMillToolkitWebMode.java b/src/com/itmill/toolkit/launcher/ITMillToolkitWebMode.java
index 96727c41f3..0d8297504c 100644
--- a/src/com/itmill/toolkit/launcher/ITMillToolkitWebMode.java
+++ b/src/com/itmill/toolkit/launcher/ITMillToolkitWebMode.java
@@ -20,110 +20,110 @@ import com.itmill.toolkit.launcher.util.BrowserLauncher;
*/
public class ITMillToolkitWebMode {
- private final static String serverPort = "8888";
-
- /**
- * Main function for running Jetty.
- *
- * Command line Arguments are passed through to Jetty, see runServer method
- * for options.
- *
- * @param args
- */
- public static void main(String[] args) {
-
- // Pass-through of arguments for Jetty
- final Map serverArgs = parseArguments(args);
-
- // Start Jetty
- System.out.println("Starting Jetty servlet container.");
- final String url = runServer(serverArgs, "Web Mode");
-
- // Start Browser
- System.out.println("Starting Web Browser.");
- if (url != null) {
- BrowserLauncher.openBrowser(url);
- }
-
- }
-
- /**
- * Run the server with specified arguments.
- *
- * @param serverArgs
- * @return
- */
- protected static String runServer(Map serverArgs, String mode) {
-
- // Add help for System.out
- System.out
- .println("-------------------------------------------------\n"
- + "Starting IT Mill Toolkit in "
- + mode
- + ".\n"
- + "Running in http://localhost:"
- + serverPort
- + "\n-------------------------------------------------\n");
-
- // Assign default values for some arguments
- assignDefault(serverArgs, "webroot", "WebContent");
- assignDefault(serverArgs, "httpPort", serverPort);
-
- try {
- final Server server = new Server();
-
- final Connector connector = new SelectChannelConnector();
-
- connector.setPort(8888);
- server.setConnectors(new Connector[] { connector });
-
- final WebAppContext webappcontext = new WebAppContext();
- webappcontext.setContextPath("");
- webappcontext.setWar(serverArgs.get("webroot").toString());
-
- server.setHandler(webappcontext);
-
- server.start();
- } catch (final Exception e) {
- e.printStackTrace();
- return null;
- }
-
- return "http://localhost:" + serverArgs.get("httpPort");
- }
-
- /**
- * Assign default value for given key.
- *
- * @param map
- * @param key
- * @param value
- */
- private static void assignDefault(Map map, String key, String value) {
- if (!map.containsKey(key)) {
- map.put(key, value);
- }
- }
-
- /**
- * Parse all command line arguments into a map.
- *
- * Arguments format "key=value" are put into map.
- *
- * @param args
- * @return map of arguments key value pairs.
- */
- protected static Map parseArguments(String[] args) {
- final Map map = new HashMap();
- for (int i = 0; i < args.length; i++) {
- final int d = args[i].indexOf("=");
- if (d > 0 && d < args[i].length() && args[i].startsWith("--")) {
- final String name = args[i].substring(2, d);
- final String value = args[i].substring(d + 1);
- map.put(name, value);
- }
- }
- return map;
- }
+ private final static String serverPort = "8888";
+
+ /**
+ * Main function for running Jetty.
+ *
+ * Command line Arguments are passed through to Jetty, see runServer method
+ * for options.
+ *
+ * @param args
+ */
+ public static void main(String[] args) {
+
+ // Pass-through of arguments for Jetty
+ final Map serverArgs = parseArguments(args);
+
+ // Start Jetty
+ System.out.println("Starting Jetty servlet container.");
+ final String url = runServer(serverArgs, "Web Mode");
+
+ // Start Browser
+ System.out.println("Starting Web Browser.");
+ if (url != null) {
+ BrowserLauncher.openBrowser(url);
+ }
+
+ }
+
+ /**
+ * Run the server with specified arguments.
+ *
+ * @param serverArgs
+ * @return
+ */
+ protected static String runServer(Map serverArgs, String mode) {
+
+ // Add help for System.out
+ System.out
+ .println("-------------------------------------------------\n"
+ + "Starting IT Mill Toolkit in "
+ + mode
+ + ".\n"
+ + "Running in http://localhost:"
+ + serverPort
+ + "\n-------------------------------------------------\n");
+
+ // Assign default values for some arguments
+ assignDefault(serverArgs, "webroot", "WebContent");
+ assignDefault(serverArgs, "httpPort", serverPort);
+
+ try {
+ final Server server = new Server();
+
+ final Connector connector = new SelectChannelConnector();
+
+ connector.setPort(8888);
+ server.setConnectors(new Connector[] { connector });
+
+ final WebAppContext webappcontext = new WebAppContext();
+ webappcontext.setContextPath("");
+ webappcontext.setWar(serverArgs.get("webroot").toString());
+
+ server.setHandler(webappcontext);
+
+ server.start();
+ } catch (final Exception e) {
+ e.printStackTrace();
+ return null;
+ }
+
+ return "http://localhost:" + serverArgs.get("httpPort");
+ }
+
+ /**
+ * Assign default value for given key.
+ *
+ * @param map
+ * @param key
+ * @param value
+ */
+ private static void assignDefault(Map map, String key, String value) {
+ if (!map.containsKey(key)) {
+ map.put(key, value);
+ }
+ }
+
+ /**
+ * Parse all command line arguments into a map.
+ *
+ * Arguments format "key=value" are put into map.
+ *
+ * @param args
+ * @return map of arguments key value pairs.
+ */
+ protected static Map parseArguments(String[] args) {
+ final Map map = new HashMap();
+ for (int i = 0; i < args.length; i++) {
+ final int d = args[i].indexOf("=");
+ if (d > 0 && d < args[i].length() && args[i].startsWith("--")) {
+ final String name = args[i].substring(2, d);
+ final String value = args[i].substring(d + 1);
+ map.put(name, value);
+ }
+ }
+ return map;
+ }
}