Search in sources :

Example 1 with FolderWatcher

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();
}
Also used : File(java.io.File) BeansException(org.springframework.beans.BeansException) IOException(java.io.IOException) FolderWatcher(com.nabalive.application.core.util.FolderWatcher) PostConstruct(javax.annotation.PostConstruct)

Aggregations

FolderWatcher (com.nabalive.application.core.util.FolderWatcher)1 File (java.io.File)1 IOException (java.io.IOException)1 PostConstruct (javax.annotation.PostConstruct)1 BeansException (org.springframework.beans.BeansException)1