/** * This will install the {@code listener} at the given {@code file}. * * @param file The FileObject to listen on. * @param listener The FileListener */ public static void installListener(final FileObject file, final FileListener listener) { final WeakRefFileListener weakListener = new WeakRefFileListener(file, listener); file.getFileSystem().addListener(file, new WeakRefFileListener(file, weakListener)); }
/** * This will install the {@code listener} at the given {@code file}. * @param file The FileObject to listen on. * @param listener The FileListener */ public static void installListener(final FileObject file, final FileListener listener) { final WeakRefFileListener weakListener = new WeakRefFileListener(file, listener); file.getFileSystem().addListener(file, new WeakRefFileListener(file, weakListener)); }
/** * This will install the {@code listener} at the given {@code file}. * * @param file The FileObject to listen on. * @param listener The FileListener */ public static void installListener(final FileObject file, final FileListener listener) { final WeakRefFileListener weakListener = new WeakRefFileListener(file, listener); file.getFileSystem().addListener(file, new WeakRefFileListener(file, weakListener)); }
/** * This will install the {@code listener} at the given {@code file}. * * @param file The FileObject to listen on. * @param listener The FileListener */ public static void installListener(final FileObject file, final FileListener listener) { final WeakRefFileListener weakListener = new WeakRefFileListener(file, listener); file.getFileSystem().addListener(file, new WeakRefFileListener(file, weakListener)); }
/** * Adds a file to be monitored. * * @param file The FileObject to add. */ private void doAddFile(final FileObject file) { synchronized (this.monitorMap) { if (this.monitorMap.get(file.getName()) == null) { this.monitorMap.put(file.getName(), new FileMonitorAgent(this, file)); try { if (this.listener != null) { file.getFileSystem().addListener(file, this.listener); } if (file.getType().hasChildren() && this.recursive) { // Traverse the children final FileObject[] children = file.getChildren(); for (final FileObject element : children) { this.addFile(element); // Add depth first } } } catch (final FileSystemException fse) { LOG.error(fse.getLocalizedMessage(), fse); } } } }
/** * Adds a file to be monitored. * * @param file The FileObject to add. */ private void doAddFile(final FileObject file) { synchronized (this.monitorMap) { if (this.monitorMap.get(file.getName()) == null) { this.monitorMap.put(file.getName(), new FileMonitorAgent(this, file)); try { if (this.listener != null) { file.getFileSystem().addListener(file, this.listener); } if (file.getType().hasChildren() && this.recursive) { // Traverse the children final FileObject[] children = file.getChildren(); for (final FileObject element : children) { this.addFile(element); // Add depth first } } } catch (final FileSystemException fse) { LOG.error(fse.getLocalizedMessage(), fse); } } } }
/** * Adds a file to be monitored. * * @param file The FileObject to add. */ private void doAddFile(final FileObject file) { synchronized (this.monitorMap) { if (this.monitorMap.get(file.getName()) == null) { this.monitorMap.put(file.getName(), new FileMonitorAgent(this, file)); try { if (this.listener != null) { file.getFileSystem().addListener(file, this.listener); } if (file.getType().hasChildren() && this.recursive) { // Traverse the children final FileObject[] children = file.getChildren(); for (final FileObject element : children) { this.addFile(element); // Add depth first } } } catch (final FileSystemException fse) { LOG.error(fse.getLocalizedMessage(), fse); } } } }
file.getFileSystem().addListener(file, this.listener);
@Override public VersionedProperties read(final PropertiesWatcher watcher) throws IOException { final FileObject latest = getLatest(parentDirObj); final int ver = latest == null ? -1 : getVersion(latest); final VersionedProperties ret = new VersionedProperties(ver, Utils.read(latest)); if (watcher != null) { // if there's a watcher .... final FileObject next = nextFile(latest, parentDirObj); final Proxy proxy = new Proxy(next, watcher); next.getFileSystem().addListener(next, proxy); // but now, if the file exists due to a race condition, lets at least address that. if (next.exists()) proxy.doIt(); } return ret; }
/** * Recursively fires create events for all children if recursive descent is enabled. Otherwise the create event * is only fired for the initial FileObject. * * @param child The child to add. */ private void fireAllCreate(final FileObject child) { // Add listener so that it can be triggered if (this.fm.getFileListener() != null) { child.getFileSystem().addListener(child, this.fm.getFileListener()); } ((AbstractFileSystem) child.getFileSystem()).fireFileCreated(child); // Remove it because a listener is added in the queueAddFile if (this.fm.getFileListener() != null) { child.getFileSystem().removeListener(child, this.fm.getFileListener()); } this.fm.queueAddFile(child); // Add try { if (this.fm.isRecursive() && child.getType().hasChildren()) { final FileObject[] newChildren = child.getChildren(); for (final FileObject element : newChildren) { fireAllCreate(element); } } } catch (final FileSystemException fse) { LOG.error(fse.getLocalizedMessage(), fse); } }
/** * Recursively fires create events for all children if recursive descent is enabled. Otherwise the create event * is only fired for the initial FileObject. * * @param child The child to add. */ private void fireAllCreate(final FileObject child) { // Add listener so that it can be triggered if (this.fm.getFileListener() != null) { child.getFileSystem().addListener(child, this.fm.getFileListener()); } ((AbstractFileSystem) child.getFileSystem()).fireFileCreated(child); // Remove it because a listener is added in the queueAddFile if (this.fm.getFileListener() != null) { child.getFileSystem().removeListener(child, this.fm.getFileListener()); } this.fm.queueAddFile(child); // Add try { if (this.fm.isRecursive() && child.getType().hasChildren()) { final FileObject[] newChildren = child.getChildren(); for (final FileObject element : newChildren) { fireAllCreate(element); } } } catch (final FileSystemException fse) { LOG.error(fse.getLocalizedMessage(), fse); } }
/** * Recursively fires create events for all children if recursive descent is enabled. Otherwise the create event * is only fired for the initial FileObject. * * @param child The child to add. */ private void fireAllCreate(final FileObject child) { // Add listener so that it can be triggered if (this.fm.getFileListener() != null) { child.getFileSystem().addListener(child, this.fm.getFileListener()); } ((AbstractFileSystem) child.getFileSystem()).fireFileCreated(child); // Remove it because a listener is added in the queueAddFile if (this.fm.getFileListener() != null) { child.getFileSystem().removeListener(child, this.fm.getFileListener()); } this.fm.queueAddFile(child); // Add try { if (this.fm.isRecursive() && child.getType().hasChildren()) { final FileObject[] newChildren = child.getChildren(); for (final FileObject element : newChildren) { fireAllCreate(element); } } } catch (final FileSystemException fse) { LOG.error(fse.getLocalizedMessage(), fse); } }
child.getFileSystem().addListener(child, this.fm.getFileListener());
fs.addListener(child, listener); try {
fs.addListener(child, listener); try {
fs.addListener(child, listener); try