diff options
author | Kjetil Ørbekk <kjetil.orbekk@gmail.com> | 2012-02-03 17:16:55 +0100 |
---|---|---|
committer | Kjetil Ørbekk <kjetil.orbekk@gmail.com> | 2012-02-03 17:16:55 +0100 |
commit | 7a6765d14402c8f7010b02f44021f9020af06497 (patch) | |
tree | fb186eb5b4ff53cd123b36a7c1e2fc3363ebefb6 /same/src/main/java/com | |
parent | ea144844b965ea0aaa0f79ea1615491e70a515f9 (diff) |
Use Configuration in client as well.
Diffstat (limited to 'same/src/main/java/com')
-rw-r--r-- | same/src/main/java/com/orbekk/same/ClientApp.java | 21 | ||||
-rw-r--r-- | same/src/main/java/com/orbekk/same/config/Configuration.java | 6 |
2 files changed, 12 insertions, 15 deletions
diff --git a/same/src/main/java/com/orbekk/same/ClientApp.java b/same/src/main/java/com/orbekk/same/ClientApp.java index c9ab52e..3e08567 100644 --- a/same/src/main/java/com/orbekk/same/ClientApp.java +++ b/same/src/main/java/com/orbekk/same/ClientApp.java @@ -6,16 +6,16 @@ import org.slf4j.LoggerFactory; import com.googlecode.jsonrpc4j.JsonRpcServer; import com.orbekk.net.HttpUtil; +import com.orbekk.same.config.Configuration; import com.orbekk.same.http.RpcHandler; public class ClientApp { private Logger logger = LoggerFactory.getLogger(getClass()); - private Server server; - private static final int timeout = 1000; - public void run(int port, String networkName, - String masterUrl) { - SameController controller = SameController.create(null); + public void run(Configuration configuration) { + String networkName = configuration.get("networkName"); + String masterUrl = configuration.get("masterUrl"); + SameController controller = SameController.create(configuration); try { controller.start(); } catch (Exception e) { @@ -26,14 +26,7 @@ public class ClientApp { } public static void main(String[] args) { - if (args.length < 3) { - System.err.println("Usage: port networkName masterUrl"); - System.exit(1); - } - int port = Integer.parseInt(args[0]); - String networkName = args[1]; - String masterUrl = args[2]; - (new ClientApp()).run(port, networkName, masterUrl); - + Configuration configuration = Configuration.loadOrDie(); + (new ClientApp()).run(configuration); } } diff --git a/same/src/main/java/com/orbekk/same/config/Configuration.java b/same/src/main/java/com/orbekk/same/config/Configuration.java index 43b77e5..1c9ffb6 100644 --- a/same/src/main/java/com/orbekk/same/config/Configuration.java +++ b/same/src/main/java/com/orbekk/same/config/Configuration.java @@ -59,7 +59,11 @@ public class Configuration { } public String get(String name) { - return configuration.getProperty(name); + String value = configuration.getProperty(name); + if (value == null) { + logger.error("Property {} = null", name); + } + return value; } public int getInt(String name) { |