aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/org/traccar/handler/events
diff options
context:
space:
mode:
authorAnton Tananaev <anton@traccar.org>2022-05-30 13:12:37 -0700
committerAnton Tananaev <anton@traccar.org>2022-05-30 13:12:37 -0700
commitce661ec77a957b70c15509c6801e6f34b32ad11d (patch)
tree1fd501abc09e1eeceb3bf411b5d2612b27cc35ad /src/main/java/org/traccar/handler/events
parent154ff3b2175e67b3fac531cb9c5c5c68880f5e12 (diff)
downloadtrackermap-server-ce661ec77a957b70c15509c6801e6f34b32ad11d.tar.gz
trackermap-server-ce661ec77a957b70c15509c6801e6f34b32ad11d.tar.bz2
trackermap-server-ce661ec77a957b70c15509c6801e6f34b32ad11d.zip
Improve dependency injection
Diffstat (limited to 'src/main/java/org/traccar/handler/events')
-rw-r--r--src/main/java/org/traccar/handler/events/AlertEventHandler.java5
-rw-r--r--src/main/java/org/traccar/handler/events/BehaviorEventHandler.java4
-rw-r--r--src/main/java/org/traccar/handler/events/CommandResultEventHandler.java8
-rw-r--r--src/main/java/org/traccar/handler/events/DriverEventHandler.java5
-rw-r--r--src/main/java/org/traccar/handler/events/FuelDropEventHandler.java4
-rw-r--r--src/main/java/org/traccar/handler/events/GeofenceEventHandler.java5
-rw-r--r--src/main/java/org/traccar/handler/events/IgnitionEventHandler.java5
-rw-r--r--src/main/java/org/traccar/handler/events/MaintenanceEventHandler.java5
-rw-r--r--src/main/java/org/traccar/handler/events/MotionEventHandler.java5
-rw-r--r--src/main/java/org/traccar/handler/events/OverspeedEventHandler.java5
10 files changed, 41 insertions, 10 deletions
diff --git a/src/main/java/org/traccar/handler/events/AlertEventHandler.java b/src/main/java/org/traccar/handler/events/AlertEventHandler.java
index 05dbc516e..6e7b0b16e 100644
--- a/src/main/java/org/traccar/handler/events/AlertEventHandler.java
+++ b/src/main/java/org/traccar/handler/events/AlertEventHandler.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2016 - 2019 Anton Tananaev (anton@traccar.org)
+ * Copyright 2016 - 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.
@@ -25,12 +25,15 @@ import org.traccar.database.IdentityManager;
import org.traccar.model.Event;
import org.traccar.model.Position;
+import javax.inject.Inject;
+
@ChannelHandler.Sharable
public class AlertEventHandler extends BaseEventHandler {
private final IdentityManager identityManager;
private final boolean ignoreDuplicateAlerts;
+ @Inject
public AlertEventHandler(Config config, IdentityManager identityManager) {
this.identityManager = identityManager;
ignoreDuplicateAlerts = config.getBoolean(Keys.EVENT_IGNORE_DUPLICATE_ALERTS);
diff --git a/src/main/java/org/traccar/handler/events/BehaviorEventHandler.java b/src/main/java/org/traccar/handler/events/BehaviorEventHandler.java
index 767cef3f6..bbf749cdc 100644
--- a/src/main/java/org/traccar/handler/events/BehaviorEventHandler.java
+++ b/src/main/java/org/traccar/handler/events/BehaviorEventHandler.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2021 Anton Tananaev (anton@traccar.org)
+ * Copyright 2021 - 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.
@@ -23,6 +23,7 @@ import org.traccar.helper.UnitsConverter;
import org.traccar.model.Event;
import org.traccar.model.Position;
+import javax.inject.Inject;
import java.util.Collections;
import java.util.Map;
@@ -34,6 +35,7 @@ public class BehaviorEventHandler extends BaseEventHandler {
private final IdentityManager identityManager;
+ @Inject
public BehaviorEventHandler(Config config, IdentityManager identityManager) {
accelerationThreshold = config.getDouble(Keys.EVENT_BEHAVIOR_ACCELERATION_THRESHOLD);
brakingThreshold = config.getDouble(Keys.EVENT_BEHAVIOR_BRAKING_THRESHOLD);
diff --git a/src/main/java/org/traccar/handler/events/CommandResultEventHandler.java b/src/main/java/org/traccar/handler/events/CommandResultEventHandler.java
index 9b7ff554e..858f84e09 100644
--- a/src/main/java/org/traccar/handler/events/CommandResultEventHandler.java
+++ b/src/main/java/org/traccar/handler/events/CommandResultEventHandler.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2016 Anton Tananaev (anton@traccar.org)
+ * Copyright 2016 - 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.
@@ -22,9 +22,15 @@ import io.netty.channel.ChannelHandler;
import org.traccar.model.Event;
import org.traccar.model.Position;
+import javax.inject.Inject;
+
@ChannelHandler.Sharable
public class CommandResultEventHandler extends BaseEventHandler {
+ @Inject
+ public CommandResultEventHandler() {
+ }
+
@Override
protected Map<Event, Position> analyzePosition(Position position) {
Object commandResult = position.getAttributes().get(Position.KEY_RESULT);
diff --git a/src/main/java/org/traccar/handler/events/DriverEventHandler.java b/src/main/java/org/traccar/handler/events/DriverEventHandler.java
index 6fdf4246b..510ac3465 100644
--- a/src/main/java/org/traccar/handler/events/DriverEventHandler.java
+++ b/src/main/java/org/traccar/handler/events/DriverEventHandler.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2017 - 2019 Anton Tananaev (anton@traccar.org)
+ * Copyright 2017 - 2022 Anton Tananaev (anton@traccar.org)
* Copyright 2017 Andrey Kunitsyn (andrey@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -24,11 +24,14 @@ import org.traccar.database.IdentityManager;
import org.traccar.model.Event;
import org.traccar.model.Position;
+import javax.inject.Inject;
+
@ChannelHandler.Sharable
public class DriverEventHandler extends BaseEventHandler {
private final IdentityManager identityManager;
+ @Inject
public DriverEventHandler(IdentityManager identityManager) {
this.identityManager = identityManager;
}
diff --git a/src/main/java/org/traccar/handler/events/FuelDropEventHandler.java b/src/main/java/org/traccar/handler/events/FuelDropEventHandler.java
index 343a17311..7849abff9 100644
--- a/src/main/java/org/traccar/handler/events/FuelDropEventHandler.java
+++ b/src/main/java/org/traccar/handler/events/FuelDropEventHandler.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2017 - 2019 Anton Tananaev (anton@traccar.org)
+ * Copyright 2017 - 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.
@@ -21,6 +21,7 @@ import org.traccar.model.Device;
import org.traccar.model.Event;
import org.traccar.model.Position;
+import javax.inject.Inject;
import java.util.Collections;
import java.util.Map;
@@ -31,6 +32,7 @@ public class FuelDropEventHandler extends BaseEventHandler {
private final IdentityManager identityManager;
+ @Inject
public FuelDropEventHandler(IdentityManager identityManager) {
this.identityManager = identityManager;
}
diff --git a/src/main/java/org/traccar/handler/events/GeofenceEventHandler.java b/src/main/java/org/traccar/handler/events/GeofenceEventHandler.java
index dae0c891f..36df7aaf3 100644
--- a/src/main/java/org/traccar/handler/events/GeofenceEventHandler.java
+++ b/src/main/java/org/traccar/handler/events/GeofenceEventHandler.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2016 - 2021 Anton Tananaev (anton@traccar.org)
+ * Copyright 2016 - 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.
@@ -30,6 +30,8 @@ import org.traccar.model.Device;
import org.traccar.model.Event;
import org.traccar.model.Position;
+import javax.inject.Inject;
+
@ChannelHandler.Sharable
public class GeofenceEventHandler extends BaseEventHandler {
@@ -38,6 +40,7 @@ public class GeofenceEventHandler extends BaseEventHandler {
private final CalendarManager calendarManager;
private final ConnectionManager connectionManager;
+ @Inject
public GeofenceEventHandler(
IdentityManager identityManager, GeofenceManager geofenceManager, CalendarManager calendarManager,
ConnectionManager connectionManager) {
diff --git a/src/main/java/org/traccar/handler/events/IgnitionEventHandler.java b/src/main/java/org/traccar/handler/events/IgnitionEventHandler.java
index 69df9a46b..9887c9db6 100644
--- a/src/main/java/org/traccar/handler/events/IgnitionEventHandler.java
+++ b/src/main/java/org/traccar/handler/events/IgnitionEventHandler.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2016 - 2019 Anton Tananaev (anton@traccar.org)
+ * Copyright 2016 - 2022 Anton Tananaev (anton@traccar.org)
* Copyright 2016 Andrey Kunitsyn (andrey@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -25,11 +25,14 @@ import org.traccar.model.Device;
import org.traccar.model.Event;
import org.traccar.model.Position;
+import javax.inject.Inject;
+
@ChannelHandler.Sharable
public class IgnitionEventHandler extends BaseEventHandler {
private final IdentityManager identityManager;
+ @Inject
public IgnitionEventHandler(IdentityManager identityManager) {
this.identityManager = identityManager;
}
diff --git a/src/main/java/org/traccar/handler/events/MaintenanceEventHandler.java b/src/main/java/org/traccar/handler/events/MaintenanceEventHandler.java
index 0f960ad1f..5b9ce4316 100644
--- a/src/main/java/org/traccar/handler/events/MaintenanceEventHandler.java
+++ b/src/main/java/org/traccar/handler/events/MaintenanceEventHandler.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2016 - 2018 Anton Tananaev (anton@traccar.org)
+ * Copyright 2016 - 2022 Anton Tananaev (anton@traccar.org)
* Copyright 2016 - 2018 Andrey Kunitsyn (andrey@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -26,12 +26,15 @@ import org.traccar.model.Event;
import org.traccar.model.Maintenance;
import org.traccar.model.Position;
+import javax.inject.Inject;
+
@ChannelHandler.Sharable
public class MaintenanceEventHandler extends BaseEventHandler {
private final IdentityManager identityManager;
private final MaintenancesManager maintenancesManager;
+ @Inject
public MaintenanceEventHandler(IdentityManager identityManager, MaintenancesManager maintenancesManager) {
this.identityManager = identityManager;
this.maintenancesManager = maintenancesManager;
diff --git a/src/main/java/org/traccar/handler/events/MotionEventHandler.java b/src/main/java/org/traccar/handler/events/MotionEventHandler.java
index db276f32b..23a39d070 100644
--- a/src/main/java/org/traccar/handler/events/MotionEventHandler.java
+++ b/src/main/java/org/traccar/handler/events/MotionEventHandler.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2016 - 2019 Anton Tananaev (anton@traccar.org)
+ * Copyright 2016 - 2022 Anton Tananaev (anton@traccar.org)
* Copyright 2017 Andrey Kunitsyn (andrey@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -29,6 +29,8 @@ import org.traccar.model.Position;
import org.traccar.reports.ReportUtils;
import org.traccar.reports.model.TripsConfig;
+import javax.inject.Inject;
+
@ChannelHandler.Sharable
public class MotionEventHandler extends BaseEventHandler {
@@ -36,6 +38,7 @@ public class MotionEventHandler extends BaseEventHandler {
private final DeviceManager deviceManager;
private final TripsConfig tripsConfig;
+ @Inject
public MotionEventHandler(IdentityManager identityManager, DeviceManager deviceManager, TripsConfig tripsConfig) {
this.identityManager = identityManager;
this.deviceManager = deviceManager;
diff --git a/src/main/java/org/traccar/handler/events/OverspeedEventHandler.java b/src/main/java/org/traccar/handler/events/OverspeedEventHandler.java
index 347ad9005..102003c3c 100644
--- a/src/main/java/org/traccar/handler/events/OverspeedEventHandler.java
+++ b/src/main/java/org/traccar/handler/events/OverspeedEventHandler.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2016 - 2020 Anton Tananaev (anton@traccar.org)
+ * Copyright 2016 - 2022 Anton Tananaev (anton@traccar.org)
* Copyright 2018 Andrey Kunitsyn (andrey@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -30,6 +30,8 @@ import org.traccar.model.Event;
import org.traccar.model.Geofence;
import org.traccar.model.Position;
+import javax.inject.Inject;
+
@ChannelHandler.Sharable
public class OverspeedEventHandler extends BaseEventHandler {
@@ -43,6 +45,7 @@ public class OverspeedEventHandler extends BaseEventHandler {
private final long minimalDuration;
private final boolean preferLowest;
+ @Inject
public OverspeedEventHandler(Config config, DeviceManager deviceManager, GeofenceManager geofenceManager) {
this.deviceManager = deviceManager;
this.geofenceManager = geofenceManager;