Methods Summary |
---|
protected void | addWarInfo(java.io.File warfile)add cluster war to the watcher state
WarInfo info = (WarInfo) currentStatus.get(warfile.getAbsolutePath());
if (info == null) {
info = new WarInfo(warfile);
info.setLastState(-1); //assume file is non existent
currentStatus.put(warfile.getAbsolutePath(), info);
}
|
public void | check()check for modification and send notifcation to listener
if (log.isInfoEnabled())
log.info("check cluster wars at " + watchDir);
File[] list = watchDir.listFiles(new WarFilter());
if (list == null)
list = new File[0];
//first make sure all the files are listed in our current status
for (int i = 0; i < list.length; i++) {
addWarInfo(list[i]);
}
//check all the status codes and update the FarmDeployer
for (Iterator i = currentStatus.entrySet().iterator(); i.hasNext();) {
Map.Entry entry = (Map.Entry) i.next();
WarInfo info = (WarInfo) entry.getValue();
int check = info.check();
if (check == 1) {
listener.fileModified(info.getWar());
} else if (check == -1) {
listener.fileRemoved(info.getWar());
//no need to keep in memory
currentStatus.remove(info.getWar());
}
}
|
public void | clear()clear watcher state
currentStatus.clear();
|
public FileChangeListener | getListener()
return listener;
|
public java.io.File | getWatchDir()
return watchDir;
|
public void | setListener(FileChangeListener listener)
this.listener = listener;
|
public void | setWatchDir(java.io.File watchDir)
this.watchDir = watchDir;
|