Class FileSystemWatcher

All Implemented Interfaces:
Iterable<ComponentType>, Channel, ComponentType, Eligible, Manager

public class FileSystemWatcher extends Component
A component that watches paths in the file system for changes and sends events if such changes occur.
  • Field Details

  • Constructor Details

    • FileSystemWatcher

      Creates a new component base with its channel set to itself.
    • FileSystemWatcher

      public FileSystemWatcher(Channel componentChannel)
      Creates a new component base with its channel set to the given channel.

      As a special case Channel.SELF can be passed to the constructor to make the component use itself as channel. The special value is necessary as you obviously cannot pass an object to be constructed to its constructor.

      Parameters:
      componentChannel - the channel that the component’s handlers listen on by default and that Manager.fire(Event, Channel...) sends the event to
  • Method Details

    • onWatchFile

      @Handler public void onWatchFile(WatchFile event, Channel channel) throws IOException
      Register a path to wath.

      Subsequent FileChanged events will be fire on the channel(s) on which the WatchFile event was fired.

      The channel is stored using a weak reference, so no explicit “clear watch” is required.

      Parameters:
      event - the event
      channel - the channel
      Throws:
      IOException - if an I/O exception occurs