*/
private class ComponentMonitor implements Runnable {
public void run() {
try {
File [] jars = componentDirectory.listFiles(new FileFilter() {
public boolean accept(File pathname) {
String fileName = pathname.getName().toLowerCase();
return (fileName.endsWith(".jar") || fileName.endsWith(".war"));
}
});
for (int i=0; i<jars.length; i++) {
File jarFile = jars[i];
String componentName = jarFile.getName().substring(
0, jarFile.getName().length()-4).toLowerCase();
// See if the JAR has already been exploded.
File dir = new File(componentDirectory, componentName);
// If the JAR hasn't been exploded, do so.
if (!dir.exists()) {
unzipComponent(componentName, jarFile, dir);
}
// See if the JAR is newer than the directory. If so, the component
// needs to be unloaded and then reloaded.
else if (jarFile.lastModified() > dir.lastModified()) {
unloadComponent(componentName);
// Ask the system to clean up references.
System.gc();
while (!deleteDir(dir)) {
manager.getLog().error("Error unloading component " + componentName + ". " +
"Will attempt again momentarily.");
Thread.sleep(5000);
}
// Now unzip the component.
unzipComponent(componentName, jarFile, dir);
}
}
File [] dirs = componentDirectory.listFiles(new FileFilter() {
public boolean accept(File pathname) {
return pathname.isDirectory();
}
});