use of com.nabalive.application.core.util.FolderWatcher in project NabAlive by jcheype.
the class ApplicationGroovyLoader method init.
@PostConstruct
public void init() {
File scriptFolder = new File(APPS_FOLDER);
if (!scriptFolder.isDirectory()) {
throw new IllegalStateException("parameter \"apps.folder\" must point to a directory: " + APPS_FOLDER);
}
Runnable folderWatcher = new FolderWatcher(scriptFolder) {
@Override
protected void onChange(File file) {
logger.debug("FolderWatcher onChange: {}", file.getName());
if (!file.exists()) {
applicationManager.unRegisterByName(stripExtension(file.getName()));
return;
} else if (file.getName().endsWith(".zip")) {
try {
registerZip(file);
} catch (Exception e) {
logger.error("cannot load app: {}", file.getName(), e);
}
}
}
};
new Thread(folderWatcher).start();
}
Aggregations