aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/org/traccar/MainModule.java
diff options
context:
space:
mode:
authorAnton Tananaev <anton@traccar.org>2022-10-02 08:39:06 -0700
committerAnton Tananaev <anton@traccar.org>2022-10-02 08:39:06 -0700
commitae3eddba7e0a6688807f71d2c290618d1c49da05 (patch)
treec0ff0ed14f7ccfcd99973d16e8bcbe52045e8f5b /src/main/java/org/traccar/MainModule.java
parent63a8bb747e92cc98d64bad59464922a9f6be5867 (diff)
downloadtrackermap-server-ae3eddba7e0a6688807f71d2c290618d1c49da05.tar.gz
trackermap-server-ae3eddba7e0a6688807f71d2c290618d1c49da05.tar.bz2
trackermap-server-ae3eddba7e0a6688807f71d2c290618d1c49da05.zip
Use singletons where possible
Diffstat (limited to 'src/main/java/org/traccar/MainModule.java')
-rw-r--r--src/main/java/org/traccar/MainModule.java9
1 files changed, 8 insertions, 1 deletions
diff --git a/src/main/java/org/traccar/MainModule.java b/src/main/java/org/traccar/MainModule.java
index 94669915b..c4cda578e 100644
--- a/src/main/java/org/traccar/MainModule.java
+++ b/src/main/java/org/traccar/MainModule.java
@@ -99,10 +99,11 @@ public class MainModule extends AbstractModule {
protected void configure() {
bindConstant().annotatedWith(Names.named("configFile")).to(configFile);
bind(Config.class).asEagerSingleton();
- bind(Storage.class).to(DatabaseStorage.class);
+ bind(Storage.class).to(DatabaseStorage.class).in(Scopes.SINGLETON);
bind(Timer.class).to(HashedWheelTimer.class).in(Scopes.SINGLETON);
}
+ @Singleton
@Provides
public static ObjectMapper provideObjectMapper(Config config) {
ObjectMapper objectMapper = new ObjectMapper();
@@ -114,6 +115,7 @@ public class MainModule extends AbstractModule {
return objectMapper;
}
+ @Singleton
@Provides
public static Client provideClient(ObjectMapperContextResolver objectMapperContextResolver) {
return ClientBuilder.newClient().register(objectMapperContextResolver);
@@ -130,6 +132,7 @@ public class MainModule extends AbstractModule {
return null;
}
+ @Singleton
@Provides
public static MailManager provideMailManager(Config config, StatisticsManager statisticsManager) {
if (config.getBoolean(Keys.MAIL_DEBUG)) {
@@ -265,6 +268,7 @@ public class MainModule extends AbstractModule {
return null;
}
+ @Singleton
@Provides
public static GeolocationHandler provideGeolocationHandler(
Config config, @Nullable GeolocationProvider geolocationProvider, CacheManager cacheManager,
@@ -275,6 +279,7 @@ public class MainModule extends AbstractModule {
return null;
}
+ @Singleton
@Provides
public static GeocoderHandler provideGeocoderHandler(
Config config, @Nullable Geocoder geocoder, CacheManager cacheManager) {
@@ -284,6 +289,7 @@ public class MainModule extends AbstractModule {
return null;
}
+ @Singleton
@Provides
public static SpeedLimitHandler provideSpeedLimitHandler(@Nullable SpeedLimitProvider speedLimitProvider) {
if (speedLimitProvider != null) {
@@ -302,6 +308,7 @@ public class MainModule extends AbstractModule {
return new NullBroadcastService();
}
+ @Singleton
@Provides
public static EventForwarder provideEventForwarder(Config config, Client client, CacheManager cacheManager) {
if (config.hasKey(Keys.EVENT_FORWARD_URL)) {