Class MacOSXListeningWatchService

  • All Implemented Interfaces:
    java.io.Closeable, java.lang.AutoCloseable, java.nio.file.WatchService

    public class MacOSXListeningWatchService
    extends java.lang.Object
    This class contains the bulk of my implementation of the Watch Service API. It hooks into Carbon's File System Events API.
    • Constructor Detail

      • MacOSXListeningWatchService

        public MacOSXListeningWatchService()
    • Method Detail

      • register

        public io.methvin.watchservice.AbstractWatchKey register​(WatchablePath watchable,
                                                                 java.lang.Iterable<? extends java.nio.file.WatchEvent.Kind<?>> events)
                                                          throws java.io.IOException
        Registers the given watchable with this service, returning a new watch key for it. This implementation just checks that the service is open and creates a key; subclasses may override it to do other things as well.
        Throws:
        java.io.IOException
      • close

        public void close()
        Specified by:
        close in interface java.lang.AutoCloseable
        Specified by:
        close in interface java.io.Closeable
        Specified by:
        close in interface java.nio.file.WatchService
      • isOpen

        public boolean isOpen()
        Returns whether or not this watch service is open.
      • cancelled

        public void cancelled​(io.methvin.watchservice.AbstractWatchKey key)
        Called when the given key is cancelled. Does nothing by default.
      • poll

        public java.nio.file.WatchKey poll()
        Specified by:
        poll in interface java.nio.file.WatchService
      • poll

        public java.nio.file.WatchKey poll​(long timeout,
                                           java.util.concurrent.TimeUnit unit)
                                    throws java.lang.InterruptedException
        Specified by:
        poll in interface java.nio.file.WatchService
        Throws:
        java.lang.InterruptedException
      • take

        public java.nio.file.WatchKey take()
                                    throws java.lang.InterruptedException
        Specified by:
        take in interface java.nio.file.WatchService
        Throws:
        java.lang.InterruptedException
      • checkOpen

        protected final void checkOpen()
        Checks that the watch service is open, throwing ClosedWatchServiceException if not.