Re-factor config params

This commit is contained in:
Anton Tananaev 2015-06-05 17:02:22 +12:00
parent 96a8551d16
commit 35ae7fbd26
4 changed files with 34 additions and 34 deletions

View File

@ -4,6 +4,31 @@
<properties>
<!-- SERVER CONFIG -->
<entry key='web.enable'>true</entry>
<!--<entry key='web.address'></entry>-->
<entry key='web.port'>8082</entry>
<entry key='web.application'>../traccar-web/traccar-web.war</entry>
<entry key='web.new'>true</entry>
<entry key='web.path'>web</entry>
<entry key='web.mobile'>webm</entry>
<entry key='geocoder.enable'>false</entry>
<entry key='geocoder.type'>nominatim</entry>
<entry key='geocoder.url'>http://nominatim.openstreetmap.org/reverse</entry>
<!--<entry key='filter.enable'>true</entry>
<entry key='filter.limit'>3600</entry>
<entry key='filter.invalid'>true</entry>
<entry key='filter.zero'>true</entry>
<entry key='filter.duplicate'>true</entry>
<entry key='filter.distance'>50</entry>-->
<entry key='logger.enable'>true</entry>
<entry key='logger.level'>all</entry>
<entry key='logger.file'>target/tracker-server.log</entry>
<!-- DATABASE CONFIG -->
<!--<entry key='database.driverFile'>hsqldb.jar</entry>-->
@ -105,31 +130,6 @@
UPDATE device SET positionId = :id WHERE id = :deviceId;
</entry>
<!-- SERVER CONFIG -->
<entry key='http.enable'>true</entry>
<!--<entry key='http.address'></entry>-->
<entry key='http.port'>8082</entry>
<entry key='http.application'>../traccar-web/traccar-web.war</entry>
<entry key='http.new'>true</entry>
<entry key='http.path'>web</entry>
<entry key='http.mobile'>webm</entry>
<entry key='geocoder.enable'>false</entry>
<entry key='geocoder.type'>nominatim</entry>
<entry key='geocoder.url'>http://nominatim.openstreetmap.org/reverse</entry>
<!--<entry key='filter.enable'>true</entry>
<entry key='filter.limit'>3600</entry>
<entry key='filter.invalid'>true</entry>
<entry key='filter.zero'>true</entry>
<entry key='filter.duplicate'>true</entry>
<entry key='filter.distance'>50</entry>-->
<entry key='logger.enable'>true</entry>
<entry key='logger.level'>all</entry>
<entry key='logger.file'>target/tracker-server.log</entry>
<!-- PROTOCOL CONFIG -->
<entry key='detector.port'>5000</entry>

View File

@ -91,7 +91,7 @@ public class Context {
dataManager = new DataManager(properties);
dataCache = new DataCache(dataManager);
if (Boolean.valueOf(properties.getProperty("http.new"))) {
if (Boolean.valueOf(properties.getProperty("web.new"))) {
permissionsManager = new PermissionsManager();
}
@ -106,7 +106,7 @@ public class Context {
}
}
if (Boolean.valueOf(properties.getProperty("http.enable"))) {
if (Boolean.valueOf(properties.getProperty("web.enable"))) {
webServer = new WebServer();
}

View File

@ -113,7 +113,7 @@ public class DataManager {
dataSource = ds;
}
if (Boolean.valueOf(properties.getProperty("http.new"))) {
if (Boolean.valueOf(properties.getProperty("web.new"))) {
createDatabaseSchema();
}
}

View File

@ -39,15 +39,15 @@ public class WebServer {
public WebServer() {
Properties properties = Context.getProps();
String address = properties.getProperty("http.address");
Integer port = Integer.valueOf(properties.getProperty("http.port", "8082"));
String address = properties.getProperty("web.address");
Integer port = Integer.valueOf(properties.getProperty("web.port", "8082"));
if (address == null) {
server = new Server(port);
} else {
server = new Server(new InetSocketAddress(address, port));
}
if (Boolean.valueOf(properties.getProperty("http.new"))) {
if (Boolean.valueOf(properties.getProperty("web.new"))) {
ServletContextHandler servletHandler = new ServletContextHandler(ServletContextHandler.SESSIONS);
servletHandler.setContextPath("/api");
@ -58,13 +58,13 @@ public class WebServer {
servletHandler.addServlet(new ServletHolder(new MainServlet()), "/*");
ResourceHandler mobileResourceHandler = new ResourceHandler();
mobileResourceHandler.setResourceBase(properties.getProperty("http.mobile"));
mobileResourceHandler.setResourceBase(properties.getProperty("web.mobile"));
mobileResourceHandler.setWelcomeFiles(new String[] {"index.html"});
ContextHandler mobileContext = new ContextHandler("/m");
mobileContext.setHandler(mobileResourceHandler);
ResourceHandler resourceHandler = new ResourceHandler();
resourceHandler.setResourceBase(properties.getProperty("http.path"));
resourceHandler.setResourceBase(properties.getProperty("web.path"));
resourceHandler.setWelcomeFiles(new String[]{"index.html"});
HandlerList handlerList = new HandlerList();
@ -83,7 +83,7 @@ public class WebServer {
WebAppContext webapp = new WebAppContext();
webapp.setContextPath("/");
webapp.setWar(properties.getProperty("http.application"));
webapp.setWar(properties.getProperty("web.application"));
server.setHandler(webapp);
}