diff options
author | Abyss777 <abyss@fox5.ru> | 2017-07-24 16:25:34 +0500 |
---|---|---|
committer | Abyss777 <abyss@fox5.ru> | 2017-07-24 16:25:34 +0500 |
commit | d6c7cdf1e103c977ed94b737dc838d7ac22b9fa7 (patch) | |
tree | 12c3b57771236977cedde9651f7c5a44e67ec23f /src/org/traccar/database/DriversManager.java | |
parent | 4b2372336d0496c85befe099914434e5b68f05b3 (diff) | |
download | trackermap-server-d6c7cdf1e103c977ed94b737dc838d7ac22b9fa7.tar.gz trackermap-server-d6c7cdf1e103c977ed94b737dc838d7ac22b9fa7.tar.bz2 trackermap-server-d6c7cdf1e103c977ed94b737dc838d7ac22b9fa7.zip |
Optimize caching and class structure
Diffstat (limited to 'src/org/traccar/database/DriversManager.java')
-rw-r--r-- | src/org/traccar/database/DriversManager.java | 27 |
1 files changed, 2 insertions, 25 deletions
diff --git a/src/org/traccar/database/DriversManager.java b/src/org/traccar/database/DriversManager.java index 0dc2b102d..e3ae07a65 100644 --- a/src/org/traccar/database/DriversManager.java +++ b/src/org/traccar/database/DriversManager.java @@ -20,7 +20,6 @@ import java.sql.SQLException; import java.util.Map; import java.util.concurrent.ConcurrentHashMap; -import org.traccar.helper.Log; import org.traccar.model.Driver; import org.traccar.model.BaseModel; @@ -30,24 +29,6 @@ public class DriversManager extends ExtendedObjectManager { public DriversManager(DataManager dataManager) { super(dataManager, Driver.class); - refreshItems(); - refreshExtendedPermissions(); - } - - @Override - public void refreshItems() { - if (getDataManager() != null) { - try { - clearItems(); - for (BaseModel item : getDataManager().getObjects(getBaseClass())) { - putItem(item.getId(), item); - driversByUniqueId.put(((Driver) item).getUniqueId(), (Driver) item); - } - } catch (SQLException error) { - Log.warning(error); - } - } - refreshUserItems(); } @Override @@ -57,9 +38,8 @@ public class DriversManager extends ExtendedObjectManager { } @Override - public void updateItem(BaseModel item) throws SQLException { + protected void updateCachedItem(BaseModel item) { Driver driver = (Driver) item; - getDataManager().updateObject(driver); Driver cachedDriver = (Driver) getById(driver.getId()); cachedDriver.setName(driver.getName()); if (!driver.getUniqueId().equals(cachedDriver.getUniqueId())) { @@ -71,16 +51,13 @@ public class DriversManager extends ExtendedObjectManager { } @Override - public void removeItem(long driverId) throws SQLException { + protected void removeCachedItem(long driverId) { Driver cachedDriver = (Driver) getById(driverId); - getDataManager().removeObject(Driver.class, driverId); if (cachedDriver != null) { String driverUniqueId = cachedDriver.getUniqueId(); removeCachedItem(driverId); driversByUniqueId.remove(driverUniqueId); } - refreshUserItems(); - refreshExtendedPermissions(); } public Driver getDriverByUniqueId(String uniqueId) { |