src/share/classes/sun/nio/fs/AbstractWatchKey.java

Print this page

        

*** 30,40 **** /** * Base implementation class for watch keys. */ ! abstract class AbstractWatchKey extends WatchKey { /** * Maximum size of event list (in the future this may be tunable) */ static final int MAX_EVENT_LIST_SIZE = 512; --- 30,40 ---- /** * Base implementation class for watch keys. */ ! abstract class AbstractWatchKey implements WatchKey { /** * Maximum size of event list (in the future this may be tunable) */ static final int MAX_EVENT_LIST_SIZE = 512;
*** 51,60 **** --- 51,63 ---- private static enum State { READY, SIGNALLED }; // reference to watcher private final AbstractWatchService watcher; + // reference to the original directory + private final Path dir; + // key state private State state; // pending events private List<WatchEvent<?>> events;
*** 61,72 **** // maps a context to the last event for the context (iff the last queued // event for the context is an ENTRY_MODIFY event). private Map<Object,WatchEvent<?>> lastModifyEvents; ! protected AbstractWatchKey(AbstractWatchService watcher) { this.watcher = watcher; this.state = State.READY; this.events = new ArrayList<WatchEvent<?>>(); this.lastModifyEvents = new HashMap<Object,WatchEvent<?>>(); } --- 64,76 ---- // maps a context to the last event for the context (iff the last queued // event for the context is an ENTRY_MODIFY event). private Map<Object,WatchEvent<?>> lastModifyEvents; ! protected AbstractWatchKey(Path dir, AbstractWatchService watcher) { this.watcher = watcher; + this.dir = dir; this.state = State.READY; this.events = new ArrayList<WatchEvent<?>>(); this.lastModifyEvents = new HashMap<Object,WatchEvent<?>>(); }
*** 73,82 **** --- 77,93 ---- final AbstractWatchService watcher() { return watcher; } /** + * Return the original watchable (Path) + */ + Path watchable() { + return dir; + } + + /** * Enqueues this key to the watch service */ final void signal() { synchronized (this) { if (state == State.READY) {
*** 173,183 **** } /** * WatchEvent implementation */ ! private static class Event<T> extends WatchEvent<T> { private final WatchEvent.Kind<T> kind; private final T context; // synchronize on watch key to access/increment count private int count; --- 184,194 ---- } /** * WatchEvent implementation */ ! private static class Event<T> implements WatchEvent<T> { private final WatchEvent.Kind<T> kind; private final T context; // synchronize on watch key to access/increment count private int count;