aboutsummaryrefslogtreecommitdiff
path: root/src/org
diff options
context:
space:
mode:
Diffstat (limited to 'src/org')
-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();
+ }
+
}