/** {@inheritDoc} */ @Override public void preDestroy() { super.preDestroy(); synchronized (lock) { try { if (fileAlterationMonitor != null) fileAlterationMonitor.stop(10); if (fileWatchListener != null) fileWatchListener.clear(); fileAlterationMonitor = null; fileWatchListener = null; } catch (Exception exc) { logger.error("Could not stop file monitor", exc); } } }
/** {@inheritDoc} */ @Override public void runPostProcessAction(ConfigurationSourceIdentifier configurationSourceIdentifier) { super.runPostProcessAction(configurationSourceIdentifier); Class<?> referenceClass = configurationSourceIdentifier.getReferenceClass(); String resourceName = getResourceName(configurationSourceIdentifier); try { File confFile = getConfigurationFile(referenceClass, resourceName); getFileWatchListener().addFile(confFile, configurationSourceIdentifier); } catch (ConfigurationException exc) { logger.warn("Could not add file to watch list: " + exc.getMessage()); if (logger.isTraceEnabled()) logger.trace(exc.getMessage(), exc); } }
/** {@inheritDoc} */ @Override public void postInit() { super.postInit(); synchronized (lock) { if (fileAlterationMonitor == null) { fileWatchListener = new FileWatchListener(ConfigurationUtilities.getInstance()); fileAlterationMonitor = new FileAlterationMonitor(); File confDir = getFilesystemConfiguration().getConfigurationDirectory(); FileAlterationObserver observer = new FileAlterationObserver(confDir); observer.addListener(getFileWatchListener()); fileAlterationMonitor.addObserver(observer); try { fileAlterationMonitor.start(); } catch (Exception exc) { logger.error("Could not start file monitor", exc); } } } }