aboutsummaryrefslogtreecommitdiff
path: root/src/org/traccar
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2019-02-27 23:02:41 -0800
committerAnton Tananaev <anton.tananaev@gmail.com>2019-02-27 23:02:41 -0800
commit08754125ed5d152efe29926728033da3658c69fc (patch)
tree41a8924575e0e4ad646f3ac44e984e7cb7fccb1d /src/org/traccar
parenta68b4ab19873de65145772b408b4db75da25484a (diff)
downloadtraccar-server-08754125ed5d152efe29926728033da3658c69fc.tar.gz
traccar-server-08754125ed5d152efe29926728033da3658c69fc.tar.bz2
traccar-server-08754125ed5d152efe29926728033da3658c69fc.zip
Move events handler classes
Diffstat (limited to 'src/org/traccar')
-rw-r--r--src/org/traccar/BasePipelineFactory.java51
-rw-r--r--src/org/traccar/Context.java4
-rw-r--r--src/org/traccar/config/Keys.java6
-rw-r--r--src/org/traccar/database/ConnectionManager.java2
-rw-r--r--src/org/traccar/handler/events/AlertEventHandler.java (renamed from src/org/traccar/events/AlertEventHandler.java)2
-rw-r--r--src/org/traccar/handler/events/CommandResultEventHandler.java (renamed from src/org/traccar/events/CommandResultEventHandler.java)2
-rw-r--r--src/org/traccar/handler/events/DriverEventHandler.java (renamed from src/org/traccar/events/DriverEventHandler.java)2
-rw-r--r--src/org/traccar/handler/events/FuelDropEventHandler.java (renamed from src/org/traccar/events/FuelDropEventHandler.java)2
-rw-r--r--src/org/traccar/handler/events/GeofenceEventHandler.java (renamed from src/org/traccar/events/GeofenceEventHandler.java)2
-rw-r--r--src/org/traccar/handler/events/IgnitionEventHandler.java (renamed from src/org/traccar/events/IgnitionEventHandler.java)2
-rw-r--r--src/org/traccar/handler/events/MaintenanceEventHandler.java (renamed from src/org/traccar/events/MaintenanceEventHandler.java)2
-rw-r--r--src/org/traccar/handler/events/MotionEventHandler.java (renamed from src/org/traccar/events/MotionEventHandler.java)2
-rw-r--r--src/org/traccar/handler/events/OverspeedEventHandler.java (renamed from src/org/traccar/events/OverspeedEventHandler.java)2
-rw-r--r--src/org/traccar/handler/events/TextMessageEventHandler.java (renamed from src/org/traccar/events/TextMessageEventHandler.java)2
-rw-r--r--src/org/traccar/reports/ReportUtils.java2
-rw-r--r--src/org/traccar/sms/smpp/ClientSmppSessionHandler.java2
16 files changed, 48 insertions, 39 deletions
diff --git a/src/org/traccar/BasePipelineFactory.java b/src/org/traccar/BasePipelineFactory.java
index 85127fd7a..e9f786792 100644
--- a/src/org/traccar/BasePipelineFactory.java
+++ b/src/org/traccar/BasePipelineFactory.java
@@ -25,15 +25,15 @@ import io.netty.handler.timeout.IdleStateHandler;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.traccar.config.Keys;
-import org.traccar.events.AlertEventHandler;
-import org.traccar.events.CommandResultEventHandler;
-import org.traccar.events.DriverEventHandler;
-import org.traccar.events.FuelDropEventHandler;
-import org.traccar.events.GeofenceEventHandler;
-import org.traccar.events.IgnitionEventHandler;
-import org.traccar.events.MaintenanceEventHandler;
-import org.traccar.events.MotionEventHandler;
-import org.traccar.events.OverspeedEventHandler;
+import org.traccar.handler.events.AlertEventHandler;
+import org.traccar.handler.events.CommandResultEventHandler;
+import org.traccar.handler.events.DriverEventHandler;
+import org.traccar.handler.events.FuelDropEventHandler;
+import org.traccar.handler.events.GeofenceEventHandler;
+import org.traccar.handler.events.IgnitionEventHandler;
+import org.traccar.handler.events.MaintenanceEventHandler;
+import org.traccar.handler.events.MotionEventHandler;
+import org.traccar.handler.events.OverspeedEventHandler;
import org.traccar.handler.ComputedAttributesHandler;
import org.traccar.handler.CopyAttributesHandler;
import org.traccar.handler.DistanceHandler;
@@ -55,6 +55,7 @@ public abstract class BasePipelineFactory extends ChannelInitializer<Channel> {
private static final Logger LOGGER = LoggerFactory.getLogger(BasePipelineFactory.class);
private final TrackerServer server;
+ private boolean eventsEnabled;
private int timeout;
private CommandResultEventHandler commandResultEventHandler;
@@ -69,13 +70,13 @@ public abstract class BasePipelineFactory extends ChannelInitializer<Channel> {
public BasePipelineFactory(TrackerServer server, String protocol) {
this.server = server;
-
+ eventsEnabled = Context.getConfig().getBoolean(Keys.EVENT_ENABLE);
timeout = Context.getConfig().getInteger(Keys.PROTOCOL_TIMEOUT.withPrefix(protocol));
if (timeout == 0) {
timeout = Context.getConfig().getInteger(Keys.SERVER_TIMEOUT);
}
- if (Context.getConfig().getBoolean("event.enable")) {
+ if (eventsEnabled) {
commandResultEventHandler = new CommandResultEventHandler();
overspeedEventHandler = Context.getOverspeedEventHandler();
fuelDropEventHandler = new FuelDropEventHandler();
@@ -151,24 +152,26 @@ public abstract class BasePipelineFactory extends ChannelInitializer<Channel> {
Main.getInjector().getInstance(MotionHandler.class),
Main.getInjector().getInstance(EngineHoursHandler.class),
Main.getInjector().getInstance(CopyAttributesHandler.class),
- Main.getInjector().getInstance(ComputedAttributesHandler.class));
+ Main.getInjector().getInstance(ComputedAttributesHandler.class),
+ Main.getInjector().getInstance(WebDataHandler.class));
if (Context.getDataManager() != null) {
pipeline.addLast(new DefaultDataHandler());
}
- addHandlers(
- pipeline,
- Main.getInjector().getInstance(WebDataHandler.class),
- commandResultEventHandler,
- overspeedEventHandler,
- fuelDropEventHandler,
- motionEventHandler,
- geofenceEventHandler,
- alertEventHandler,
- ignitionEventHandler,
- maintenanceEventHandler,
- driverEventHandler);
+ if (eventsEnabled) {
+ addHandlers(
+ pipeline,
+ commandResultEventHandler,
+ overspeedEventHandler,
+ fuelDropEventHandler,
+ motionEventHandler,
+ geofenceEventHandler,
+ alertEventHandler,
+ ignitionEventHandler,
+ maintenanceEventHandler,
+ driverEventHandler);
+ }
pipeline.addLast(new MainEventHandler());
}
diff --git a/src/org/traccar/Context.java b/src/org/traccar/Context.java
index 2f8432645..627299c01 100644
--- a/src/org/traccar/Context.java
+++ b/src/org/traccar/Context.java
@@ -41,8 +41,8 @@ import org.traccar.database.MediaManager;
import org.traccar.database.NotificationManager;
import org.traccar.database.PermissionsManager;
import org.traccar.database.UsersManager;
-import org.traccar.events.MotionEventHandler;
-import org.traccar.events.OverspeedEventHandler;
+import org.traccar.handler.events.MotionEventHandler;
+import org.traccar.handler.events.OverspeedEventHandler;
import org.traccar.geocoder.Geocoder;
import org.traccar.helper.Log;
import org.traccar.helper.SanitizerModule;
diff --git a/src/org/traccar/config/Keys.java b/src/org/traccar/config/Keys.java
index ce6ad640d..dc5560daf 100644
--- a/src/org/traccar/config/Keys.java
+++ b/src/org/traccar/config/Keys.java
@@ -40,6 +40,12 @@ public final class Keys {
"server.statistics", Boolean.class);
/**
+ * Enable events subsystem. Flag to enable all events handlers.
+ */
+ public static final ConfigKey EVENT_ENABLE = new ConfigKey(
+ "event.enable", Boolean.class);
+
+ /**
* List of external handler classes to use in Netty pipeline.
*/
public static final ConfigKey EXTRA_HANDLERS = new ConfigKey(
diff --git a/src/org/traccar/database/ConnectionManager.java b/src/org/traccar/database/ConnectionManager.java
index 3d37af710..fc52fc375 100644
--- a/src/org/traccar/database/ConnectionManager.java
+++ b/src/org/traccar/database/ConnectionManager.java
@@ -23,7 +23,7 @@ import org.slf4j.LoggerFactory;
import org.traccar.Context;
import org.traccar.GlobalTimer;
import org.traccar.Protocol;
-import org.traccar.events.OverspeedEventHandler;
+import org.traccar.handler.events.OverspeedEventHandler;
import org.traccar.model.Device;
import org.traccar.model.DeviceState;
import org.traccar.model.Event;
diff --git a/src/org/traccar/events/AlertEventHandler.java b/src/org/traccar/handler/events/AlertEventHandler.java
index b14869e72..c6d61538b 100644
--- a/src/org/traccar/events/AlertEventHandler.java
+++ b/src/org/traccar/handler/events/AlertEventHandler.java
@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.traccar.events;
+package org.traccar.handler.events;
import java.util.Collections;
import java.util.Map;
diff --git a/src/org/traccar/events/CommandResultEventHandler.java b/src/org/traccar/handler/events/CommandResultEventHandler.java
index 89ec44190..3acddc1b9 100644
--- a/src/org/traccar/events/CommandResultEventHandler.java
+++ b/src/org/traccar/handler/events/CommandResultEventHandler.java
@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.traccar.events;
+package org.traccar.handler.events;
import java.util.Collections;
import java.util.Map;
diff --git a/src/org/traccar/events/DriverEventHandler.java b/src/org/traccar/handler/events/DriverEventHandler.java
index c8efd0576..ef73d6d2d 100644
--- a/src/org/traccar/events/DriverEventHandler.java
+++ b/src/org/traccar/handler/events/DriverEventHandler.java
@@ -14,7 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.traccar.events;
+package org.traccar.handler.events;
import java.util.Collections;
import java.util.Map;
diff --git a/src/org/traccar/events/FuelDropEventHandler.java b/src/org/traccar/handler/events/FuelDropEventHandler.java
index 31b17d500..7de3930ca 100644
--- a/src/org/traccar/events/FuelDropEventHandler.java
+++ b/src/org/traccar/handler/events/FuelDropEventHandler.java
@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.traccar.events;
+package org.traccar.handler.events;
import io.netty.channel.ChannelHandler;
import org.traccar.BaseEventHandler;
diff --git a/src/org/traccar/events/GeofenceEventHandler.java b/src/org/traccar/handler/events/GeofenceEventHandler.java
index 313553195..3bddfe7a4 100644
--- a/src/org/traccar/events/GeofenceEventHandler.java
+++ b/src/org/traccar/handler/events/GeofenceEventHandler.java
@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.traccar.events;
+package org.traccar.handler.events;
import java.util.ArrayList;
import java.util.HashMap;
diff --git a/src/org/traccar/events/IgnitionEventHandler.java b/src/org/traccar/handler/events/IgnitionEventHandler.java
index a17f15318..4930ef901 100644
--- a/src/org/traccar/events/IgnitionEventHandler.java
+++ b/src/org/traccar/handler/events/IgnitionEventHandler.java
@@ -14,7 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.traccar.events;
+package org.traccar.handler.events;
import java.util.Collections;
import java.util.Map;
diff --git a/src/org/traccar/events/MaintenanceEventHandler.java b/src/org/traccar/handler/events/MaintenanceEventHandler.java
index 5bebb1baf..e7f641431 100644
--- a/src/org/traccar/events/MaintenanceEventHandler.java
+++ b/src/org/traccar/handler/events/MaintenanceEventHandler.java
@@ -14,7 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.traccar.events;
+package org.traccar.handler.events;
import java.util.HashMap;
import java.util.Map;
diff --git a/src/org/traccar/events/MotionEventHandler.java b/src/org/traccar/handler/events/MotionEventHandler.java
index 4047b83a4..c03b394e5 100644
--- a/src/org/traccar/events/MotionEventHandler.java
+++ b/src/org/traccar/handler/events/MotionEventHandler.java
@@ -14,7 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.traccar.events;
+package org.traccar.handler.events;
import java.util.Collections;
import java.util.Map;
diff --git a/src/org/traccar/events/OverspeedEventHandler.java b/src/org/traccar/handler/events/OverspeedEventHandler.java
index 4f9a35793..567758de5 100644
--- a/src/org/traccar/events/OverspeedEventHandler.java
+++ b/src/org/traccar/handler/events/OverspeedEventHandler.java
@@ -14,7 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.traccar.events;
+package org.traccar.handler.events;
import java.util.Collections;
import java.util.Map;
diff --git a/src/org/traccar/events/TextMessageEventHandler.java b/src/org/traccar/handler/events/TextMessageEventHandler.java
index be4a193a7..b5e2c72b0 100644
--- a/src/org/traccar/events/TextMessageEventHandler.java
+++ b/src/org/traccar/handler/events/TextMessageEventHandler.java
@@ -14,7 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.traccar.events;
+package org.traccar.handler.events;
import org.traccar.Context;
import org.traccar.model.Device;
diff --git a/src/org/traccar/reports/ReportUtils.java b/src/org/traccar/reports/ReportUtils.java
index ea383d598..5e02afb64 100644
--- a/src/org/traccar/reports/ReportUtils.java
+++ b/src/org/traccar/reports/ReportUtils.java
@@ -26,7 +26,7 @@ import org.jxls.transform.Transformer;
import org.jxls.transform.poi.PoiTransformer;
import org.jxls.util.TransformerFactory;
import org.traccar.Context;
-import org.traccar.events.MotionEventHandler;
+import org.traccar.handler.events.MotionEventHandler;
import org.traccar.model.DeviceState;
import org.traccar.model.Driver;
import org.traccar.model.Event;
diff --git a/src/org/traccar/sms/smpp/ClientSmppSessionHandler.java b/src/org/traccar/sms/smpp/ClientSmppSessionHandler.java
index f48721ff9..4fdbbd212 100644
--- a/src/org/traccar/sms/smpp/ClientSmppSessionHandler.java
+++ b/src/org/traccar/sms/smpp/ClientSmppSessionHandler.java
@@ -18,7 +18,7 @@ package org.traccar.sms.smpp;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import org.traccar.events.TextMessageEventHandler;
+import org.traccar.handler.events.TextMessageEventHandler;
import com.cloudhopper.commons.charset.CharsetUtil;
import com.cloudhopper.smpp.SmppConstants;