aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAbyss777 <abyss@fox5.ru>2016-06-23 16:17:25 +0500
committerAbyss777 <abyss@fox5.ru>2016-06-23 16:17:25 +0500
commitbd2e0fdc6fe222316e9e740aa265b6d132d407b6 (patch)
tree0e146fde0b2a7556c380a4b715cb88e42b97d8cb /src
parenta445733519b4b38b52b03fbb63a55c7270cb9221 (diff)
downloadtrackermap-server-bd2e0fdc6fe222316e9e740aa265b6d132d407b6.tar.gz
trackermap-server-bd2e0fdc6fe222316e9e740aa265b6d132d407b6.tar.bz2
trackermap-server-bd2e0fdc6fe222316e9e740aa265b6d132d407b6.zip
Added possibility to disable event and geofence subsystems
Diffstat (limited to 'src')
-rw-r--r--src/org/traccar/BaseEventHandler.java6
-rw-r--r--src/org/traccar/BasePipelineFactory.java22
-rw-r--r--src/org/traccar/Context.java8
-rw-r--r--src/org/traccar/database/ConnectionManager.java4
-rw-r--r--src/org/traccar/database/NotificationManager.java4
-rw-r--r--src/org/traccar/web/WebServer.java11
6 files changed, 34 insertions, 21 deletions
diff --git a/src/org/traccar/BaseEventHandler.java b/src/org/traccar/BaseEventHandler.java
index 1ae9d2c6d..82e78c6b3 100644
--- a/src/org/traccar/BaseEventHandler.java
+++ b/src/org/traccar/BaseEventHandler.java
@@ -26,10 +26,8 @@ public abstract class BaseEventHandler extends BaseDataHandler {
protected Position handlePosition(Position position) {
Collection<Event> events = analyzePosition(position);
- if (events != null) {
- for (Event event : events) {
- Context.getNotificationManager().updateEvent(event, position);
- }
+ if (events != null && Context.getNotificationManager() != null) {
+ Context.getNotificationManager().updateEvents(events, position);
}
return position;
}
diff --git a/src/org/traccar/BasePipelineFactory.java b/src/org/traccar/BasePipelineFactory.java
index b61d95171..9de9b3a52 100644
--- a/src/org/traccar/BasePipelineFactory.java
+++ b/src/org/traccar/BasePipelineFactory.java
@@ -132,20 +132,22 @@ public abstract class BasePipelineFactory implements ChannelPipelineFactory {
hemisphereHandler = new HemisphereHandler();
}
- commandResultEventHandler = new CommandResultEventHandler();
+ if (Context.getConfig().getBoolean("event.enable")) {
+ commandResultEventHandler = new CommandResultEventHandler();
- if (Context.getConfig().getBoolean("event.overspeedHandler")) {
- overspeedEventHandler = new OverspeedEventHandler();
- }
+ if (Context.getConfig().getBoolean("event.overspeedHandler")) {
+ overspeedEventHandler = new OverspeedEventHandler();
+ }
- if (Context.getConfig().getBoolean("event.motionHandler")) {
- motionEventHandler = new MotionEventHandler();
- }
+ if (Context.getConfig().getBoolean("event.motionHandler")) {
+ motionEventHandler = new MotionEventHandler();
+ }
- if (Context.getConfig().getBoolean("event.geofenceHandler")) {
- geofenceEventHandler = new GeofenceEventHandler();
+ if (Context.getConfig().getBoolean("geofence.enable")
+ && Context.getConfig().getBoolean("event.geofenceHandler")) {
+ geofenceEventHandler = new GeofenceEventHandler();
+ }
}
-
}
protected abstract void addSpecificHandlers(ChannelPipeline pipeline);
diff --git a/src/org/traccar/Context.java b/src/org/traccar/Context.java
index f40db72e5..7d22ac681 100644
--- a/src/org/traccar/Context.java
+++ b/src/org/traccar/Context.java
@@ -193,9 +193,13 @@ public final class Context {
connectionManager = new ConnectionManager(dataManager);
- geofenceManager = new GeofenceManager(dataManager);
+ if (config.getBoolean("geofence.enable")) {
+ geofenceManager = new GeofenceManager(dataManager);
+ }
- notificationManager = new NotificationManager(dataManager);
+ if (config.getBoolean("event.enable")) {
+ notificationManager = new NotificationManager(dataManager);
+ }
serverManager = new ServerManager();
diff --git a/src/org/traccar/database/ConnectionManager.java b/src/org/traccar/database/ConnectionManager.java
index 8a1debdfa..8796673b1 100644
--- a/src/org/traccar/database/ConnectionManager.java
+++ b/src/org/traccar/database/ConnectionManager.java
@@ -94,7 +94,9 @@ public class ConnectionManager {
if (status.equals(Device.STATUS_ONLINE)) {
event.setType(Event.TYPE_DEVICE_ONLINE);
}
- Context.getNotificationManager().updateEvent(event, null);
+ if (Context.getNotificationManager() != null) {
+ Context.getNotificationManager().updateEvent(event, null);
+ }
}
device.setStatus(status);
diff --git a/src/org/traccar/database/NotificationManager.java b/src/org/traccar/database/NotificationManager.java
index 7593367a3..ab6b2230a 100644
--- a/src/org/traccar/database/NotificationManager.java
+++ b/src/org/traccar/database/NotificationManager.java
@@ -41,8 +41,8 @@ public class NotificationManager {
Set<Long> users = Context.getPermissionsManager().getDeviceUsers(event.getDeviceId());
for (Long userId : users) {
- if (event.getGeofenceId() == 0
- || Context.getGeofenceManager().checkGeofence(userId, event.getGeofenceId())) {
+ if (event.getGeofenceId() == 0 || Context.getGeofenceManager() != null
+ && Context.getGeofenceManager().checkGeofence(userId, event.getGeofenceId())) {
Context.getConnectionManager().updateEvent(userId, event, position);
}
}
diff --git a/src/org/traccar/web/WebServer.java b/src/org/traccar/web/WebServer.java
index c06ee5d35..2fa5c1a80 100644
--- a/src/org/traccar/web/WebServer.java
+++ b/src/org/traccar/web/WebServer.java
@@ -29,6 +29,7 @@ import org.glassfish.jersey.jackson.JacksonFeature;
import org.glassfish.jersey.server.ResourceConfig;
import org.glassfish.jersey.servlet.ServletContainer;
import org.traccar.Config;
+import org.traccar.Context;
import org.traccar.api.AsyncSocketServlet;
import org.traccar.api.CorsResponseFilter;
import org.traccar.api.ObjectMapperProvider;
@@ -154,8 +155,14 @@ public class WebServer {
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);
+ CommandTypeResource.class);
+ if (Context.getConfig().getBoolean("event.enable")) {
+ resourceConfig.registerClasses(EventResource.class);
+ }
+ if (Context.getConfig().getBoolean("geofence.enable")) {
+ resourceConfig.registerClasses(GeofenceResource.class, DeviceGeofenceResource.class,
+ GeofencePermissionResource.class, GroupGeofenceResource.class);
+ }
servletHandler.addServlet(new ServletHolder(new ServletContainer(resourceConfig)), "/*");
handlers.addHandler(servletHandler);