aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2018-09-30 11:40:45 +1300
committerAnton Tananaev <anton.tananaev@gmail.com>2018-09-30 11:40:45 +1300
commitf8e2c913fd18c40025cc110cd7c4506b6038b123 (patch)
tree73b1f1cb44aa9cf711c8111a84c5dbeadd13a843 /src
parent3179094aacede295938f64e21178bbb6f7fa0867 (diff)
downloadtrackermap-server-f8e2c913fd18c40025cc110cd7c4506b6038b123.tar.gz
trackermap-server-f8e2c913fd18c40025cc110cd7c4506b6038b123.tar.bz2
trackermap-server-f8e2c913fd18c40025cc110cd7c4506b6038b123.zip
Use DefaultServlet instead of ResourceHandler
Diffstat (limited to 'src')
-rw-r--r--src/org/traccar/Context.java2
-rw-r--r--src/org/traccar/database/DataManager.java4
-rw-r--r--src/org/traccar/web/WebServer.java16
3 files changed, 10 insertions, 12 deletions
diff --git a/src/org/traccar/Context.java b/src/org/traccar/Context.java
index 2607fd107..ca2091148 100644
--- a/src/org/traccar/Context.java
+++ b/src/org/traccar/Context.java
@@ -406,7 +406,7 @@ public final class Context {
}
if (config.getBoolean("web.enable")) {
- webServer = new WebServer(config, dataManager.getDataSource());
+ webServer = new WebServer(config);
}
permissionsManager = new PermissionsManager(dataManager, usersManager);
diff --git a/src/org/traccar/database/DataManager.java b/src/org/traccar/database/DataManager.java
index f28041fc3..c3a53f4b6 100644
--- a/src/org/traccar/database/DataManager.java
+++ b/src/org/traccar/database/DataManager.java
@@ -91,10 +91,6 @@ public class DataManager {
initDatabaseSchema();
}
- public DataSource getDataSource() {
- return dataSource;
- }
-
private void initDatabase() throws Exception {
String jndiName = config.getString("database.jndi");
diff --git a/src/org/traccar/web/WebServer.java b/src/org/traccar/web/WebServer.java
index 1f56c4139..82a119255 100644
--- a/src/org/traccar/web/WebServer.java
+++ b/src/org/traccar/web/WebServer.java
@@ -117,18 +117,20 @@ public class WebServer {
}
private void initWebApp() {
- ResourceHandler resourceHandler = new ResourceHandler();
- resourceHandler.setResourceBase(config.getString("web.path"));
+ ServletContextHandler servletHandler = new ServletContextHandler(ServletContextHandler.SESSIONS);
+ ServletHolder servletHolder = new ServletHolder(DefaultServlet.class);
+ servletHolder.setInitParameter("resourceBase", config.getString("web.path"));
if (config.getBoolean("web.debug")) {
- resourceHandler.setWelcomeFiles(new String[] {"release.html", "index.html"});
+ servletHandler.setWelcomeFiles(new String[] {"debug.html", "index.html"});
} else {
String cache = config.getString("web.cacheControl");
if (cache != null && !cache.isEmpty()) {
- resourceHandler.setCacheControl(cache);
+ servletHolder.setInitParameter("cacheControl", cache);
}
- resourceHandler.setWelcomeFiles(new String[] {"release.html", "index.html"});
+ servletHandler.setWelcomeFiles(new String[] {"release.html", "index.html"});
}
- handlers.addHandler(resourceHandler);
+ servletHandler.addServlet(servletHolder, "/*");
+ handlers.addHandler(servletHandler);
}
private void initApi() {
@@ -141,7 +143,7 @@ public class WebServer {
servletHandler.addServlet(new ServletHolder(new AsyncSocketServlet()), "/socket");
if (config.hasKey("media.path")) {
- ServletHolder servletHolder = new ServletHolder("media", DefaultServlet.class);
+ ServletHolder servletHolder = new ServletHolder(DefaultServlet.class);
servletHolder.setInitParameter("resourceBase", config.getString("media.path"));
servletHolder.setInitParameter("dirAllowed", config.getString("media.dirAllowed", "false"));
servletHolder.setInitParameter("pathInfoOnly", "true");