aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/org/traccar/MainModule.java
diff options
context:
space:
mode:
authorAnton Tananaev <anton@traccar.org>2023-03-12 11:03:25 -0700
committerAnton Tananaev <anton@traccar.org>2023-03-12 11:03:25 -0700
commit08612944b879861c37b34688e0e9ef2d4a8c11a2 (patch)
treee6811c830a51dde18d6b5ef719af368003e6ea48 /src/main/java/org/traccar/MainModule.java
parent4fc5d0b58b3667ee1bb81515deef6440225af76b (diff)
downloadtrackermap-server-08612944b879861c37b34688e0e9ef2d4a8c11a2.tar.gz
trackermap-server-08612944b879861c37b34688e0e9ef2d4a8c11a2.tar.bz2
trackermap-server-08612944b879861c37b34688e0e9ef2d4a8c11a2.zip
Implement memory storage
Diffstat (limited to 'src/main/java/org/traccar/MainModule.java')
-rw-r--r--src/main/java/org/traccar/MainModule.java12
1 files changed, 11 insertions, 1 deletions
diff --git a/src/main/java/org/traccar/MainModule.java b/src/main/java/org/traccar/MainModule.java
index ae42d6712..663747de1 100644
--- a/src/main/java/org/traccar/MainModule.java
+++ b/src/main/java/org/traccar/MainModule.java
@@ -84,6 +84,7 @@ import org.traccar.sms.SnsSmsClient;
import org.traccar.speedlimit.OverpassSpeedLimitProvider;
import org.traccar.speedlimit.SpeedLimitProvider;
import org.traccar.storage.DatabaseStorage;
+import org.traccar.storage.MemoryStorage;
import org.traccar.storage.Storage;
import org.traccar.web.WebServer;
@@ -108,12 +109,21 @@ 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).in(Scopes.SINGLETON);
bind(Timer.class).to(HashedWheelTimer.class).in(Scopes.SINGLETON);
}
@Singleton
@Provides
+ public static Storage provideStorage(Injector injector, Config config) {
+ if (config.getBoolean(Keys.DATABASE_MEMORY)) {
+ return injector.getInstance(MemoryStorage.class);
+ } else {
+ return injector.getInstance(DatabaseStorage.class);
+ }
+ }
+
+ @Singleton
+ @Provides
public static ObjectMapper provideObjectMapper(Config config) {
ObjectMapper objectMapper = new ObjectMapper();
if (config.getBoolean(Keys.WEB_SANITIZE)) {