Created
December 15, 2016 13:38
-
-
Save Muzietto/3c723f5de34b2e6e604b110b6de43297 to your computer and use it in GitHub Desktop.
Launching a standalone Jetty to run whatever...
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.wcg.product.ajax.ajaxserver.connectors; | |
import java.net.URL; | |
import org.apache.commons.lang.StringUtils; | |
import org.eclipse.jetty.server.Server; | |
import org.eclipse.jetty.xml.XmlConfiguration; | |
public class StandaloneServer { | |
private static Server server; | |
public static void main(String[] arguments) { | |
if (arguments == null || arguments.length == 0 | |
|| StringUtils.isEmpty(arguments[0])) { | |
throw new IllegalArgumentException( | |
"URL for the jetty.xml file must be provided"); | |
} | |
String config = arguments[0].trim(); | |
server = new Server(); | |
System.out.println(config); | |
XmlConfiguration configuration; | |
try { | |
configuration = new XmlConfiguration(new URL(config)); | |
configuration.configure(server); | |
server.start(); | |
System.out.println("server started------------------------------------------------------"); | |
System.out.println(server.dump()); | |
server.join(); | |
} catch (Exception e) { | |
e.printStackTrace(); | |
} | |
} | |
public static void stop() { | |
try { | |
server.stop(); | |
} catch (Exception e) { | |
e.printStackTrace(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment