aboutsummaryrefslogtreecommitdiff
path: root/src/org/traccar/Context.java
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2015-07-12 17:54:00 +1200
committerAnton Tananaev <anton.tananaev@gmail.com>2015-07-12 17:54:00 +1200
commita2dac324574dde8fe8e57bd46dd7f94d0fb60231 (patch)
tree061e957cb53e00214a33acb6317be9c0849c50fa /src/org/traccar/Context.java
parentf1ae2d73584d4ddded6f727c665d97f03ecf9c25 (diff)
downloadtrackermap-server-a2dac324574dde8fe8e57bd46dd7f94d0fb60231.tar.gz
trackermap-server-a2dac324574dde8fe8e57bd46dd7f94d0fb60231.tar.bz2
trackermap-server-a2dac324574dde8fe8e57bd46dd7f94d0fb60231.zip
Re-factor configuration access
Diffstat (limited to 'src/org/traccar/Context.java')
-rw-r--r--src/org/traccar/Context.java47
1 files changed, 17 insertions, 30 deletions
diff --git a/src/org/traccar/Context.java b/src/org/traccar/Context.java
index 6fb812f4f..0b74eacd0 100644
--- a/src/org/traccar/Context.java
+++ b/src/org/traccar/Context.java
@@ -15,8 +15,6 @@
*/
package org.traccar;
-import java.io.FileInputStream;
-import java.util.Properties;
import org.traccar.database.ConnectionManager;
import org.traccar.database.DataManager;
import org.traccar.database.IdentityManager;
@@ -29,24 +27,12 @@ import org.traccar.helper.Log;
import org.traccar.http.WebServer;
public class Context {
-
- private static Properties properties;
-
- public static Properties getProps() {
- return properties;
- }
- /*public static boolean getPropBoolean(String key) {
- return Boolean.valueOf(properties.getProperty(key));
- }
+ private static Config config;
- public static int getPropInt() {
- return Integer.valueOf(null);
+ public static Config getConfig() {
+ return config;
}
-
- public static String getPropString() {
- return null;
- }*/
private static boolean loggerEnabled;
@@ -98,37 +84,38 @@ public class Context {
public static void init(String[] arguments) throws Exception {
- properties = new Properties();
+ config = new Config();
if (arguments.length > 0) {
- properties.loadFromXML(new FileInputStream(arguments[0]));
+ config.load(arguments[0]);
}
- loggerEnabled = Boolean.valueOf(properties.getProperty("logger.enable"));
+ loggerEnabled = config.getBoolean("logger.enable");
if (loggerEnabled) {
- Log.setupLogger(properties);
+ Log.setupLogger(config);
}
- dataManager = new DataManager(properties);
+ dataManager = new DataManager(config);
identityManager = dataManager;
connectionManager = new ConnectionManager();
- if (!Boolean.valueOf(properties.getProperty("web.old"))) {
+ if (!config.getBoolean("web.old")) {
permissionsManager = new PermissionsManager();
}
- if (Boolean.parseBoolean(properties.getProperty("geocoder.enable"))) {
- String type = properties.getProperty("geocoder.type");
+ if (config.getBoolean("geocoder.enable")) {
+ String type = config.getString("geocoder.type");
+ String url = config.getString("geocoder.url");
if (type != null && type.equals("nominatim")) {
- reverseGeocoder = new NominatimReverseGeocoder(properties.getProperty("geocoder.url"));
+ reverseGeocoder = new NominatimReverseGeocoder(url);
} else if (type != null && type.equals("gisgraphy")) {
- reverseGeocoder = new GisgraphyReverseGeocoder(properties.getProperty("geocoder.url"));
+ reverseGeocoder = new GisgraphyReverseGeocoder(url);
} else {
reverseGeocoder = new GoogleReverseGeocoder();
}
}
- if (Boolean.valueOf(properties.getProperty("web.enable"))) {
- webServer = new WebServer();
+ if (config.getBoolean("web.enable")) {
+ webServer = new WebServer(config);
}
serverManager = new ServerManager();
@@ -141,7 +128,7 @@ public class Context {
* Initialize context for unit testing
*/
public static void init(IdentityManager identityManager) {
- properties = new Properties();
+ config = new Config();
connectionManager = new ConnectionManager();
Context.identityManager = identityManager;
}