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

Print this page

        

@@ -30,11 +30,11 @@
 
 /**
  * Base implementation class for watch keys.
  */
 
-abstract class AbstractWatchKey extends WatchKey {
+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,10 +51,13 @@
     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,12 +64,13 @@
 
     // 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) {
+    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,10 +77,17 @@
     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,11 +184,11 @@
     }
 
     /**
      * WatchEvent implementation
      */
-    private static class Event<T> extends WatchEvent<T> {
+    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;