aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/org/traccar/web
diff options
context:
space:
mode:
authorAnton Tananaev <anton@traccar.org>2022-06-16 18:19:57 -0700
committerAnton Tananaev <anton@traccar.org>2022-06-16 18:19:57 -0700
commitee9abd94265eb704b5f5dd2262f1a3460bbe2a8f (patch)
treed4362b6cf9b62ba952366a4eb6081fc576987e80 /src/main/java/org/traccar/web
parent0de7889d5548ab16bc8dc31e8734dc48dd51d43d (diff)
downloadtrackermap-server-ee9abd94265eb704b5f5dd2262f1a3460bbe2a8f.tar.gz
trackermap-server-ee9abd94265eb704b5f5dd2262f1a3460bbe2a8f.tar.bz2
trackermap-server-ee9abd94265eb704b5f5dd2262f1a3460bbe2a8f.zip
Refactor config usage
Diffstat (limited to 'src/main/java/org/traccar/web')
-rw-r--r--src/main/java/org/traccar/web/ConsoleServlet.java16
-rw-r--r--src/main/java/org/traccar/web/WebServer.java2
2 files changed, 12 insertions, 6 deletions
diff --git a/src/main/java/org/traccar/web/ConsoleServlet.java b/src/main/java/org/traccar/web/ConsoleServlet.java
index 0f3dcd8fd..902a4f7a9 100644
--- a/src/main/java/org/traccar/web/ConsoleServlet.java
+++ b/src/main/java/org/traccar/web/ConsoleServlet.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2015 - 2020 Anton Tananaev (anton@traccar.org)
+ * Copyright 2015 - 2022 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -19,7 +19,7 @@ import org.h2.server.web.ConnectionInfo;
import org.h2.server.web.WebServlet;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import org.traccar.Context;
+import org.traccar.config.Config;
import org.traccar.config.Keys;
import java.lang.reflect.Field;
@@ -30,6 +30,12 @@ public class ConsoleServlet extends WebServlet {
private static final Logger LOGGER = LoggerFactory.getLogger(ConsoleServlet.class);
+ private final Config config;
+
+ public ConsoleServlet(Config config) {
+ this.config = config;
+ }
+
@Override
public void init() {
super.init();
@@ -40,9 +46,9 @@ public class ConsoleServlet extends WebServlet {
org.h2.server.web.WebServer server = (org.h2.server.web.WebServer) field.get(this);
ConnectionInfo connectionInfo = new ConnectionInfo("Traccar|"
- + Context.getConfig().getString(Keys.DATABASE_DRIVER) + "|"
- + Context.getConfig().getString(Keys.DATABASE_URL) + "|"
- + Context.getConfig().getString(Keys.DATABASE_USER));
+ + config.getString(Keys.DATABASE_DRIVER) + "|"
+ + config.getString(Keys.DATABASE_URL) + "|"
+ + config.getString(Keys.DATABASE_USER));
Method method;
diff --git a/src/main/java/org/traccar/web/WebServer.java b/src/main/java/org/traccar/web/WebServer.java
index d7276d21f..6c8a798b4 100644
--- a/src/main/java/org/traccar/web/WebServer.java
+++ b/src/main/java/org/traccar/web/WebServer.java
@@ -91,7 +91,7 @@ public class WebServer implements LifecycleObject {
initSessionConfig(servletHandler);
if (config.getBoolean(Keys.WEB_CONSOLE)) {
- servletHandler.addServlet(new ServletHolder(new ConsoleServlet()), "/console/*");
+ servletHandler.addServlet(new ServletHolder(new ConsoleServlet(config)), "/console/*");
}
initWebApp(servletHandler);