1.1 --- a/webidor/src/main/java/cz/xelfi/quoridor/webidor/resources/Quoridor.java Wed Jul 29 17:24:20 2009 +0200
1.2 +++ b/webidor/src/main/java/cz/xelfi/quoridor/webidor/resources/Quoridor.java Tue Aug 11 14:26:49 2009 +0200
1.3 @@ -41,7 +41,7 @@
1.4 *
1.5 * @author Jaroslav Tulach <jtulach@netbeans.org>
1.6 */
1.7 -@Path("/")
1.8 +@Path("/api")
1.9 @Singleton
1.10 public final class Quoridor {
1.11 private final File path;
1.12 @@ -69,28 +69,27 @@
1.13 //
1.14
1.15 public static void main(String[] args) throws IOException {
1.16 + HttpServer s = start(9998);
1.17 + System.out.println(
1.18 + "Quoridor started at port 9998\n" + "Hit enter to stop it..."
1.19 + );
1.20 + System.in.read();
1.21 + s.stop(0);
1.22 + System.exit(0);
1.23 + }
1.24
1.25 - final String baseUri = "http://localhost:9998/";
1.26 - final Map<String, String> initParams = new HashMap<String, String>();
1.27 + public static HttpServer start(int port) throws IOException {
1.28 + final String baseUri = "http://localhost:" + port + "/";
1.29
1.30 File home = new File(System.getProperty("user.home"));
1.31 File quoridor = new File(home, ".quoridor");
1.32
1.33 System.setProperty("quoridor.dir", quoridor.getPath());
1.34
1.35 - initParams.put("com.sun.jersey.config.property.packages",
1.36 - "cz.xelfi.quoridor.webidor.resources");
1.37 -
1.38 - System.out.println("Starting Quoridor...");
1.39 ResourceConfig rc = new PackagesResourceConfig("cz.xelfi.quoridor.webidor");
1.40 - HttpServer threadSelector = HttpServerFactory.create(baseUri, rc);
1.41 - threadSelector.start();
1.42 - System.out.println(String.format(
1.43 - "Quoridor started with WADL available at %sapplication.wadl\n" +
1.44 - "Hit enter to stop it...", baseUri, baseUri));
1.45 - System.in.read();
1.46 - threadSelector.stop(0);
1.47 - System.exit(0);
1.48 + HttpServer server = HttpServerFactory.create(baseUri, rc);
1.49 + server.start();
1.50 + return server;
1.51 }
1.52
1.53 }