aboutsummaryrefslogtreecommitdiff
path: root/src/org/traccar/database/ConnectionManager.java
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2015-07-14 19:34:58 +1200
committerAnton Tananaev <anton.tananaev@gmail.com>2015-07-14 19:34:58 +1200
commitf9b7908c1fe0c04e9dcb93b4261b9fe0b4bb1617 (patch)
tree057957543cb18c20bf66de6d363fdc821700832d /src/org/traccar/database/ConnectionManager.java
parente98b18b8b0a8c99d24ac8010c1393978d071baa2 (diff)
downloadtrackermap-server-f9b7908c1fe0c04e9dcb93b4261b9fe0b4bb1617.tar.gz
trackermap-server-f9b7908c1fe0c04e9dcb93b4261b9fe0b4bb1617.tar.bz2
trackermap-server-f9b7908c1fe0c04e9dcb93b4261b9fe0b4bb1617.zip
Reduce dependencies on data manager (fix #954)
Diffstat (limited to 'src/org/traccar/database/ConnectionManager.java')
-rw-r--r--src/org/traccar/database/ConnectionManager.java17
1 files changed, 9 insertions, 8 deletions
diff --git a/src/org/traccar/database/ConnectionManager.java b/src/org/traccar/database/ConnectionManager.java
index 0d357a41c..dc125d7b0 100644
--- a/src/org/traccar/database/ConnectionManager.java
+++ b/src/org/traccar/database/ConnectionManager.java
@@ -31,18 +31,19 @@ import org.traccar.model.Position;
public class ConnectionManager {
- private Map<String, ActiveDevice> activeDevices = new HashMap<>();
+ private final Map<String, ActiveDevice> activeDevices = new HashMap<>();
private final Map<Long, Position> positions = new HashMap<>();
private final Map<Long, Set<DataCacheListener>> listeners = new HashMap<>();
- public void init(DataManager dataManager) {
- try {
- Collection<Position> positions = dataManager.getLatestPositions();
- for (Position position : positions) {
- this.positions.put(position.getDeviceId(), position);
+ public ConnectionManager(DataManager dataManager) {
+ if (dataManager != null) {
+ try {
+ for (Position position : dataManager.getLatestPositions()) {
+ this.positions.put(position.getDeviceId(), position);
+ }
+ } catch (SQLException error) {
+ Log.warning(error);
}
- } catch (SQLException error) {
- Log.warning(error);
}
}