1.1 --- a/freemarkerdor/src/main/java/cz/xelfi/quoridor/freemarkerdor/UI.java Thu Mar 04 19:37:58 2010 +0100
1.2 +++ b/freemarkerdor/src/main/java/cz/xelfi/quoridor/freemarkerdor/UI.java Tue Mar 09 19:33:46 2010 +0100
1.3 @@ -41,6 +41,8 @@
1.4 import java.io.StringWriter;
1.5 import java.net.URI;
1.6 import java.text.MessageFormat;
1.7 +import java.util.ArrayList;
1.8 +import java.util.Arrays;
1.9 import java.util.Date;
1.10 import java.util.HashMap;
1.11 import java.util.List;
1.12 @@ -474,19 +476,28 @@
1.13 // start the server
1.14 //
1.15
1.16 - public static void main(String[] args) throws Exception {
1.17 + public static void main(String[] params) throws Exception {
1.18 + List<String> args = new ArrayList<String>(Arrays.asList(params));
1.19 +
1.20 + String publicURL = null;
1.21 + if (args.size() >= 2 && args.get(0).equals("--url")) {
1.22 + publicURL = args.get(1);
1.23 + args.remove(0);
1.24 + args.remove(0);
1.25 + }
1.26 +
1.27 int port = 9333;
1.28 - if (args.length > 1) {
1.29 - port = Integer.parseInt(args[0]);
1.30 + if (args.size() > 1) {
1.31 + port = Integer.parseInt(args.get(0));
1.32 }
1.33 - String remoteAPI = args.length >= 2 ? args[1] : null;
1.34 - String remoteStatistics = args.length >= 3 ? args[2] : null;
1.35 + String remoteAPI = args.size() >= 2 ? args.get(1) : null;
1.36 + String remoteStatistics = args.size() >= 3 ? args.get(2) : null;
1.37
1.38 Locale.setDefault(Locale.ROOT);
1.39
1.40 - Callable<Void> r = startServers(port, remoteAPI, remoteStatistics);
1.41 + Callable<Void> r = startServers(port, remoteAPI, remoteStatistics, publicURL);
1.42
1.43 - if (args.length < 3 || !args[args.length - 1].equals("--kill")) {
1.44 + if (args.size() < 3 || !args.get(args.size() - 1).equals("--kill")) {
1.45 System.out.println("Hit enter to stop it...");
1.46 System.in.read();
1.47 } else {
1.48 @@ -498,7 +509,7 @@
1.49 System.exit(0);
1.50 }
1.51
1.52 - static Callable<Void> startServers(int port, String remoteAPI, String remoteStatistics) throws Exception {
1.53 + static Callable<Void> startServers(int port, String remoteAPI, String remoteStatistics, String publicURL) throws Exception {
1.54 Client client = new Client();
1.55 Client client1 = new Client();
1.56
1.57 @@ -521,9 +532,12 @@
1.58 );
1.59
1.60 final String baseUri = "http://localhost:" + port + "/";
1.61 + if (publicURL == null) {
1.62 + publicURL = baseUri;
1.63 + }
1.64 final HttpServer server = HttpServerFactory.create(baseUri, rc);
1.65 Client c3 = new Client();
1.66 - web = c3.resource(baseUri);
1.67 + web = c3.resource(publicURL);
1.68 server.start();
1.69 System.out.println("Quoridor started at port " + port);
1.70