aboutsummaryrefslogtreecommitdiff
path: root/src/org/traccar
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2019-02-23 11:41:49 -0800
committerAnton Tananaev <anton.tananaev@gmail.com>2019-02-23 11:41:49 -0800
commitbd909426d24832e42a63503c338bbd8c37176caa (patch)
treef8c593e3e7875a7d53ce9dcfdce7dd791b52a6c2 /src/org/traccar
parent378e16a4845a245b27d3fbb2850f0abcbb502357 (diff)
downloadtraccar-server-bd909426d24832e42a63503c338bbd8c37176caa.tar.gz
traccar-server-bd909426d24832e42a63503c338bbd8c37176caa.tar.bz2
traccar-server-bd909426d24832e42a63503c338bbd8c37176caa.zip
Move logic to module
Diffstat (limited to 'src/org/traccar')
-rw-r--r--src/org/traccar/BasePipelineFactory.java6
-rw-r--r--src/org/traccar/MainModule.java18
2 files changed, 19 insertions, 5 deletions
diff --git a/src/org/traccar/BasePipelineFactory.java b/src/org/traccar/BasePipelineFactory.java
index 0c0e4ef46..4bc41bd55 100644
--- a/src/org/traccar/BasePipelineFactory.java
+++ b/src/org/traccar/BasePipelineFactory.java
@@ -31,7 +31,6 @@ import io.netty.channel.socket.DatagramPacket;
import io.netty.handler.timeout.IdleStateHandler;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import org.traccar.config.Keys;
import org.traccar.events.CommandResultEventHandler;
import org.traccar.events.DriverEventHandler;
import org.traccar.events.FuelDropEventHandler;
@@ -316,12 +315,9 @@ public abstract class BasePipelineFactory extends ChannelInitializer<Channel> {
pipeline.addLast(new DefaultDataHandler());
}
- if (Context.getConfig().getBoolean(Keys.FORWARD_ENABLE)) {
- pipeline.addLast(Main.getInjector().getInstance(WebDataHandler.class));
- }
-
addHandlers(
pipeline,
+ Main.getInjector().getInstance(WebDataHandler.class),
commandResultEventHandler,
overspeedEventHandler,
fuelDropEventHandler,
diff --git a/src/org/traccar/MainModule.java b/src/org/traccar/MainModule.java
index 40933aba5..26bdfcd60 100644
--- a/src/org/traccar/MainModule.java
+++ b/src/org/traccar/MainModule.java
@@ -18,7 +18,9 @@ package org.traccar;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.google.inject.AbstractModule;
import com.google.inject.Provides;
+import com.google.inject.Singleton;
import org.traccar.config.Config;
+import org.traccar.config.Keys;
import org.traccar.database.IdentityManager;
import javax.ws.rs.client.Client;
@@ -45,4 +47,20 @@ public class MainModule extends AbstractModule {
return Context.getClient();
}
+ @Singleton
+ @Provides
+ public static WebDataHandler provideWebDataHandler(
+ Config config, IdentityManager identityManager, ObjectMapper objectMapper, Client client) {
+ if (config.getBoolean(Keys.FORWARD_ENABLE)) {
+ return new WebDataHandler(config, identityManager, objectMapper, client);
+ } else {
+ return null;
+ }
+ }
+
+ @Override
+ protected void configure() {
+ binder().requireExplicitBindings();
+ }
+
}