aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2016-11-01 14:46:18 +1300
committerAnton Tananaev <anton.tananaev@gmail.com>2016-11-01 14:46:18 +1300
commit153ea4ae66082ffe5af89b1acd23ea632d1ad65f (patch)
tree1faf2b93d1c81a4d287aa4f1b5c148afe6650192
parent5e5b32f8ed85899a97236906fda13a6937e913c1 (diff)
downloadtrackermap-server-153ea4ae66082ffe5af89b1acd23ea632d1ad65f.tar.gz
trackermap-server-153ea4ae66082ffe5af89b1acd23ea632d1ad65f.tar.bz2
trackermap-server-153ea4ae66082ffe5af89b1acd23ea632d1ad65f.zip
Simplify resource loading
-rw-r--r--src/org/traccar/web/WebServer.java38
1 files changed, 5 insertions, 33 deletions
diff --git a/src/org/traccar/web/WebServer.java b/src/org/traccar/web/WebServer.java
index ecdac73c0..3970fb6eb 100644
--- a/src/org/traccar/web/WebServer.java
+++ b/src/org/traccar/web/WebServer.java
@@ -34,25 +34,7 @@ import org.traccar.api.CorsResponseFilter;
import org.traccar.api.ObjectMapperProvider;
import org.traccar.api.ResourceErrorHandler;
import org.traccar.api.SecurityRequestFilter;
-import org.traccar.api.resource.AttributeAliasResource;
-import org.traccar.api.resource.CommandResource;
-import org.traccar.api.resource.GroupPermissionResource;
import org.traccar.api.resource.ServerResource;
-import org.traccar.api.resource.SessionResource;
-import org.traccar.api.resource.DevicePermissionResource;
-import org.traccar.api.resource.StatisticsResource;
-import org.traccar.api.resource.UserResource;
-import org.traccar.api.resource.GroupResource;
-import org.traccar.api.resource.NotificationResource;
-import org.traccar.api.resource.DeviceResource;
-import org.traccar.api.resource.PositionResource;
-import org.traccar.api.resource.ReportResource;
-import org.traccar.api.resource.CommandTypeResource;
-import org.traccar.api.resource.DeviceGeofenceResource;
-import org.traccar.api.resource.EventResource;
-import org.traccar.api.resource.GeofencePermissionResource;
-import org.traccar.api.resource.GeofenceResource;
-import org.traccar.api.resource.GroupGeofenceResource;
import org.traccar.helper.Log;
import javax.naming.InitialContext;
@@ -121,9 +103,7 @@ public class WebServer {
resourceHandler.setResourceBase(config.getString("web.path"));
if (config.getBoolean("web.debug")) {
resourceHandler.setWelcomeFiles(new String[] {"debug.html"});
- //Troubleshooting Locked UI Files on Windows while app is running (like html, js, css, etc...),
- //you can make changes to the UI Files and refresh the page in the browser without stopping the app first
- resourceHandler.setMinMemoryMappedContentLength(-1);
+ resourceHandler.setMinMemoryMappedContentLength(-1); // avoid locking files on Windows
} else {
resourceHandler.setWelcomeFiles(new String[] {"release.html", "index.html"});
}
@@ -153,18 +133,10 @@ public class WebServer {
servletHandler.addServlet(new ServletHolder(new AsyncSocketServlet()), "/socket");
ResourceConfig resourceConfig = new ResourceConfig();
- resourceConfig.register(ObjectMapperProvider.class);
- resourceConfig.register(JacksonFeature.class);
- resourceConfig.register(ResourceErrorHandler.class);
- resourceConfig.register(SecurityRequestFilter.class);
- resourceConfig.register(CorsResponseFilter.class);
- resourceConfig.registerClasses(ServerResource.class, SessionResource.class, CommandResource.class,
- GroupPermissionResource.class, DevicePermissionResource.class, UserResource.class,
- GroupResource.class, DeviceResource.class, PositionResource.class,
- CommandTypeResource.class, EventResource.class, GeofenceResource.class,
- DeviceGeofenceResource.class, GeofencePermissionResource.class, GroupGeofenceResource.class,
- NotificationResource.class, ReportResource.class, AttributeAliasResource.class,
- StatisticsResource.class);
+ resourceConfig.registerClasses(JacksonFeature.class, ObjectMapperProvider.class, ResourceErrorHandler.class);
+ resourceConfig.registerClasses(SecurityRequestFilter.class, CorsResponseFilter.class);
+ resourceConfig.packages(ServerResource.class.getPackage().getName());
+
servletHandler.addServlet(new ServletHolder(new ServletContainer(resourceConfig)), "/*");
handlers.addHandler(servletHandler);