diff options
author | Anton Tananaev <anton@traccar.org> | 2022-05-30 13:12:37 -0700 |
---|---|---|
committer | Anton Tananaev <anton@traccar.org> | 2022-05-30 13:12:37 -0700 |
commit | ce661ec77a957b70c15509c6801e6f34b32ad11d (patch) | |
tree | 1fd501abc09e1eeceb3bf411b5d2612b27cc35ad /src/main/java/org/traccar/database | |
parent | 154ff3b2175e67b3fac531cb9c5c5c68880f5e12 (diff) | |
download | trackermap-server-ce661ec77a957b70c15509c6801e6f34b32ad11d.tar.gz trackermap-server-ce661ec77a957b70c15509c6801e6f34b32ad11d.tar.bz2 trackermap-server-ce661ec77a957b70c15509c6801e6f34b32ad11d.zip |
Improve dependency injection
Diffstat (limited to 'src/main/java/org/traccar/database')
-rw-r--r-- | src/main/java/org/traccar/database/ConnectionManager.java | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/src/main/java/org/traccar/database/ConnectionManager.java b/src/main/java/org/traccar/database/ConnectionManager.java index 359061f00..f0e40f631 100644 --- a/src/main/java/org/traccar/database/ConnectionManager.java +++ b/src/main/java/org/traccar/database/ConnectionManager.java @@ -1,5 +1,5 @@ /* - * Copyright 2015 - 2020 Anton Tananaev (anton@traccar.org) + * Copyright 2015 - 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. @@ -17,10 +17,10 @@ package org.traccar.database; 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.Context; -import org.traccar.GlobalTimer; import org.traccar.Main; import org.traccar.Protocol; import org.traccar.config.Keys; @@ -52,9 +52,12 @@ public class ConnectionManager { private final Map<Long, Set<UpdateListener>> listeners = new ConcurrentHashMap<>(); private final Map<Long, Timeout> timeouts = new ConcurrentHashMap<>(); + private final Timer timer; + public ConnectionManager() { deviceTimeout = Context.getConfig().getLong(Keys.STATUS_TIMEOUT) * 1000; updateDeviceState = Context.getConfig().getBoolean(Keys.STATUS_UPDATE_DEVICE_STATE); + timer = Main.getInjector().getInstance(Timer.class); } public void addActiveDevice(long deviceId, Protocol protocol, Channel channel, SocketAddress remoteAddress) { @@ -118,7 +121,7 @@ public class ConnectionManager { } if (status.equals(Device.STATUS_ONLINE)) { - timeouts.put(deviceId, GlobalTimer.getTimer().newTimeout(timeout1 -> { + timeouts.put(deviceId, timer.newTimeout(timeout1 -> { if (!timeout1.isCancelled()) { updateDevice(deviceId, Device.STATUS_UNKNOWN, null); } |