WatcherThread(File dir, WatcherSensitivity s) throws Exception { watchService = FileSystems.getDefault().newWatchService(); WatchEvent.Kind<?>[] kinds = new WatchEvent.Kind[]{ENTRY_CREATE, ENTRY_DELETE, ENTRY_MODIFY}; WatchEvent.Modifier modifier = lookupModifier(s); dir.toPath().register(watchService, kinds, modifier); }
/** * Constructor. * * @param ps The settings for this content store. */ protected ConfigFileStore(PropertyStore ps) { super(ps); try { dir = new File(getStringProperty(FILESTORE_directory, ".")).getCanonicalFile(); dir.mkdirs(); charset = getProperty(FILESTORE_charset, Charset.class, Charset.defaultCharset()); updateOnWrite = getBooleanProperty(FILESTORE_updateOnWrite, false); extensions = getArrayProperty(FILESTORE_extensions, String.class, new String[]{"cfg"}); WatcherSensitivity ws = getProperty(FILESTORE_watcherSensitivity, WatcherSensitivity.class, WatcherSensitivity.MEDIUM); watcher = getBooleanProperty(FILESTORE_useWatcher, false) ? new WatcherThread(dir, ws) : null; if (watcher != null) watcher.start(); } catch (Exception e) { throw new RuntimeException(e); } }
/** * Constructor. * * @param ps The settings for this content store. */ protected ConfigFileStore(PropertyStore ps) { super(ps); try { dir = new File(getStringProperty(FILESTORE_directory, ".")).getCanonicalFile(); dir.mkdirs(); charset = getProperty(FILESTORE_charset, Charset.class, Charset.defaultCharset()); updateOnWrite = getBooleanProperty(FILESTORE_updateOnWrite, false); extensions = getArrayProperty(FILESTORE_extensions, String.class, new String[]{"cfg"}); WatcherSensitivity ws = getProperty(FILESTORE_watcherSensitivity, WatcherSensitivity.class, WatcherSensitivity.MEDIUM); watcher = getBooleanProperty(FILESTORE_useWatcher, false) ? new WatcherThread(dir, ws) : null; if (watcher != null) watcher.start(); } catch (Exception e) { throw new RuntimeException(e); } }
/** * Constructor. * * @param ps The settings for this content store. */ protected ConfigFileStore(PropertyStore ps) { super(ps); try { dir = new File(getStringProperty(FILESTORE_directory, ".")).getCanonicalFile(); dir.mkdirs(); charset = getProperty(FILESTORE_charset, Charset.class, Charset.defaultCharset()); updateOnWrite = getBooleanProperty(FILESTORE_updateOnWrite, false); WatcherSensitivity ws = getProperty(FILESTORE_watcherSensitivity, WatcherSensitivity.class, WatcherSensitivity.MEDIUM); watcher = getBooleanProperty(FILESTORE_useWatcher, false) ? new WatcherThread(dir, ws) : null; if (watcher != null) watcher.start(); } catch (Exception e) { throw new RuntimeException(e); } }
@Override /* Closeable */ public synchronized void close() { if (watcher != null) watcher.interrupt(); }
WatcherThread(File dir, WatcherSensitivity s) throws Exception { watchService = FileSystems.getDefault().newWatchService(); WatchEvent.Kind<?>[] kinds = new WatchEvent.Kind[]{ENTRY_CREATE, ENTRY_DELETE, ENTRY_MODIFY}; WatchEvent.Modifier modifier = lookupModifier(s); dir.toPath().register(watchService, kinds, modifier); }
WatcherThread(File dir, WatcherSensitivity s) throws Exception { watchService = FileSystems.getDefault().newWatchService(); WatchEvent.Kind<?>[] kinds = new WatchEvent.Kind[]{ENTRY_CREATE, ENTRY_DELETE, ENTRY_MODIFY}; WatchEvent.Modifier modifier = lookupModifier(s); dir.toPath().register(watchService, kinds, modifier); }
@Override /* Closeable */ public synchronized void close() { if (watcher != null) watcher.interrupt(); }
@Override /* Closeable */ public synchronized void close() { if (watcher != null) watcher.interrupt(); }