This method gets called from the monitor thread. This goes through
all the monitored entried and checks the time stamps. If any of the
time stamps is modified, it makes a callback to its listener. The
callbacks are single threaded, i.e., waits for one to finish before
makes the second call.
The time stamp of the monitored entry is set to the current
time stamp before the callback is made.
try {
ArrayList reloadList = new ArrayList();
synchronized (_monitoredEntries) {
Iterator iter = _monitoredEntries.iterator();
MonitorableEntry entry = null;
while (iter.hasNext()) {
entry = (MonitorableEntry) iter.next();
File file = entry.getMonitoredFile();
long lastModified = file.lastModified();
long lastReloadedAt = entry.getLastReloadedTimeStamp();
// time stamp is updated
if (lastModified > lastReloadedAt) {
// sets the time stamp so that it gets called once
entry.setLastReloadedTimeStamp(lastModified);
reloadList.add(entry);
}
}
}
// found some entries with modified time stamp
if (reloadList.size() > 0) {
_logger.log(Level.FINEST,
"[ReloadMonitor] Monitor detected reloadable entry!");
int size = reloadList.size();
MonitorableEntry entry = null;
for (int i=0; i<size; i++) {
entry = (MonitorableEntry) reloadList.get(i);
MonitorListener l = entry.getListener();
// calls back the listener
boolean success = l.reload(entry);
// log status
if (success) {
_logger.log(Level.INFO,
"core.application_reload_successful",
entry.getDisplayName());
} else {
_logger.log(Level.INFO,
"core.application_reload_failed",
entry.getDisplayName());
}
}
// Reload the web modules
/*
* Remove compile time dependence on J2EERunner. Replace it
* temporarily with call to ReconfigHelper.
J2EERunner.requestReconfiguration();
*/
ReconfigHelper.sendReconfigMessage("");
// removes all the entries after the call back
reloadList.clear();
}
} catch (Throwable t) {
// catches any uncaught exceptions thrown from the handlers
_logger.log(Level.WARNING, "core.exception", t);
}