freemarkerdor/src/main/java/cz/xelfi/quoridor/freemarkerdor/UI.java
changeset 72 5f081edc8502
parent 70 3c9966fc0352
child 73 b3165f3a9ad7
     1.1 --- a/freemarkerdor/src/main/java/cz/xelfi/quoridor/freemarkerdor/UI.java	Mon Sep 07 22:27:39 2009 +0200
     1.2 +++ b/freemarkerdor/src/main/java/cz/xelfi/quoridor/freemarkerdor/UI.java	Tue Sep 08 07:54:12 2009 +0200
     1.3 @@ -215,30 +215,32 @@
     1.4      }
     1.5  
     1.6      static Callable<Void> startServers(int port) throws Exception {
     1.7 -        final HttpServer api = Quoridor.start(port + 1);
     1.8 +        File home = new File(System.getProperty("user.home"));
     1.9 +        File quoridor = new File(home, ".quoridor");
    1.10 +
    1.11 +        System.setProperty("quoridor.dir", quoridor.getPath());
    1.12 +
    1.13 +        ResourceConfig rc = new PackagesResourceConfig(
    1.14 +            "cz.xelfi.quoridor.webidor",
    1.15 +            "cz.xelfi.quoridor.freemarkerdor"
    1.16 +        );
    1.17 +
    1.18          Client client = new Client();
    1.19 -        base = client.resource(new URI("http://localhost:" + (port + 1) + "/api/"));
    1.20 +        base = client.resource(new URI("http://localhost:" + port + "/api/"));
    1.21  
    1.22 -        final HttpServer s = start(port);
    1.23 +        final String baseUri = "http://localhost:" + port + "/";
    1.24 +        final HttpServer server = HttpServerFactory.create(baseUri, rc);
    1.25 +        server.start();
    1.26          System.out.println("Quoridor started at port " + port);
    1.27  
    1.28          return new Callable<Void>() {
    1.29              public Void call() throws Exception {
    1.30 -                s.stop(0);
    1.31 -                api.stop(0);
    1.32 +                server.stop(0);
    1.33                  return null;
    1.34              }
    1.35          };
    1.36      }
    1.37  
    1.38 -    static HttpServer start(int port) throws IOException {
    1.39 -        final String baseUri = "http://localhost:" + port + "/";
    1.40 -        ResourceConfig rc = new PackagesResourceConfig("cz.xelfi.quoridor.freemarkerdor");
    1.41 -        HttpServer server = HttpServerFactory.create(baseUri, rc);
    1.42 -        server.start();
    1.43 -        return server;
    1.44 -    }
    1.45 -
    1.46      private Viewable viewable(String page, Document doc, Object... more) {
    1.47          String bundle = page.split("\\.")[0];
    1.48