diff options
author | Anton Tananaev <anton.tananaev@gmail.com> | 2015-07-12 17:54:00 +1200 |
---|---|---|
committer | Anton Tananaev <anton.tananaev@gmail.com> | 2015-07-12 17:54:00 +1200 |
commit | a2dac324574dde8fe8e57bd46dd7f94d0fb60231 (patch) | |
tree | 061e957cb53e00214a33acb6317be9c0849c50fa /src/org/traccar/http/WebServer.java | |
parent | f1ae2d73584d4ddded6f727c665d97f03ecf9c25 (diff) | |
download | traccar-server-a2dac324574dde8fe8e57bd46dd7f94d0fb60231.tar.gz traccar-server-a2dac324574dde8fe8e57bd46dd7f94d0fb60231.tar.bz2 traccar-server-a2dac324574dde8fe8e57bd46dd7f94d0fb60231.zip |
Re-factor configuration access
Diffstat (limited to 'src/org/traccar/http/WebServer.java')
-rw-r--r-- | src/org/traccar/http/WebServer.java | 23 |
1 files changed, 11 insertions, 12 deletions
diff --git a/src/org/traccar/http/WebServer.java b/src/org/traccar/http/WebServer.java index 21a7ba775..a9238964c 100644 --- a/src/org/traccar/http/WebServer.java +++ b/src/org/traccar/http/WebServer.java @@ -16,7 +16,6 @@ package org.traccar.http; import java.net.InetSocketAddress; -import java.util.Properties; import javax.naming.InitialContext; import org.eclipse.jetty.server.Handler; import org.eclipse.jetty.server.Server; @@ -25,6 +24,7 @@ import org.eclipse.jetty.server.handler.ResourceHandler; import org.eclipse.jetty.servlet.ServletContextHandler; import org.eclipse.jetty.servlet.ServletHolder; import org.eclipse.jetty.webapp.WebAppContext; +import org.traccar.Config; import org.traccar.Context; import org.traccar.helper.Log; @@ -35,18 +35,17 @@ public class WebServer { private Server server; - public WebServer() { - Properties properties = Context.getProps(); - - String address = properties.getProperty("web.address"); - Integer port = Integer.valueOf(properties.getProperty("web.port", "8082")); + public WebServer(Config config) { + + String address = config.getString("web.address"); + int port = config.getInteger("web.port", 8082); if (address == null) { server = new Server(port); } else { server = new Server(new InetSocketAddress(address, port)); } - if (!Boolean.valueOf(properties.getProperty("web.old"))) { + if (!config.getBoolean("web.old")) { ServletContextHandler servletHandler = new ServletContextHandler(ServletContextHandler.SESSIONS); servletHandler.setContextPath("/api"); @@ -65,11 +64,11 @@ public class WebServer { mobileContext.setHandler(mobileResourceHandler);*/ ResourceHandler resourceHandler = new ResourceHandler(); - resourceHandler.setResourceBase(properties.getProperty("web.path")); - if (Boolean.valueOf(properties.getProperty("web.debug"))) { - resourceHandler.setWelcomeFiles(new String[]{"debug.html"}); + resourceHandler.setResourceBase(config.getString("web.path")); + if (config.getBoolean("web.debug")) { + resourceHandler.setWelcomeFiles(new String[] { "debug.html" }); } else { - resourceHandler.setWelcomeFiles(new String[]{"release.html"}); + resourceHandler.setWelcomeFiles(new String[] { "release.html" }); } HandlerList handlerList = new HandlerList(); @@ -88,7 +87,7 @@ public class WebServer { WebAppContext webapp = new WebAppContext(); webapp.setContextPath("/"); - webapp.setWar(properties.getProperty("web.application")); + webapp.setWar(config.getString("web.application")); server.setHandler(webapp); } |