aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/org/traccar/MainModule.java
diff options
context:
space:
mode:
authorAnton Tananaev <anton@traccar.org>2022-06-18 13:36:32 -0700
committerAnton Tananaev <anton@traccar.org>2022-06-18 13:36:32 -0700
commite65bfeab8dafb02c21b360b4970d5d94013f53f6 (patch)
treee8cfeee74f316c8f5b2580f49466734881d204ad /src/main/java/org/traccar/MainModule.java
parent6fe1f8ed83680204fe7ec50382588dbe82fec1ba (diff)
downloadtrackermap-server-e65bfeab8dafb02c21b360b4970d5d94013f53f6.tar.gz
trackermap-server-e65bfeab8dafb02c21b360b4970d5d94013f53f6.tar.bz2
trackermap-server-e65bfeab8dafb02c21b360b4970d5d94013f53f6.zip
Finally remove context
Diffstat (limited to 'src/main/java/org/traccar/MainModule.java')
-rw-r--r--src/main/java/org/traccar/MainModule.java22
1 files changed, 20 insertions, 2 deletions
diff --git a/src/main/java/org/traccar/MainModule.java b/src/main/java/org/traccar/MainModule.java
index 439dcd1d9..7dcc91f32 100644
--- a/src/main/java/org/traccar/MainModule.java
+++ b/src/main/java/org/traccar/MainModule.java
@@ -22,6 +22,8 @@ import com.google.inject.AbstractModule;
import com.google.inject.Injector;
import com.google.inject.Provides;
import com.google.inject.Scopes;
+import com.google.inject.name.Named;
+import com.google.inject.name.Names;
import io.netty.util.HashedWheelTimer;
import io.netty.util.Timer;
import org.apache.velocity.app.VelocityEngine;
@@ -59,6 +61,7 @@ import org.traccar.geolocation.UnwiredGeolocationProvider;
import org.traccar.handler.GeocoderHandler;
import org.traccar.handler.GeolocationHandler;
import org.traccar.handler.SpeedLimitHandler;
+import org.traccar.helper.Log;
import org.traccar.helper.SanitizerModule;
import org.traccar.notification.EventForwarder;
import org.traccar.session.cache.CacheManager;
@@ -83,8 +86,15 @@ import java.util.Properties;
public class MainModule extends AbstractModule {
+ private final String configFile;
+
+ public MainModule(String configFile) {
+ this.configFile = configFile;
+ }
+
@Override
protected void configure() {
+ bindConstant().annotatedWith(Names.named("configFile")).to(configFile);
bind(Storage.class).to(DatabaseStorage.class);
bind(Timer.class).to(HashedWheelTimer.class).in(Scopes.SINGLETON);
}
@@ -101,9 +111,17 @@ public class MainModule extends AbstractModule {
return objectMapper;
}
+ @Singleton
@Provides
- public static Config provideConfig() {
- return Context.getConfig();
+ public static Config provideConfig(@Named("configFile") String configFile) throws Exception {
+ try {
+ Config config = new Config(configFile);
+ Log.setupLogger(config);
+ return config;
+ } catch (Exception e) {
+ Log.setupDefaultLogger();
+ throw e;
+ }
}
@Provides