diff options
-rw-r--r-- | default.cfg | 3 | ||||
-rw-r--r-- | opengts.cfg | 3 | ||||
-rw-r--r-- | setup/linux/traccar.cfg | 3 | ||||
-rw-r--r-- | setup/macosx/traccar.cfg | 3 | ||||
-rw-r--r-- | setup/windows/traccar.cfg | 3 | ||||
-rw-r--r-- | src/org/traccar/model/DatabaseDataManager.java | 22 |
6 files changed, 3 insertions, 34 deletions
diff --git a/default.cfg b/default.cfg index 45bfa87f3..a286bec1d 100644 --- a/default.cfg +++ b/default.cfg @@ -12,9 +12,6 @@ <entry key='database.user'>sa</entry> <entry key='database.password'></entry> - <!-- Database refresh delay in seconds --> - <entry key='database.refreshDelay'>300</entry> - <!--> id - Long imei - String diff --git a/opengts.cfg b/opengts.cfg index c738fcf0e..da819e1e9 100644 --- a/opengts.cfg +++ b/opengts.cfg @@ -10,9 +10,6 @@ <entry key='database.user'>[USER]</entry> <entry key='database.password'>[PASSWORD]</entry> - <!-- Database refresh delay in seconds --> - <entry key='database.refreshDelay'>300</entry> - <entry key='database.selectDevice'> SELECT imeiNumber AS id, imeiNumber AS imei FROM Device WHERE imeiNumber <> ''; </entry> diff --git a/setup/linux/traccar.cfg b/setup/linux/traccar.cfg index 0e0349283..1cf16119b 100644 --- a/setup/linux/traccar.cfg +++ b/setup/linux/traccar.cfg @@ -11,9 +11,6 @@ <entry key='database.user'>sa</entry> <entry key='database.password'></entry> - <!-- Database refresh delay in seconds --> - <entry key='database.refreshDelay'>300</entry> - <!--> id - Long imei - String diff --git a/setup/macosx/traccar.cfg b/setup/macosx/traccar.cfg index 0e0349283..1cf16119b 100644 --- a/setup/macosx/traccar.cfg +++ b/setup/macosx/traccar.cfg @@ -11,9 +11,6 @@ <entry key='database.user'>sa</entry> <entry key='database.password'></entry> - <!-- Database refresh delay in seconds --> - <entry key='database.refreshDelay'>300</entry> - <!--> id - Long imei - String diff --git a/setup/windows/traccar.cfg b/setup/windows/traccar.cfg index 412a8d612..64c6fff1f 100644 --- a/setup/windows/traccar.cfg +++ b/setup/windows/traccar.cfg @@ -11,9 +11,6 @@ <entry key='database.user'>sa</entry>
<entry key='database.password'></entry>
- <!-- Database refresh delay in seconds -->
- <entry key='database.refreshDelay'>300</entry>
-
<!-->
id - Long
imei - String
diff --git a/src/org/traccar/model/DatabaseDataManager.java b/src/org/traccar/model/DatabaseDataManager.java index ca5cb1372..3799c5461 100644 --- a/src/org/traccar/model/DatabaseDataManager.java +++ b/src/org/traccar/model/DatabaseDataManager.java @@ -1,5 +1,5 @@ /* - * Copyright 2012 - 2013 Anton Tananaev (anton.tananaev@gmail.com) + * Copyright 2012 - 2014 Anton Tananaev (anton.tananaev@gmail.com) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -21,11 +21,7 @@ import java.net.URL; import java.net.URLClassLoader; import java.sql.*; import java.util.*; -import java.util.logging.Level; -import java.util.logging.Logger; -import javax.xml.namespace.QName; import javax.xml.xpath.XPath; -import javax.xml.xpath.XPathConstants; import javax.xml.xpath.XPathExpressionException; import javax.xml.xpath.XPathFactory; import org.traccar.helper.AdvancedConnection; @@ -70,14 +66,6 @@ public class DatabaseDataManager implements DataManager { } } - // Refresh delay - String refreshDelay = properties.getProperty("database.refreshDelay"); - if (refreshDelay != null) { - devicesRefreshDelay = Long.valueOf(refreshDelay) * 1000; - } else { - devicesRefreshDelay = new Long(300) * 1000; // Magic number - } - // Connect database String url = properties.getProperty("database.url"); String user = properties.getProperty("database.user"); @@ -126,19 +114,15 @@ public class DatabaseDataManager implements DataManager { * Devices cache */ private Map<String, Device> devices; - private Calendar devicesLastUpdate; - private Long devicesRefreshDelay; @Override public Device getDeviceByImei(String imei) throws SQLException { - if ((devices == null) || (Calendar.getInstance().getTimeInMillis() - devicesLastUpdate.getTimeInMillis() > devicesRefreshDelay)) { - List<Device> list = getDevices(); + if (devices == null || !devices.containsKey(imei)) { devices = new HashMap<String, Device>(); - for (Device device: list) { + for (Device device: getDevices()) { devices.put(device.getImei(), device); } - devicesLastUpdate = Calendar.getInstance(); } return devices.get(imei); |