* @param container the container to monitor.
*/
protected void checkContainer(final EZBContainer container) {
// get archive
IArchive archive = container.getArchive();
// Get URL
URL url = null;
try {
url = archive.getURL();
} catch (ArchiveException e1) {
this.logger.warn("Cannot get URL on the container {0}", archive.getName());
return;
}
File file = urlToFile(url);
// No file archive, means that it has been removed
if (!file.exists()) {
this.logger.info("Archive ''{0}'' has been removed, then the associated EJB3 container is stopping", archive
.getName());
try {
container.stop();
getEmbedded().removeContainer(container);
} finally {
this.deployed.remove(file);
}
return;
}
// container was modified, need to relaunch it
if (hasBeenUpdated(file)) {
this.logger.info("Container with archive {0} was modified. Reloading...", archive.getName());
try {
container.stop();
getEmbedded().removeContainer(container);
} finally {
this.deployed.remove(file);
}
try {
container.start();
getEmbedded().addContainer(container);
} catch (EZBContainerException e) {
this.deployed.remove(file);
this.logger.error("Error while restarting archive {0}.", archive.getName(), e);
}
}
}