long lastModified = ((Long) app.redeployResources.get(resources[i])).longValue();
if ((!resource.isDirectory()) && resource.lastModified() > lastModified) {
// Undeploy application
if (log.isInfoEnabled())
log.info(sm.getString("hostConfig.undeploy", app.name));
ContainerBase context = (ContainerBase) host.findChild(app.name);
try {
host.removeChild(context);
} catch (Throwable t) {
log.warn(sm.getString
("hostConfig.context.remove", app.name), t);
}
try {
context.destroy();
} catch (Throwable t) {
log.warn(sm.getString
("hostConfig.context.destroy", app.name), t);
}
// Delete other redeploy resources
for (int j = i + 1; j < resources.length; j++) {
try {
File current = new File(resources[j]);
current = current.getCanonicalFile();
if ((current.getAbsolutePath().startsWith(appBase().getAbsolutePath() + File.separator))
|| (current.getAbsolutePath().startsWith(configBase().getAbsolutePath()))) {
if (log.isDebugEnabled())
log.debug("Delete " + current);
ExpandWar.delete(current);
}
} catch (IOException e) {
log.warn(sm.getString
("hostConfig.canonicalizing", app.name), e);
}
}
deployed.remove(app.name);
return;
}
} else {
// There is a chance the the resource was only missing
// temporarily eg renamed during a text editor save
try {
Thread.sleep(500);
} catch (InterruptedException e1) {
// Ignore
}
// Recheck the resource to see if it was really deleted
if (resource.exists()) {
continue;
}
long lastModified =
((Long) app.redeployResources.get(resources[i])).longValue();
if (lastModified == 0L) {
continue;
}
// Undeploy application
if (log.isInfoEnabled())
log.info(sm.getString("hostConfig.undeploy", app.name));
ContainerBase context = (ContainerBase) host.findChild(app.name);
try {
host.removeChild(context);
} catch (Throwable t) {
log.warn(sm.getString
("hostConfig.context.remove", app.name), t);
}
try {
context.destroy();
} catch (Throwable t) {
log.warn(sm.getString
("hostConfig.context.destroy", app.name), t);
}
// Delete all redeploy resources