aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/org
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
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')
-rw-r--r--src/main/java/org/traccar/MainEventHandler.java9
-rw-r--r--src/main/java/org/traccar/MainModule.java9
-rw-r--r--src/main/java/org/traccar/WebDataHandler.java2
-rw-r--r--src/main/java/org/traccar/api/CorsResponseFilter.java2
-rw-r--r--src/main/java/org/traccar/api/security/LoginService.java2
-rw-r--r--src/main/java/org/traccar/api/signature/CryptoManager.java2
-rw-r--r--src/main/java/org/traccar/api/signature/TokenManager.java2
-rw-r--r--src/main/java/org/traccar/database/MediaManager.java2
-rw-r--r--src/main/java/org/traccar/database/NotificationManager.java2
-rw-r--r--src/main/java/org/traccar/handler/ComputedAttributesHandler.java2
-rw-r--r--src/main/java/org/traccar/handler/CopyAttributesHandler.java2
-rw-r--r--src/main/java/org/traccar/handler/DefaultDataHandler.java2
-rw-r--r--src/main/java/org/traccar/handler/DistanceHandler.java2
-rw-r--r--src/main/java/org/traccar/handler/EngineHoursHandler.java2
-rw-r--r--src/main/java/org/traccar/handler/FilterHandler.java2
-rw-r--r--src/main/java/org/traccar/handler/HemisphereHandler.java2
-rw-r--r--src/main/java/org/traccar/handler/MotionHandler.java2
-rw-r--r--src/main/java/org/traccar/handler/RemoteAddressHandler.java2
-rw-r--r--src/main/java/org/traccar/handler/SpeedLimitHandler.java2
-rw-r--r--src/main/java/org/traccar/handler/TimeHandler.java2
-rw-r--r--src/main/java/org/traccar/handler/events/AlertEventHandler.java2
-rw-r--r--src/main/java/org/traccar/handler/events/BehaviorEventHandler.java2
-rw-r--r--src/main/java/org/traccar/handler/events/CommandResultEventHandler.java2
-rw-r--r--src/main/java/org/traccar/handler/events/DriverEventHandler.java2
-rw-r--r--src/main/java/org/traccar/handler/events/FuelEventHandler.java2
-rw-r--r--src/main/java/org/traccar/handler/events/GeofenceEventHandler.java2
-rw-r--r--src/main/java/org/traccar/handler/events/IgnitionEventHandler.java2
-rw-r--r--src/main/java/org/traccar/handler/events/MaintenanceEventHandler.java2
-rw-r--r--src/main/java/org/traccar/handler/events/MediaEventHandler.java2
-rw-r--r--src/main/java/org/traccar/handler/events/MotionEventHandler.java2
-rw-r--r--src/main/java/org/traccar/handler/events/OverspeedEventHandler.java2
-rw-r--r--src/main/java/org/traccar/notification/NotificationFormatter.java2
-rw-r--r--src/main/java/org/traccar/notification/TextTemplateFormatter.java2
-rw-r--r--src/main/java/org/traccar/notificators/NotificatorMail.java2
-rw-r--r--src/main/java/org/traccar/notificators/NotificatorPushover.java2
-rw-r--r--src/main/java/org/traccar/notificators/NotificatorSms.java2
-rw-r--r--src/main/java/org/traccar/notificators/NotificatorTelegram.java2
-rw-r--r--src/main/java/org/traccar/notificators/NotificatorTraccar.java2
-rw-r--r--src/main/java/org/traccar/notificators/NotificatorWeb.java8
-rw-r--r--src/main/java/org/traccar/reports/common/ReportUtils.java2
-rw-r--r--src/main/java/org/traccar/reports/common/TripsConfig.java2
-rw-r--r--src/main/java/org/traccar/web/WebServer.java2
42 files changed, 92 insertions, 12 deletions
diff --git a/src/main/java/org/traccar/MainEventHandler.java b/src/main/java/org/traccar/MainEventHandler.java
index 52eb43faf..17bcad0dd 100644
--- a/src/main/java/org/traccar/MainEventHandler.java
+++ b/src/main/java/org/traccar/MainEventHandler.java
@@ -16,6 +16,7 @@
package org.traccar;
import io.netty.channel.Channel;
+import io.netty.channel.ChannelHandler;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelInboundHandlerAdapter;
import io.netty.channel.socket.DatagramChannel;
@@ -23,7 +24,6 @@ import io.netty.handler.codec.http.HttpRequestDecoder;
import io.netty.handler.timeout.IdleStateEvent;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import org.traccar.broadcast.BroadcastService;
import org.traccar.config.Config;
import org.traccar.config.Keys;
import org.traccar.database.StatisticsManager;
@@ -41,11 +41,14 @@ import org.traccar.storage.query.Condition;
import org.traccar.storage.query.Request;
import javax.inject.Inject;
+import javax.inject.Singleton;
import java.util.Arrays;
import java.util.HashSet;
import java.util.LinkedHashSet;
import java.util.Set;
+@Singleton
+@ChannelHandler.Sharable
public class MainEventHandler extends ChannelInboundHandlerAdapter {
private static final Logger LOGGER = LoggerFactory.getLogger(MainEventHandler.class);
@@ -57,17 +60,15 @@ public class MainEventHandler extends ChannelInboundHandlerAdapter {
private final Storage storage;
private final ConnectionManager connectionManager;
private final StatisticsManager statisticsManager;
- private final BroadcastService broadcastService;
@Inject
public MainEventHandler(
Config config, CacheManager cacheManager, Storage storage, ConnectionManager connectionManager,
- StatisticsManager statisticsManager, BroadcastService broadcastService) {
+ StatisticsManager statisticsManager) {
this.cacheManager = cacheManager;
this.storage = storage;
this.connectionManager = connectionManager;
this.statisticsManager = statisticsManager;
- this.broadcastService = broadcastService;
String connectionlessProtocolList = config.getString(Keys.STATUS_IGNORE_OFFLINE);
if (connectionlessProtocolList != null) {
connectionlessProtocols.addAll(Arrays.asList(connectionlessProtocolList.split("[, ]")));
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)) {
diff --git a/src/main/java/org/traccar/WebDataHandler.java b/src/main/java/org/traccar/WebDataHandler.java
index d0aa32e53..9b26c8875 100644
--- a/src/main/java/org/traccar/WebDataHandler.java
+++ b/src/main/java/org/traccar/WebDataHandler.java
@@ -33,6 +33,7 @@ import org.traccar.model.Group;
import org.traccar.session.cache.CacheManager;
import javax.inject.Inject;
+import javax.inject.Singleton;
import javax.ws.rs.core.HttpHeaders;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
@@ -52,6 +53,7 @@ import java.util.TimeZone;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicInteger;
+@Singleton
@ChannelHandler.Sharable
public class WebDataHandler extends BaseDataHandler {
diff --git a/src/main/java/org/traccar/api/CorsResponseFilter.java b/src/main/java/org/traccar/api/CorsResponseFilter.java
index 5375e207f..67d0341a1 100644
--- a/src/main/java/org/traccar/api/CorsResponseFilter.java
+++ b/src/main/java/org/traccar/api/CorsResponseFilter.java
@@ -20,11 +20,13 @@ import org.traccar.config.Config;
import org.traccar.config.Keys;
import javax.inject.Inject;
+import javax.inject.Singleton;
import javax.ws.rs.container.ContainerRequestContext;
import javax.ws.rs.container.ContainerResponseContext;
import javax.ws.rs.container.ContainerResponseFilter;
import java.io.IOException;
+@Singleton
public class CorsResponseFilter implements ContainerResponseFilter {
private final String allowed;
diff --git a/src/main/java/org/traccar/api/security/LoginService.java b/src/main/java/org/traccar/api/security/LoginService.java
index 1e82a4cf2..32487f06b 100644
--- a/src/main/java/org/traccar/api/security/LoginService.java
+++ b/src/main/java/org/traccar/api/security/LoginService.java
@@ -28,9 +28,11 @@ import org.traccar.storage.query.Request;
import javax.annotation.Nullable;
import javax.inject.Inject;
+import javax.inject.Singleton;
import java.io.IOException;
import java.security.GeneralSecurityException;
+@Singleton
public class LoginService {
private final Storage storage;
diff --git a/src/main/java/org/traccar/api/signature/CryptoManager.java b/src/main/java/org/traccar/api/signature/CryptoManager.java
index 8a3e7704c..249d5bd97 100644
--- a/src/main/java/org/traccar/api/signature/CryptoManager.java
+++ b/src/main/java/org/traccar/api/signature/CryptoManager.java
@@ -21,6 +21,7 @@ import org.traccar.storage.query.Columns;
import org.traccar.storage.query.Request;
import javax.inject.Inject;
+import javax.inject.Singleton;
import java.security.GeneralSecurityException;
import java.security.KeyFactory;
import java.security.KeyPair;
@@ -33,6 +34,7 @@ import java.security.spec.ECGenParameterSpec;
import java.security.spec.PKCS8EncodedKeySpec;
import java.security.spec.X509EncodedKeySpec;
+@Singleton
public class CryptoManager {
private final Storage storage;
diff --git a/src/main/java/org/traccar/api/signature/TokenManager.java b/src/main/java/org/traccar/api/signature/TokenManager.java
index a352ecc10..6a0d90b40 100644
--- a/src/main/java/org/traccar/api/signature/TokenManager.java
+++ b/src/main/java/org/traccar/api/signature/TokenManager.java
@@ -21,11 +21,13 @@ import org.apache.commons.codec.binary.Base64;
import org.traccar.storage.StorageException;
import javax.inject.Inject;
+import javax.inject.Singleton;
import java.io.IOException;
import java.security.GeneralSecurityException;
import java.util.Date;
import java.util.concurrent.TimeUnit;
+@Singleton
public class TokenManager {
private static final int DEFAULT_EXPIRATION_DAYS = 7;
diff --git a/src/main/java/org/traccar/database/MediaManager.java b/src/main/java/org/traccar/database/MediaManager.java
index 2b3e3e1ee..c1ef810ee 100644
--- a/src/main/java/org/traccar/database/MediaManager.java
+++ b/src/main/java/org/traccar/database/MediaManager.java
@@ -22,6 +22,7 @@ import org.traccar.config.Config;
import org.traccar.config.Keys;
import javax.inject.Inject;
+import javax.inject.Singleton;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
@@ -34,6 +35,7 @@ import java.nio.file.Paths;
import java.text.SimpleDateFormat;
import java.util.Date;
+@Singleton
public class MediaManager {
private static final Logger LOGGER = LoggerFactory.getLogger(MediaManager.class);
diff --git a/src/main/java/org/traccar/database/NotificationManager.java b/src/main/java/org/traccar/database/NotificationManager.java
index 5be627f2a..5ea89fcac 100644
--- a/src/main/java/org/traccar/database/NotificationManager.java
+++ b/src/main/java/org/traccar/database/NotificationManager.java
@@ -36,11 +36,13 @@ import org.traccar.storage.query.Request;
import javax.annotation.Nullable;
import javax.inject.Inject;
+import javax.inject.Singleton;
import java.util.Arrays;
import java.util.Map;
import java.util.Map.Entry;
import java.util.stream.Collectors;
+@Singleton
public class NotificationManager {
private static final Logger LOGGER = LoggerFactory.getLogger(NotificationManager.class);
diff --git a/src/main/java/org/traccar/handler/ComputedAttributesHandler.java b/src/main/java/org/traccar/handler/ComputedAttributesHandler.java
index 82ac4e804..c9f1f63d7 100644
--- a/src/main/java/org/traccar/handler/ComputedAttributesHandler.java
+++ b/src/main/java/org/traccar/handler/ComputedAttributesHandler.java
@@ -40,7 +40,9 @@ import org.traccar.model.Position;
import org.traccar.session.cache.CacheManager;
import javax.inject.Inject;
+import javax.inject.Singleton;
+@Singleton
@ChannelHandler.Sharable
public class ComputedAttributesHandler extends BaseDataHandler {
diff --git a/src/main/java/org/traccar/handler/CopyAttributesHandler.java b/src/main/java/org/traccar/handler/CopyAttributesHandler.java
index 1fa47cfaa..e5c9bc29a 100644
--- a/src/main/java/org/traccar/handler/CopyAttributesHandler.java
+++ b/src/main/java/org/traccar/handler/CopyAttributesHandler.java
@@ -25,7 +25,9 @@ import org.traccar.model.Position;
import org.traccar.session.cache.CacheManager;
import javax.inject.Inject;
+import javax.inject.Singleton;
+@Singleton
@ChannelHandler.Sharable
public class CopyAttributesHandler extends BaseDataHandler {
diff --git a/src/main/java/org/traccar/handler/DefaultDataHandler.java b/src/main/java/org/traccar/handler/DefaultDataHandler.java
index f6a20628b..89255a5fe 100644
--- a/src/main/java/org/traccar/handler/DefaultDataHandler.java
+++ b/src/main/java/org/traccar/handler/DefaultDataHandler.java
@@ -25,7 +25,9 @@ import org.traccar.storage.query.Columns;
import org.traccar.storage.query.Request;
import javax.inject.Inject;
+import javax.inject.Singleton;
+@Singleton
@ChannelHandler.Sharable
public class DefaultDataHandler extends BaseDataHandler {
diff --git a/src/main/java/org/traccar/handler/DistanceHandler.java b/src/main/java/org/traccar/handler/DistanceHandler.java
index 87c4a81c9..30dc9ff2b 100644
--- a/src/main/java/org/traccar/handler/DistanceHandler.java
+++ b/src/main/java/org/traccar/handler/DistanceHandler.java
@@ -25,9 +25,11 @@ import org.traccar.model.Position;
import org.traccar.session.cache.CacheManager;
import javax.inject.Inject;
+import javax.inject.Singleton;
import java.math.BigDecimal;
import java.math.RoundingMode;
+@Singleton
@ChannelHandler.Sharable
public class DistanceHandler extends BaseDataHandler {
diff --git a/src/main/java/org/traccar/handler/EngineHoursHandler.java b/src/main/java/org/traccar/handler/EngineHoursHandler.java
index 54a1a0c25..c10fe9064 100644
--- a/src/main/java/org/traccar/handler/EngineHoursHandler.java
+++ b/src/main/java/org/traccar/handler/EngineHoursHandler.java
@@ -22,7 +22,9 @@ import org.traccar.model.Position;
import org.traccar.session.cache.CacheManager;
import javax.inject.Inject;
+import javax.inject.Singleton;
+@Singleton
@ChannelHandler.Sharable
public class EngineHoursHandler extends BaseDataHandler {
diff --git a/src/main/java/org/traccar/handler/FilterHandler.java b/src/main/java/org/traccar/handler/FilterHandler.java
index 37f5cd566..f09cb16a3 100644
--- a/src/main/java/org/traccar/handler/FilterHandler.java
+++ b/src/main/java/org/traccar/handler/FilterHandler.java
@@ -35,8 +35,10 @@ import org.traccar.storage.query.Order;
import org.traccar.storage.query.Request;
import javax.inject.Inject;
+import javax.inject.Singleton;
import java.util.Date;
+@Singleton
@ChannelHandler.Sharable
public class FilterHandler extends BaseDataHandler {
diff --git a/src/main/java/org/traccar/handler/HemisphereHandler.java b/src/main/java/org/traccar/handler/HemisphereHandler.java
index f760457a3..ccbde9fe5 100644
--- a/src/main/java/org/traccar/handler/HemisphereHandler.java
+++ b/src/main/java/org/traccar/handler/HemisphereHandler.java
@@ -22,7 +22,9 @@ import org.traccar.config.Keys;
import org.traccar.model.Position;
import javax.inject.Inject;
+import javax.inject.Singleton;
+@Singleton
@ChannelHandler.Sharable
public class HemisphereHandler extends BaseDataHandler {
diff --git a/src/main/java/org/traccar/handler/MotionHandler.java b/src/main/java/org/traccar/handler/MotionHandler.java
index 25ee615c5..10312f9b3 100644
--- a/src/main/java/org/traccar/handler/MotionHandler.java
+++ b/src/main/java/org/traccar/handler/MotionHandler.java
@@ -22,7 +22,9 @@ import org.traccar.model.Position;
import org.traccar.reports.common.TripsConfig;
import javax.inject.Inject;
+import javax.inject.Singleton;
+@Singleton
@ChannelHandler.Sharable
public class MotionHandler extends BaseDataHandler {
diff --git a/src/main/java/org/traccar/handler/RemoteAddressHandler.java b/src/main/java/org/traccar/handler/RemoteAddressHandler.java
index 809f67ca2..e18d34ef2 100644
--- a/src/main/java/org/traccar/handler/RemoteAddressHandler.java
+++ b/src/main/java/org/traccar/handler/RemoteAddressHandler.java
@@ -23,8 +23,10 @@ import org.traccar.config.Keys;
import org.traccar.model.Position;
import javax.inject.Inject;
+import javax.inject.Singleton;
import java.net.InetSocketAddress;
+@Singleton
@ChannelHandler.Sharable
public class RemoteAddressHandler extends ChannelInboundHandlerAdapter {
diff --git a/src/main/java/org/traccar/handler/SpeedLimitHandler.java b/src/main/java/org/traccar/handler/SpeedLimitHandler.java
index 0469b9f16..0c6025999 100644
--- a/src/main/java/org/traccar/handler/SpeedLimitHandler.java
+++ b/src/main/java/org/traccar/handler/SpeedLimitHandler.java
@@ -24,7 +24,9 @@ import org.traccar.model.Position;
import org.traccar.speedlimit.SpeedLimitProvider;
import javax.inject.Inject;
+import javax.inject.Singleton;
+@Singleton
@ChannelHandler.Sharable
public class SpeedLimitHandler extends ChannelInboundHandlerAdapter {
diff --git a/src/main/java/org/traccar/handler/TimeHandler.java b/src/main/java/org/traccar/handler/TimeHandler.java
index 439c076c7..c98b0bd4c 100644
--- a/src/main/java/org/traccar/handler/TimeHandler.java
+++ b/src/main/java/org/traccar/handler/TimeHandler.java
@@ -24,10 +24,12 @@ import org.traccar.config.Keys;
import org.traccar.model.Position;
import javax.inject.Inject;
+import javax.inject.Singleton;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;
+@Singleton
@ChannelHandler.Sharable
public class TimeHandler extends ChannelInboundHandlerAdapter {
diff --git a/src/main/java/org/traccar/handler/events/AlertEventHandler.java b/src/main/java/org/traccar/handler/events/AlertEventHandler.java
index 75626ca6c..9f77df989 100644
--- a/src/main/java/org/traccar/handler/events/AlertEventHandler.java
+++ b/src/main/java/org/traccar/handler/events/AlertEventHandler.java
@@ -26,7 +26,9 @@ import org.traccar.model.Position;
import org.traccar.session.cache.CacheManager;
import javax.inject.Inject;
+import javax.inject.Singleton;
+@Singleton
@ChannelHandler.Sharable
public class AlertEventHandler extends BaseEventHandler {
diff --git a/src/main/java/org/traccar/handler/events/BehaviorEventHandler.java b/src/main/java/org/traccar/handler/events/BehaviorEventHandler.java
index 3c2fa6a97..51bbd82d6 100644
--- a/src/main/java/org/traccar/handler/events/BehaviorEventHandler.java
+++ b/src/main/java/org/traccar/handler/events/BehaviorEventHandler.java
@@ -24,9 +24,11 @@ import org.traccar.model.Position;
import org.traccar.session.cache.CacheManager;
import javax.inject.Inject;
+import javax.inject.Singleton;
import java.util.Collections;
import java.util.Map;
+@Singleton
@ChannelHandler.Sharable
public class BehaviorEventHandler extends BaseEventHandler {
diff --git a/src/main/java/org/traccar/handler/events/CommandResultEventHandler.java b/src/main/java/org/traccar/handler/events/CommandResultEventHandler.java
index 858f84e09..772176e9c 100644
--- a/src/main/java/org/traccar/handler/events/CommandResultEventHandler.java
+++ b/src/main/java/org/traccar/handler/events/CommandResultEventHandler.java
@@ -23,7 +23,9 @@ import org.traccar.model.Event;
import org.traccar.model.Position;
import javax.inject.Inject;
+import javax.inject.Singleton;
+@Singleton
@ChannelHandler.Sharable
public class CommandResultEventHandler extends BaseEventHandler {
diff --git a/src/main/java/org/traccar/handler/events/DriverEventHandler.java b/src/main/java/org/traccar/handler/events/DriverEventHandler.java
index 1ad66ba64..51fdc0307 100644
--- a/src/main/java/org/traccar/handler/events/DriverEventHandler.java
+++ b/src/main/java/org/traccar/handler/events/DriverEventHandler.java
@@ -23,9 +23,11 @@ import org.traccar.model.Position;
import org.traccar.session.cache.CacheManager;
import javax.inject.Inject;
+import javax.inject.Singleton;
import java.util.Collections;
import java.util.Map;
+@Singleton
@ChannelHandler.Sharable
public class DriverEventHandler extends BaseEventHandler {
diff --git a/src/main/java/org/traccar/handler/events/FuelEventHandler.java b/src/main/java/org/traccar/handler/events/FuelEventHandler.java
index d5d4ab9be..462cc4223 100644
--- a/src/main/java/org/traccar/handler/events/FuelEventHandler.java
+++ b/src/main/java/org/traccar/handler/events/FuelEventHandler.java
@@ -25,8 +25,10 @@ import org.traccar.model.Position;
import org.traccar.session.cache.CacheManager;
import javax.inject.Inject;
+import javax.inject.Singleton;
import java.util.Map;
+@Singleton
@ChannelHandler.Sharable
public class FuelEventHandler extends BaseEventHandler {
diff --git a/src/main/java/org/traccar/handler/events/GeofenceEventHandler.java b/src/main/java/org/traccar/handler/events/GeofenceEventHandler.java
index 70bdb84cb..b1be7e8ad 100644
--- a/src/main/java/org/traccar/handler/events/GeofenceEventHandler.java
+++ b/src/main/java/org/traccar/handler/events/GeofenceEventHandler.java
@@ -33,11 +33,13 @@ import org.traccar.storage.query.Condition;
import org.traccar.storage.query.Request;
import javax.inject.Inject;
+import javax.inject.Singleton;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
+@Singleton
@ChannelHandler.Sharable
public class GeofenceEventHandler extends BaseEventHandler {
diff --git a/src/main/java/org/traccar/handler/events/IgnitionEventHandler.java b/src/main/java/org/traccar/handler/events/IgnitionEventHandler.java
index 3c5ac3545..b2e9a3325 100644
--- a/src/main/java/org/traccar/handler/events/IgnitionEventHandler.java
+++ b/src/main/java/org/traccar/handler/events/IgnitionEventHandler.java
@@ -27,7 +27,9 @@ import org.traccar.model.Position;
import org.traccar.session.cache.CacheManager;
import javax.inject.Inject;
+import javax.inject.Singleton;
+@Singleton
@ChannelHandler.Sharable
public class IgnitionEventHandler extends BaseEventHandler {
diff --git a/src/main/java/org/traccar/handler/events/MaintenanceEventHandler.java b/src/main/java/org/traccar/handler/events/MaintenanceEventHandler.java
index be3e9bf8d..4fcfcd079 100644
--- a/src/main/java/org/traccar/handler/events/MaintenanceEventHandler.java
+++ b/src/main/java/org/traccar/handler/events/MaintenanceEventHandler.java
@@ -26,7 +26,9 @@ import org.traccar.model.Position;
import org.traccar.session.cache.CacheManager;
import javax.inject.Inject;
+import javax.inject.Singleton;
+@Singleton
@ChannelHandler.Sharable
public class MaintenanceEventHandler extends BaseEventHandler {
diff --git a/src/main/java/org/traccar/handler/events/MediaEventHandler.java b/src/main/java/org/traccar/handler/events/MediaEventHandler.java
index 5b9013fad..a49e08e8d 100644
--- a/src/main/java/org/traccar/handler/events/MediaEventHandler.java
+++ b/src/main/java/org/traccar/handler/events/MediaEventHandler.java
@@ -20,10 +20,12 @@ import org.traccar.model.Event;
import org.traccar.model.Position;
import javax.inject.Inject;
+import javax.inject.Singleton;
import java.util.Map;
import java.util.stream.Collectors;
import java.util.stream.Stream;
+@Singleton
@ChannelHandler.Sharable
public class MediaEventHandler extends BaseEventHandler {
diff --git a/src/main/java/org/traccar/handler/events/MotionEventHandler.java b/src/main/java/org/traccar/handler/events/MotionEventHandler.java
index 0777f353a..3511cf682 100644
--- a/src/main/java/org/traccar/handler/events/MotionEventHandler.java
+++ b/src/main/java/org/traccar/handler/events/MotionEventHandler.java
@@ -34,9 +34,11 @@ import org.traccar.storage.query.Condition;
import org.traccar.storage.query.Request;
import javax.inject.Inject;
+import javax.inject.Singleton;
import java.util.Collections;
import java.util.Map;
+@Singleton
@ChannelHandler.Sharable
public class MotionEventHandler extends BaseEventHandler {
diff --git a/src/main/java/org/traccar/handler/events/OverspeedEventHandler.java b/src/main/java/org/traccar/handler/events/OverspeedEventHandler.java
index c03b8eb7b..3928fcc88 100644
--- a/src/main/java/org/traccar/handler/events/OverspeedEventHandler.java
+++ b/src/main/java/org/traccar/handler/events/OverspeedEventHandler.java
@@ -37,9 +37,11 @@ import org.traccar.storage.query.Condition;
import org.traccar.storage.query.Request;
import javax.inject.Inject;
+import javax.inject.Singleton;
import java.util.Collections;
import java.util.Map;
+@Singleton
@ChannelHandler.Sharable
public class OverspeedEventHandler extends BaseEventHandler {
diff --git a/src/main/java/org/traccar/notification/NotificationFormatter.java b/src/main/java/org/traccar/notification/NotificationFormatter.java
index fa244d9b4..9ee3b97b6 100644
--- a/src/main/java/org/traccar/notification/NotificationFormatter.java
+++ b/src/main/java/org/traccar/notification/NotificationFormatter.java
@@ -28,7 +28,9 @@ import org.traccar.model.User;
import org.traccar.session.cache.CacheManager;
import javax.inject.Inject;
+import javax.inject.Singleton;
+@Singleton
public class NotificationFormatter {
private final CacheManager cacheManager;
diff --git a/src/main/java/org/traccar/notification/TextTemplateFormatter.java b/src/main/java/org/traccar/notification/TextTemplateFormatter.java
index be894af96..444f4a7c2 100644
--- a/src/main/java/org/traccar/notification/TextTemplateFormatter.java
+++ b/src/main/java/org/traccar/notification/TextTemplateFormatter.java
@@ -30,6 +30,7 @@ import org.traccar.model.User;
import org.traccar.storage.StorageException;
import javax.inject.Inject;
+import javax.inject.Singleton;
import java.io.IOException;
import java.io.StringWriter;
import java.nio.charset.StandardCharsets;
@@ -37,6 +38,7 @@ import java.nio.file.Paths;
import java.security.GeneralSecurityException;
import java.util.Locale;
+@Singleton
public class TextTemplateFormatter {
private static final Logger LOGGER = LoggerFactory.getLogger(TextTemplateFormatter.class);
diff --git a/src/main/java/org/traccar/notificators/NotificatorMail.java b/src/main/java/org/traccar/notificators/NotificatorMail.java
index 75571cfc4..19fde6756 100644
--- a/src/main/java/org/traccar/notificators/NotificatorMail.java
+++ b/src/main/java/org/traccar/notificators/NotificatorMail.java
@@ -24,8 +24,10 @@ import org.traccar.notification.MessageException;
import org.traccar.notification.NotificationFormatter;
import javax.inject.Inject;
+import javax.inject.Singleton;
import javax.mail.MessagingException;
+@Singleton
public class NotificatorMail implements Notificator {
private final MailManager mailManager;
diff --git a/src/main/java/org/traccar/notificators/NotificatorPushover.java b/src/main/java/org/traccar/notificators/NotificatorPushover.java
index 105cb27f0..e00db0579 100644
--- a/src/main/java/org/traccar/notificators/NotificatorPushover.java
+++ b/src/main/java/org/traccar/notificators/NotificatorPushover.java
@@ -24,9 +24,11 @@ import org.traccar.model.User;
import org.traccar.notification.NotificationFormatter;
import javax.inject.Inject;
+import javax.inject.Singleton;
import javax.ws.rs.client.Client;
import javax.ws.rs.client.Entity;
+@Singleton
public class NotificatorPushover implements Notificator {
private final NotificationFormatter notificationFormatter;
diff --git a/src/main/java/org/traccar/notificators/NotificatorSms.java b/src/main/java/org/traccar/notificators/NotificatorSms.java
index 544b67a5e..e37d10888 100644
--- a/src/main/java/org/traccar/notificators/NotificatorSms.java
+++ b/src/main/java/org/traccar/notificators/NotificatorSms.java
@@ -25,7 +25,9 @@ import org.traccar.notification.NotificationFormatter;
import org.traccar.sms.SmsManager;
import javax.inject.Inject;
+import javax.inject.Singleton;
+@Singleton
public class NotificatorSms implements Notificator {
private final SmsManager smsManager;
diff --git a/src/main/java/org/traccar/notificators/NotificatorTelegram.java b/src/main/java/org/traccar/notificators/NotificatorTelegram.java
index a00cd36f1..38e87c222 100644
--- a/src/main/java/org/traccar/notificators/NotificatorTelegram.java
+++ b/src/main/java/org/traccar/notificators/NotificatorTelegram.java
@@ -25,9 +25,11 @@ import org.traccar.model.User;
import org.traccar.notification.NotificationFormatter;
import javax.inject.Inject;
+import javax.inject.Singleton;
import javax.ws.rs.client.Client;
import javax.ws.rs.client.Entity;
+@Singleton
public class NotificatorTelegram implements Notificator {
private final NotificationFormatter notificationFormatter;
diff --git a/src/main/java/org/traccar/notificators/NotificatorTraccar.java b/src/main/java/org/traccar/notificators/NotificatorTraccar.java
index 123b16ad8..9ae39f975 100644
--- a/src/main/java/org/traccar/notificators/NotificatorTraccar.java
+++ b/src/main/java/org/traccar/notificators/NotificatorTraccar.java
@@ -24,9 +24,11 @@ import org.traccar.model.User;
import org.traccar.notification.NotificationFormatter;
import javax.inject.Inject;
+import javax.inject.Singleton;
import javax.ws.rs.client.Client;
import javax.ws.rs.client.Entity;
+@Singleton
public class NotificatorTraccar implements Notificator {
private final NotificationFormatter notificationFormatter;
diff --git a/src/main/java/org/traccar/notificators/NotificatorWeb.java b/src/main/java/org/traccar/notificators/NotificatorWeb.java
index f495042a5..deabeade1 100644
--- a/src/main/java/org/traccar/notificators/NotificatorWeb.java
+++ b/src/main/java/org/traccar/notificators/NotificatorWeb.java
@@ -16,7 +16,6 @@
*/
package org.traccar.notificators;
-import org.traccar.broadcast.BroadcastService;
import org.traccar.model.Event;
import org.traccar.model.Position;
import org.traccar.model.User;
@@ -24,19 +23,18 @@ import org.traccar.notification.NotificationFormatter;
import org.traccar.session.ConnectionManager;
import javax.inject.Inject;
+import javax.inject.Singleton;
+@Singleton
public final class NotificatorWeb implements Notificator {
private final ConnectionManager connectionManager;
- private final BroadcastService broadcastService;
private final NotificationFormatter notificationFormatter;
@Inject
public NotificatorWeb(
- ConnectionManager connectionManager, BroadcastService broadcastService,
- NotificationFormatter notificationFormatter) {
+ ConnectionManager connectionManager, NotificationFormatter notificationFormatter) {
this.connectionManager = connectionManager;
- this.broadcastService = broadcastService;
this.notificationFormatter = notificationFormatter;
}
diff --git a/src/main/java/org/traccar/reports/common/ReportUtils.java b/src/main/java/org/traccar/reports/common/ReportUtils.java
index 57ed4d148..1de774dab 100644
--- a/src/main/java/org/traccar/reports/common/ReportUtils.java
+++ b/src/main/java/org/traccar/reports/common/ReportUtils.java
@@ -52,6 +52,7 @@ import org.traccar.storage.query.Request;
import javax.annotation.Nullable;
import javax.inject.Inject;
+import javax.inject.Singleton;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
@@ -67,6 +68,7 @@ import java.util.Locale;
import java.util.Objects;
import java.util.stream.Collectors;
+@Singleton
public class ReportUtils {
private final Config config;
diff --git a/src/main/java/org/traccar/reports/common/TripsConfig.java b/src/main/java/org/traccar/reports/common/TripsConfig.java
index c28cbeed4..52db97b74 100644
--- a/src/main/java/org/traccar/reports/common/TripsConfig.java
+++ b/src/main/java/org/traccar/reports/common/TripsConfig.java
@@ -20,7 +20,9 @@ import org.traccar.config.Config;
import org.traccar.config.Keys;
import javax.inject.Inject;
+import javax.inject.Singleton;
+@Singleton
public class TripsConfig {
@Inject
diff --git a/src/main/java/org/traccar/web/WebServer.java b/src/main/java/org/traccar/web/WebServer.java
index 62ac338eb..a7ac4d6b2 100644
--- a/src/main/java/org/traccar/web/WebServer.java
+++ b/src/main/java/org/traccar/web/WebServer.java
@@ -52,7 +52,6 @@ import org.traccar.api.security.SecurityRequestFilter;
import org.traccar.config.Config;
import org.traccar.config.Keys;
-import javax.inject.Inject;
import javax.servlet.DispatcherType;
import javax.servlet.ServletException;
import javax.servlet.SessionCookieConfig;
@@ -76,7 +75,6 @@ public class WebServer implements LifecycleObject {
private final Config config;
private final Server server;
- @Inject
public WebServer(Injector injector, Config config) {
this.injector = injector;
this.config = config;