synchronized (this)
{
for (Enumeration e = this.cache.keys(); e.hasMoreElements();)
{
String key = (String) e.nextElement();
CachedObject co = (CachedObject) this.cache.get(key);
if (co instanceof RefreshableCachedObject)
{
RefreshableCachedObject rco = (RefreshableCachedObject) co;
if (rco.isUntouched())
{
this.cache.remove(key);
}
else if (rco.isStale())
{
// to prolong holding the lock on this object
refreshThese.add(key);
}
}
else if (co.isStale())
{
this.cache.remove(key);
}
}
}
for (Iterator i = refreshThese.iterator(); i.hasNext();)
{
String key = (String) i.next();
CachedObject co = (CachedObject) this.cache.get(key);
RefreshableCachedObject rco = (RefreshableCachedObject) co;
rco.refresh();
}
}