Verified Owner
Top Description Fields Constructors Methods
org.jabref.gui.util

public Class DefaultFileUpdateMonitor

extends Object
implements Runnable, FileUpdateMonitor
Class Inheritance
All Implemented Interfaces
java.lang.Runnable
Imports
java.io.IOException, java.nio.file.ClosedWatchServiceException, .FileSystems, .Path, .StandardWatchEventKinds, .WatchEvent, .WatchKey, .WatchService, java.util.List, .Optional, java.util.concurrent.atomic.AtomicBoolean, .AtomicReference, org.jabref.logic.JabRefException, .WatchServiceUnavailableException, org.jabref.model.util.FileUpdateListener, .FileUpdateMonitor, com.google.common.collect.ArrayListMultimap, .Multimap, org.slf4j.Logger, .LoggerFactory

This class monitors a set of files for changes. Upon detecting a change it notifies the registered FileUpdateListeners.

Implementation based on https://stackoverflow.com/questions/16251273/can-i-watch-for-single-file-change-with-watchservice-not-the-whole-directory.

Field Summary

Modifier and TypeField and Description
private final AtomicReference<Optional<JabRefException>>
private final Multimap<Path, FileUpdateListener>
private static final Logger
private final AtomicBoolean
private volatile WatchService

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public void
public boolean
private void
public void
public void
run()

Implements java.lang.Runnable.run.

Runs this operation.

public void
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

filesystemMonitorFailureback to summary
private final AtomicReference<Optional<JabRefException>> filesystemMonitorFailure
listenersback to summary
private final Multimap<Path, FileUpdateListener> listeners
LOGGERback to summary
private static final Logger LOGGER
notShutdownback to summary
private final AtomicBoolean notShutdown
watcherback to summary
private volatile WatchService watcher

Constructor Detail

DefaultFileUpdateMonitorback to summary
public DefaultFileUpdateMonitor()

Method Detail

addListenerForFileback to summary
public void addListenerForFile(Path file, FileUpdateListener listener) throws IOException
Annotations
@Override
isActiveback to summary
public boolean isActive()
Annotations
@Override
notifyAboutChangeback to summary
private void notifyAboutChange(Path path)
removeListenerback to summary
public void removeListener(Path path, FileUpdateListener listener)
Annotations
@Override
runback to summary
public void run()

Implements java.lang.Runnable.run.

Doc from java.lang.Runnable.run.

Runs this operation.

Annotations
@Override
shutdownback to summary
public void shutdown()
Annotations
@Override