de.esprit.appsuite.nio.watcher

## Class PathWatcher

- java.lang.Object
- - de.esprit.common.util.DumpableObject
  - - de.esprit.appsuite.launch.AbstractApplicationObject<ApplicationContext>
    - - de.esprit.appsuite.nio.watcher.PathWatcher

- All Implemented Interfaces:
    ApplicationObject<ApplicationContext>, PathChangeEvent.Source, PathRegistrationEvent.Source, SimpleLogSupport, Dumpable, Resettable

      public final class PathWatcher
      extends AbstractApplicationObject<ApplicationContext>
      implements PathRegistrationEvent.Source, PathChangeEvent.Source, Resettable

  This class runs an internal `WatchService` on registered `Path`s. It has event-notification support for two change-informations.
  - `PathRegistrationEvent` is fired whenever a path was registered or deregistered on the watch-service
  - `PathChangeEvent` is fired whenever the watch-service has detected a file-system change in any of the watched paths.
  Author:
    Rainer Buesch

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `PathWatcher(ApplicationContext ctx)`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `addPathChangeListener(PathChangeEvent.Listener l)`
    `void` | `addPathRegistrationListener(PathRegistrationEvent.Listener l)`
    `void` | `deregisterPath(java.nio.file.Path path)` Deregister everything starting with this path.
    `protected void` | `fastRegisterPath(java.nio.file.Path path)`
    `BranchPathFilter` | `getPathFilter()`
    `java.util.Map<java.nio.file.Path,java.nio.file.WatchKey>` | `getWatchedPaths()`
    `boolean` | `isPathWatched(java.nio.file.Path path)`
    `boolean` | `isRunning()`
    `void` | `registerPath(java.nio.file.Path path)`
    `void` | `removePathChangeListener(PathChangeEvent.Listener l)`
    `void` | `removePathRegistrationListener(PathRegistrationEvent.Listener l)`
    `void` | `reset()` This method is called by the ResetButton on it's registered target.
    `void` | `setCustomFilter(PathFilter filter)` Sets a filter which allows paths to be excluded from watching.
    `void` | `setPermissionFilter(PathFilter filter)`
    `void` | `startWatchService()` Creates and starts a new watch-service as an inner task.
    `void` | `stopWatchService()` Stops the watch-service task.

    - ### Methods inherited from class de.esprit.appsuite.launch.AbstractApplicationObject

      `getApplicationContext, getLogChannel, isLogDebug, isLogVerbose, logDebug, logDump, logError, logError, logFatal, logInfo, logVerbose, logWarning, setLogChannel`

    - ### Methods inherited from class de.esprit.common.util.DumpableObject

      `configureDumpHeadlineLength, configureDumpMaxElementsPrinted, copyDumpStringValues, copyToStringValues, createDumpHeader, toDumpString, toDumpString, toString, toString`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

- - ### Constructor Detail

    - #### PathWatcher

          public PathWatcher(ApplicationContext ctx)

  - ### Method Detail

    - #### addPathRegistrationListener

          public void addPathRegistrationListener(PathRegistrationEvent.Listener l)

      Specified by:
        `addPathRegistrationListener` in interface `PathRegistrationEvent.Source`

    - #### removePathRegistrationListener

          public void removePathRegistrationListener(PathRegistrationEvent.Listener l)

      Specified by:
        `removePathRegistrationListener` in interface `PathRegistrationEvent.Source`

    - #### addPathChangeListener

          public void addPathChangeListener(PathChangeEvent.Listener l)

      Specified by:
        `addPathChangeListener` in interface `PathChangeEvent.Source`

    - #### removePathChangeListener

          public void removePathChangeListener(PathChangeEvent.Listener l)

      Specified by:
        `removePathChangeListener` in interface `PathChangeEvent.Source`

    - #### reset

          public void reset()

      Description copied from interface: `Resettable`
      This method is called by the ResetButton on it's registered target.
      Specified by:
        `reset` in interface `Resettable`

    - #### startWatchService

          public void startWatchService()

      Creates and starts a new watch-service as an inner task.

    - #### isRunning

          public boolean isRunning()

    - #### stopWatchService

          public void stopWatchService()

      Stops the watch-service task. All watched paths are deregistered and the file-system is not observed any more.

    - #### registerPath

          public void registerPath(java.nio.file.Path path)

    - #### getWatchedPaths

          public java.util.Map<java.nio.file.Path,java.nio.file.WatchKey> getWatchedPaths()

    - #### fastRegisterPath

          protected void fastRegisterPath(java.nio.file.Path path)
                                   throws java.io.IOException

      Throws:
        `java.io.IOException`

    - #### deregisterPath

          public void deregisterPath(java.nio.file.Path path)

      Deregister everything starting with this path.

    - #### isPathWatched

          public boolean isPathWatched(java.nio.file.Path path)

    - #### setCustomFilter

          public final void setCustomFilter(PathFilter filter)

      Sets a filter which allows paths to be excluded from watching.

    - #### setPermissionFilter

          public final void setPermissionFilter(PathFilter filter)

    - #### getPathFilter

          public final BranchPathFilter getPathFilter()

Copyright © 2014 EsprIT-Systems. All Rights Reserved.