From e665a2c7f4dd925bed116961da48bb018d6f57f7 Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Sat, 18 Jun 2022 14:36:31 -0700 Subject: Remove static injector usages --- src/main/java/org/traccar/session/ConnectionManager.java | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'src/main/java/org/traccar/session') diff --git a/src/main/java/org/traccar/session/ConnectionManager.java b/src/main/java/org/traccar/session/ConnectionManager.java index cead771c9..05c4893fd 100644 --- a/src/main/java/org/traccar/session/ConnectionManager.java +++ b/src/main/java/org/traccar/session/ConnectionManager.java @@ -15,12 +15,12 @@ */ package org.traccar.session; +import com.google.inject.Injector; import io.netty.channel.Channel; import io.netty.util.Timeout; import io.netty.util.Timer; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import org.traccar.Main; import org.traccar.Protocol; import org.traccar.config.Config; import org.traccar.config.Keys; @@ -64,6 +64,7 @@ public class ConnectionManager { private final Map deviceStates = new ConcurrentHashMap<>(); + private final Injector injector; private final Config config; private final CacheManager cacheManager; private final Storage storage; @@ -75,8 +76,9 @@ public class ConnectionManager { @Inject public ConnectionManager( - Config config, CacheManager cacheManager, Storage storage, + Injector injector, Config config, CacheManager cacheManager, Storage storage, NotificationManager notificationManager, Timer timer) { + this.injector = injector; this.config = config; this.cacheManager = cacheManager; this.storage = storage; @@ -279,15 +281,13 @@ public class ConnectionManager { DeviceState deviceState = getDeviceState(deviceId); Map result = new HashMap<>(); - Map event = Main.getInjector() - .getInstance(MotionEventHandler.class).updateMotionState(deviceState); + Map event = injector.getInstance(MotionEventHandler.class).updateMotionState(deviceState); if (event != null) { result.putAll(event); } double speedLimit = AttributeUtil.lookup(cacheManager, Keys.EVENT_OVERSPEED_LIMIT, deviceId); - event = Main.getInjector().getInstance(OverspeedEventHandler.class) - .updateOverspeedState(deviceState, speedLimit); + event = injector.getInstance(OverspeedEventHandler.class).updateOverspeedState(deviceState, speedLimit); if (event != null) { result.putAll(event); } -- cgit v1.2.3