From b562920831af4e3d37784cad85ed47e815eceb0a Mon Sep 17 00:00:00 2001 From: Rogiel Date: Mon, 26 Dec 2011 15:16:39 -0200 Subject: [PATCH] Implements better logging while loading ID cache --- .../service/database/AbstractDAO.java | 12 +++++++++++ .../game/world/CachedWorldIDService.java | 20 +++++++++++-------- 2 files changed, 24 insertions(+), 8 deletions(-) diff --git a/l2jserver2-common/src/main/java/com/l2jserver/service/database/AbstractDAO.java b/l2jserver2-common/src/main/java/com/l2jserver/service/database/AbstractDAO.java index ee3f3093d..116da18a1 100644 --- a/l2jserver2-common/src/main/java/com/l2jserver/service/database/AbstractDAO.java +++ b/l2jserver2-common/src/main/java/com/l2jserver/service/database/AbstractDAO.java @@ -205,5 +205,17 @@ public abstract class AbstractDAO, I extends ID> return database; } + /** + * Wraps the {@link Model} array into an more specific array + * + * @param objects + * the arrays of objects to be "casted" + * @return the wrapped array + */ protected abstract T[] wrap(Model... objects); + + @Override + public String toString() { + return this.getClass().getSimpleName(); + } } diff --git a/l2jserver2-gameserver/src/main/java/com/l2jserver/service/game/world/CachedWorldIDService.java b/l2jserver2-gameserver/src/main/java/com/l2jserver/service/game/world/CachedWorldIDService.java index cc36edfd7..1c442ebd1 100644 --- a/l2jserver2-gameserver/src/main/java/com/l2jserver/service/game/world/CachedWorldIDService.java +++ b/l2jserver2-gameserver/src/main/java/com/l2jserver/service/game/world/CachedWorldIDService.java @@ -35,6 +35,7 @@ import com.l2jserver.service.ServiceStartException; import com.l2jserver.service.ServiceStopException; import com.l2jserver.service.cache.Cache; import com.l2jserver.service.cache.CacheService; +import com.l2jserver.service.database.DataAccessObject; import com.l2jserver.service.database.DatabaseService; /** @@ -118,9 +119,9 @@ public class CachedWorldIDService extends AbstractService implements public void load() { log.debug("Loading IDs from database"); - load(characterDao.selectIDs()); - load(itemDao.selectIDs()); - load(npcDao.selectIDs()); + load(characterDao); + load(itemDao); + load(npcDao); loaded = true; } @@ -134,12 +135,15 @@ public class CachedWorldIDService extends AbstractService implements /** * Load the pre-existing ids * - * @param ids - * an collection of ids + * @param dao + * the {@link DataAccessObject} that gives access to the IDs */ - private void load(Collection> ids) { - Preconditions.checkNotNull(ids, "ids"); - log.info("Loading {} IDs", ids.size()); + private void load(DataAccessObject> dao) { + Preconditions.checkNotNull(dao, "dao"); + + final Collection> ids = dao.selectIDs(); + log.info("Loaded {} IDs from {}", ids.size(), dao); + for (final ObjectID id : ids) { log.debug("Loading {}", id); allocator.allocate(id.getID());