aboutsummaryrefslogtreecommitdiff
path: root/src/org/traccar/handler
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2019-03-09 17:04:08 -0800
committerAnton Tananaev <anton.tananaev@gmail.com>2019-03-09 17:04:08 -0800
commit5c084a0b2961dbfc3cd85a386fefe0b0da6c0c44 (patch)
tree637b9f89086bad578bbad04fd52e80bf379b8beb /src/org/traccar/handler
parent2a584c67a1663897d98e7c64fe161c88b30ef314 (diff)
downloadtrackermap-server-5c084a0b2961dbfc3cd85a386fefe0b0da6c0c44.tar.gz
trackermap-server-5c084a0b2961dbfc3cd85a386fefe0b0da6c0c44.tar.bz2
trackermap-server-5c084a0b2961dbfc3cd85a386fefe0b0da6c0c44.zip
Refactor ignition event handler
Diffstat (limited to 'src/org/traccar/handler')
-rw-r--r--src/org/traccar/handler/events/IgnitionEventHandler.java16
1 files changed, 11 insertions, 5 deletions
diff --git a/src/org/traccar/handler/events/IgnitionEventHandler.java b/src/org/traccar/handler/events/IgnitionEventHandler.java
index 7a83f45b7..ec133bafc 100644
--- a/src/org/traccar/handler/events/IgnitionEventHandler.java
+++ b/src/org/traccar/handler/events/IgnitionEventHandler.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2016 Anton Tananaev (anton@traccar.org)
+ * Copyright 2016 - 2019 Anton Tananaev (anton@traccar.org)
* Copyright 2016 Andrey Kunitsyn (andrey@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -20,7 +20,7 @@ import java.util.Collections;
import java.util.Map;
import io.netty.channel.ChannelHandler;
-import org.traccar.Context;
+import org.traccar.database.IdentityManager;
import org.traccar.model.Device;
import org.traccar.model.Event;
import org.traccar.model.Position;
@@ -28,10 +28,16 @@ import org.traccar.model.Position;
@ChannelHandler.Sharable
public class IgnitionEventHandler extends BaseEventHandler {
+ private final IdentityManager identityManager;
+
+ public IgnitionEventHandler(IdentityManager identityManager) {
+ this.identityManager = identityManager;
+ }
+
@Override
protected Map<Event, Position> analyzePosition(Position position) {
- Device device = Context.getIdentityManager().getById(position.getDeviceId());
- if (device == null || !Context.getIdentityManager().isLatestPosition(position)) {
+ Device device = identityManager.getById(position.getDeviceId());
+ if (device == null || !identityManager.isLatestPosition(position)) {
return null;
}
@@ -40,7 +46,7 @@ public class IgnitionEventHandler extends BaseEventHandler {
if (position.getAttributes().containsKey(Position.KEY_IGNITION)) {
boolean ignition = position.getBoolean(Position.KEY_IGNITION);
- Position lastPosition = Context.getIdentityManager().getLastPosition(position.getDeviceId());
+ Position lastPosition = identityManager.getLastPosition(position.getDeviceId());
if (lastPosition != null && lastPosition.getAttributes().containsKey(Position.KEY_IGNITION)) {
boolean oldIgnition = lastPosition.getBoolean(Position.KEY_IGNITION);