diff options
author | Anton Tananaev <anton@traccar.org> | 2022-06-11 15:04:51 -0700 |
---|---|---|
committer | Anton Tananaev <anton@traccar.org> | 2022-06-11 15:04:51 -0700 |
commit | 7c08991f12b4958135fdffc26f272677c03630ad (patch) | |
tree | c1111ec78bad1dd8b0e4eb8f0c9194095d154d57 /src/main/java/org/traccar/schedule/ScheduleManager.java | |
parent | 4025a42c42e34bb620f4263de05781a10ddc7a9d (diff) | |
download | trackermap-server-7c08991f12b4958135fdffc26f272677c03630ad.tar.gz trackermap-server-7c08991f12b4958135fdffc26f272677c03630ad.tar.bz2 trackermap-server-7c08991f12b4958135fdffc26f272677c03630ad.zip |
Inject network client
Diffstat (limited to 'src/main/java/org/traccar/schedule/ScheduleManager.java')
-rw-r--r-- | src/main/java/org/traccar/schedule/ScheduleManager.java | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/src/main/java/org/traccar/schedule/ScheduleManager.java b/src/main/java/org/traccar/schedule/ScheduleManager.java index 154de603a..6412a186a 100644 --- a/src/main/java/org/traccar/schedule/ScheduleManager.java +++ b/src/main/java/org/traccar/schedule/ScheduleManager.java @@ -15,24 +15,31 @@ */ package org.traccar.schedule; +import com.google.inject.Injector; import org.traccar.LifecycleObject; +import javax.inject.Inject; import javax.inject.Singleton; +import java.util.List; import java.util.concurrent.Executors; import java.util.concurrent.ScheduledExecutorService; @Singleton public class ScheduleManager implements LifecycleObject { + private final Injector injector; private ScheduledExecutorService executor; + @Inject + public ScheduleManager(Injector injector) { + this.injector = injector; + } + @Override public void start() { executor = Executors.newSingleThreadScheduledExecutor(); - - new TaskDeviceInactivityCheck().schedule(executor); - new TaskWebSocketKeepalive().schedule(executor); - new TaskHealthCheck().schedule(executor); + List.of(TaskDeviceInactivityCheck.class, TaskWebSocketKeepalive.class, TaskHealthCheck.class) + .forEach(task -> injector.getInstance(task).schedule(executor)); } @Override |