*/
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;
}
}
- // Start the Winstone servlet container
+ // Start the Jetty servlet container
final String url = DevelopmentServerLauncher.runServer(serverArgs,
"Demo Server");
* 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
* \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
+ 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