From 415ba3ddb0f770b829c997beb3e575ffb6e195ec Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Tue, 14 Jun 2022 17:06:44 -0700 Subject: Inject connection manager --- src/main/java/org/traccar/database/DeviceManager.java | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'src/main/java/org/traccar/database') diff --git a/src/main/java/org/traccar/database/DeviceManager.java b/src/main/java/org/traccar/database/DeviceManager.java index 20f179f2e..973cf3f68 100644 --- a/src/main/java/org/traccar/database/DeviceManager.java +++ b/src/main/java/org/traccar/database/DeviceManager.java @@ -32,6 +32,7 @@ import org.traccar.Context; import org.traccar.config.Keys; import org.traccar.model.Command; import org.traccar.model.Device; +import org.traccar.session.ConnectionManager; import org.traccar.session.DeviceState; import org.traccar.model.DeviceAccumulators; import org.traccar.model.Group; @@ -45,6 +46,7 @@ public class DeviceManager extends BaseObjectManager implements Identity private static final Logger LOGGER = LoggerFactory.getLogger(DeviceManager.class); private final Config config; + private final ConnectionManager connectionManager; private final long dataRefreshDelay; private Map devicesByUniqueId; @@ -54,9 +56,10 @@ public class DeviceManager extends BaseObjectManager implements Identity private final Map deviceStates = new ConcurrentHashMap<>(); - public DeviceManager(DataManager dataManager) { + public DeviceManager(Config config, DataManager dataManager, ConnectionManager connectionManager) { super(dataManager, Device.class); - this.config = Context.getConfig(); + this.config = config; + this.connectionManager = connectionManager; try { writeLock(); if (devicesByUniqueId == null) { @@ -287,9 +290,7 @@ public class DeviceManager extends BaseObjectManager implements Identity positions.put(position.getDeviceId(), position); - if (Context.getConnectionManager() != null) { - Context.getConnectionManager().updatePosition(position); - } + connectionManager.updatePosition(position); } } -- cgit v1.2.3