diff options
author | Anton Tananaev <anton.tananaev@gmail.com> | 2019-02-24 18:06:39 -0800 |
---|---|---|
committer | Anton Tananaev <anton.tananaev@gmail.com> | 2019-02-24 18:06:39 -0800 |
commit | 041c2b897c28dc316e8613c9ea38dee48dd64482 (patch) | |
tree | 2aeee13384c6927dfb734e84fce6dced8fa62c5f /src/org | |
parent | d610b1ab5135503d1d39aa291190a860ddb952a9 (diff) | |
download | trackermap-server-041c2b897c28dc316e8613c9ea38dee48dd64482.tar.gz trackermap-server-041c2b897c28dc316e8613c9ea38dee48dd64482.tar.bz2 trackermap-server-041c2b897c28dc316e8613c9ea38dee48dd64482.zip |
Refactor motion handler
Diffstat (limited to 'src/org')
-rw-r--r-- | src/org/traccar/BasePipelineFactory.java | 6 | ||||
-rw-r--r-- | src/org/traccar/MainModule.java | 13 | ||||
-rw-r--r-- | src/org/traccar/handler/MotionHandler.java (renamed from src/org/traccar/MotionHandler.java) | 5 |
3 files changed, 18 insertions, 6 deletions
diff --git a/src/org/traccar/BasePipelineFactory.java b/src/org/traccar/BasePipelineFactory.java index 8e6a62391..cb60b20a7 100644 --- a/src/org/traccar/BasePipelineFactory.java +++ b/src/org/traccar/BasePipelineFactory.java @@ -41,6 +41,7 @@ import org.traccar.handler.FilterHandler; import org.traccar.handler.GeocoderHandler; import org.traccar.handler.GeolocationHandler; import org.traccar.handler.HemisphereHandler; +import org.traccar.handler.MotionHandler; import org.traccar.handler.NetworkMessageHandler; import org.traccar.handler.OpenChannelHandler; import org.traccar.handler.RemoteAddressHandler; @@ -56,7 +57,6 @@ public abstract class BasePipelineFactory extends ChannelInitializer<Channel> { private int timeout; private EngineHoursHandler engineHoursHandler; - private MotionHandler motionHandler; private CopyAttributesHandler copyAttributesHandler; private ComputedAttributesHandler computedAttributesHandler; @@ -78,8 +78,6 @@ public abstract class BasePipelineFactory extends ChannelInitializer<Channel> { timeout = Context.getConfig().getInteger(Keys.SERVER_TIMEOUT); } - motionHandler = new MotionHandler(Context.getTripsConfig().getSpeedThreshold()); - if (Context.getConfig().getBoolean("processing.engineHours.enable")) { engineHoursHandler = new EngineHoursHandler(); } @@ -165,7 +163,7 @@ public abstract class BasePipelineFactory extends ChannelInitializer<Channel> { pipeline, Main.getInjector().getInstance(FilterHandler.class), Main.getInjector().getInstance(GeocoderHandler.class), - motionHandler, + Main.getInjector().getInstance(MotionHandler.class), engineHoursHandler, copyAttributesHandler, computedAttributesHandler); diff --git a/src/org/traccar/MainModule.java b/src/org/traccar/MainModule.java index c6ca65088..0c3c5be51 100644 --- a/src/org/traccar/MainModule.java +++ b/src/org/traccar/MainModule.java @@ -47,7 +47,9 @@ import org.traccar.handler.DistanceHandler; import org.traccar.handler.FilterHandler; import org.traccar.handler.GeolocationHandler; import org.traccar.handler.HemisphereHandler; +import org.traccar.handler.MotionHandler; import org.traccar.handler.RemoteAddressHandler; +import org.traccar.reports.model.TripsConfig; import javax.annotation.Nullable; import javax.ws.rs.client.Client; @@ -79,6 +81,11 @@ public class MainModule extends AbstractModule { return Context.getClient(); } + @Provides + public static TripsConfig provideTripsConfig() { + return Context.getTripsConfig(); + } + @Singleton @Provides public static StatisticsManager provideStatisticsManager(Config config, DataManager dataManager, Client client) { @@ -202,6 +209,12 @@ public class MainModule extends AbstractModule { return null; } + @Singleton + @Provides + public static MotionHandler provideMotionHandler(TripsConfig tripsConfig) { + return new MotionHandler(tripsConfig.getSpeedThreshold()); + } + @Override protected void configure() { binder().requireExplicitBindings(); diff --git a/src/org/traccar/MotionHandler.java b/src/org/traccar/handler/MotionHandler.java index ec9a5ffd7..e8051dd75 100644 --- a/src/org/traccar/MotionHandler.java +++ b/src/org/traccar/handler/MotionHandler.java @@ -1,5 +1,5 @@ /* - * Copyright 2017 Anton Tananaev (anton@traccar.org) + * Copyright 2017 - 2019 Anton Tananaev (anton@traccar.org) * Copyright 2017 Andrey Kunitsyn (andrey@traccar.org) * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,9 +14,10 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.traccar; +package org.traccar.handler; import io.netty.channel.ChannelHandler; +import org.traccar.BaseDataHandler; import org.traccar.model.Position; @ChannelHandler.Sharable |