Object key;
Iterator i;
for (i = entries.iterator(); i.hasNext();) {
Map.Entry entry = (Map.Entry) i.next();
key = entry.getKey();
SimpleSession session = (SimpleSession) entry.getValue();
if ((curTime - session.getLastAccessTime()) >
(session.getTimeout() * 1000)) {
log.debug(JavaUtils.getMessage("timeout00",
key.toString()));
// Don't modify the hashtable while we're iterating.
victims.add(key);
}
}
// Now go remove all the victims we found during the iteration.
for (i = victims.iterator(); i.hasNext();) {
key = i.next();
SimpleSession session = (SimpleSession)activeSessions.get(key);
activeSessions.remove(key);
// For each victim, swing through the data looking for
// ServiceLifecycle objects, and calling destroy() on them.
// FIXME : This cleanup should probably happen on another
// thread, as it might take a little while.
Enumeration keys = session.getKeys();
while (keys != null && keys.hasMoreElements()) {
String keystr = (String)keys.nextElement();
Object obj = session.get(keystr);
if (obj != null && obj instanceof ServiceLifecycle) {
((ServiceLifecycle)obj).destroy();
}
}
}