class ConfigDispatcherFileWatcher extends AbstractWatchService {

    @Override
    protected void processWatchEvent(WatchEvent<?> event, Kind<?> kind, Path path) {
        if (kind == ENTRY_CREATE || kind == ENTRY_MODIFY) {
            File f = path.toFile();
            if (!f.isHidden() && f.getName().endsWith(".cfg")) {
                configDispatcher.processConfigFile(f);
            }
        } else if (kind == ENTRY_DELETE) {
            // Detect if a service specific configuration file was removed. We want to
            // notify the service in this case with an updated empty configuration.
            File configFile = path.toFile();
            if (configFile.isHidden() || configFile.isDirectory() || !configFile.getName().endsWith(".cfg")) {
                return;
            }
            configDispatcher.fileRemoved(configFile.getAbsolutePath());
        }
    }

    @Activate public  ConfigDispatcherFileWatcher(final @Reference ConfigDispatcher configDispatcher);

}