aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAnton Tananaev <anton@traccar.org>2022-06-16 06:51:41 -0700
committerAnton Tananaev <anton@traccar.org>2022-06-16 06:51:41 -0700
commitd3fd20d4a4f7dc647e75c5a0cb962759630ed967 (patch)
tree9fada7b5571f61678f7fb5a862be4da0f1f84d12 /src
parent481a902538b951a420d00c32063e0984e4e922d6 (diff)
downloadtrackermap-server-d3fd20d4a4f7dc647e75c5a0cb962759630ed967.tar.gz
trackermap-server-d3fd20d4a4f7dc647e75c5a0cb962759630ed967.tar.bz2
trackermap-server-d3fd20d4a4f7dc647e75c5a0cb962759630ed967.zip
Inject data manager
Diffstat (limited to 'src')
-rw-r--r--src/main/java/org/traccar/Context.java24
-rw-r--r--src/main/java/org/traccar/MainModule.java6
-rw-r--r--src/main/java/org/traccar/database/DataManager.java8
3 files changed, 9 insertions, 29 deletions
diff --git a/src/main/java/org/traccar/Context.java b/src/main/java/org/traccar/Context.java
index 00ab05d57..cbbc73d76 100644
--- a/src/main/java/org/traccar/Context.java
+++ b/src/main/java/org/traccar/Context.java
@@ -16,7 +16,6 @@
package org.traccar;
import org.traccar.config.Config;
-import org.traccar.config.Keys;
import org.traccar.database.BaseObjectManager;
import org.traccar.database.DataManager;
import org.traccar.database.DeviceManager;
@@ -47,12 +46,6 @@ public final class Context {
return identityManager;
}
- private static DataManager dataManager;
-
- public static DataManager getDataManager() {
- return dataManager;
- }
-
private static GroupsManager groupsManager;
public static GroupsManager getGroupsManager() {
@@ -82,20 +75,17 @@ public final class Context {
throw e;
}
- if (config.hasKey(Keys.DATABASE_URL)) {
- dataManager = new DataManager(config, Main.getInjector().getInstance(Storage.class));
- }
-
- if (dataManager != null) {
- groupsManager = new GroupsManager(dataManager);
- deviceManager = new DeviceManager(
- config, dataManager, Main.getInjector().getInstance(ConnectionManager.class));
- }
+ groupsManager = new GroupsManager(Main.getInjector().getInstance(DataManager.class));
+ deviceManager = new DeviceManager(
+ config,
+ Main.getInjector().getInstance(DataManager.class),
+ Main.getInjector().getInstance(ConnectionManager.class));
identityManager = deviceManager;
permissionsManager = new PermissionsManager(
- dataManager, Main.getInjector().getInstance(Storage.class));
+ Main.getInjector().getInstance(DataManager.class),
+ Main.getInjector().getInstance(Storage.class));
}
diff --git a/src/main/java/org/traccar/MainModule.java b/src/main/java/org/traccar/MainModule.java
index 4e95b2be0..aac11e619 100644
--- a/src/main/java/org/traccar/MainModule.java
+++ b/src/main/java/org/traccar/MainModule.java
@@ -30,7 +30,6 @@ import org.eclipse.jetty.util.URIUtil;
import org.traccar.broadcast.BroadcastService;
import org.traccar.config.Config;
import org.traccar.config.Keys;
-import org.traccar.database.DataManager;
import org.traccar.database.DeviceManager;
import org.traccar.database.IdentityManager;
import org.traccar.database.LdapProvider;
@@ -115,11 +114,6 @@ public class MainModule extends AbstractModule {
}
@Provides
- public static DataManager provideDataManager() {
- return Context.getDataManager();
- }
-
- @Provides
public static IdentityManager provideIdentityManager() {
return Context.getIdentityManager();
}
diff --git a/src/main/java/org/traccar/database/DataManager.java b/src/main/java/org/traccar/database/DataManager.java
index 9ffe1fe97..3cad2dd63 100644
--- a/src/main/java/org/traccar/database/DataManager.java
+++ b/src/main/java/org/traccar/database/DataManager.java
@@ -32,6 +32,7 @@ import org.traccar.storage.query.Limit;
import org.traccar.storage.query.Order;
import org.traccar.storage.query.Request;
+import javax.inject.Inject;
import java.util.Collection;
import java.util.Date;
@@ -41,6 +42,7 @@ public class DataManager {
private final boolean forceLdap;
+ @Inject
public DataManager(Config config, Storage storage) throws Exception {
this.storage = storage;
forceLdap = config.getBoolean(Keys.LDAP_FORCE);
@@ -68,12 +70,6 @@ public class DataManager {
return null;
}
- public void updateUserPassword(User user) throws StorageException {
- storage.updateObject(user, new Request(
- new Columns.Include("hashedPassword", "salt"),
- new Condition.Equals("id", "id")));
- }
-
public void updateDeviceStatus(Device device) throws StorageException {
storage.updateObject(device, new Request(
new Columns.Include("lastUpdate"),