aboutsummaryrefslogtreecommitdiff
path: root/src/org/traccar
diff options
context:
space:
mode:
Diffstat (limited to 'src/org/traccar')
-rw-r--r--src/org/traccar/BasePipelineFactory.java5
-rw-r--r--src/org/traccar/MainModule.java19
-rw-r--r--src/org/traccar/WebDataHandler.java17
3 files changed, 15 insertions, 26 deletions
diff --git a/src/org/traccar/BasePipelineFactory.java b/src/org/traccar/BasePipelineFactory.java
index 517b92bbf..f24841a22 100644
--- a/src/org/traccar/BasePipelineFactory.java
+++ b/src/org/traccar/BasePipelineFactory.java
@@ -316,10 +316,7 @@ public abstract class BasePipelineFactory extends ChannelInitializer<Channel> {
}
if (Context.getConfig().getBoolean("forward.enable")) {
- pipeline.addLast(Main.getInjector().getInstance(WebDataHandler.Factory.class).create(
- Context.getConfig().getString("forward.url"),
- Context.getConfig().getString("forward.header"),
- Context.getConfig().getBoolean("forward.json")));
+ pipeline.addLast(Main.getInjector().getInstance(WebDataHandler.class));
}
addHandlers(
diff --git a/src/org/traccar/MainModule.java b/src/org/traccar/MainModule.java
index 6c66a90b8..19cad5237 100644
--- a/src/org/traccar/MainModule.java
+++ b/src/org/traccar/MainModule.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2018 Anton Tananaev (anton@traccar.org)
+ * Copyright 2018 - 2019 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.
@@ -18,7 +18,6 @@ package org.traccar;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.google.inject.AbstractModule;
import com.google.inject.Provides;
-import com.google.inject.assistedinject.FactoryModuleBuilder;
import org.traccar.database.IdentityManager;
import javax.ws.rs.client.Client;
@@ -26,23 +25,23 @@ import javax.ws.rs.client.Client;
public class MainModule extends AbstractModule {
@Provides
- public static ObjectMapper getObjectMapper() {
+ public static ObjectMapper provideObjectMapper() {
return Context.getObjectMapper();
}
@Provides
- public static IdentityManager getIdentityManager() {
- return Context.getIdentityManager();
+ public static Config provideConfig() {
+ return Context.getConfig();
}
@Provides
- public static Client getClient() {
- return Context.getClient();
+ public static IdentityManager provideIdentityManager() {
+ return Context.getIdentityManager();
}
- @Override
- protected void configure() {
- install(new FactoryModuleBuilder().build(WebDataHandler.Factory.class));
+ @Provides
+ public static Client provideClient() {
+ return Context.getClient();
}
}
diff --git a/src/org/traccar/WebDataHandler.java b/src/org/traccar/WebDataHandler.java
index 572252a22..e29e5a075 100644
--- a/src/org/traccar/WebDataHandler.java
+++ b/src/org/traccar/WebDataHandler.java
@@ -17,7 +17,6 @@ package org.traccar;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
-import com.google.inject.assistedinject.Assisted;
import org.traccar.database.IdentityManager;
import org.traccar.helper.Checksum;
import org.traccar.model.Device;
@@ -51,21 +50,15 @@ public class WebDataHandler extends BaseDataHandler {
private final String header;
private final boolean json;
- public interface Factory {
- WebDataHandler create(
- @Assisted("url") String url, @Assisted("header") String header, boolean json);
- }
-
@Inject
public WebDataHandler(
- IdentityManager identityManager, ObjectMapper objectMapper, Client client,
- @Assisted("url") String url, @Assisted("header") String header, @Assisted boolean json) {
+ Config config, IdentityManager identityManager, ObjectMapper objectMapper, Client client) {
this.identityManager = identityManager;
this.objectMapper = objectMapper;
this.client = client;
- this.url = url;
- this.header = header;
- this.json = json;
+ this.url = config.getString("forward.url");
+ this.header = config.getString("forward.header");
+ this.json = config.getBoolean("forward.json");
}
private static String formatSentence(Position position) {
@@ -187,7 +180,7 @@ public class WebDataHandler extends BaseDataHandler {
return position;
}
- protected Map<String, Object> prepareJsonPayload(Position position) {
+ private Map<String, Object> prepareJsonPayload(Position position) {
Map<String, Object> data = new HashMap<>();
Device device = identityManager.getById(position.getDeviceId());