Class WatchServiceSynchronizationStrategy

java.lang.Object
io.github.monsieurdoceo.filizer.storage.sync.strategy.WatchServiceSynchronizationStrategy
All Implemented Interfaces:
FileSynchronizationStrategy

public final class WatchServiceSynchronizationStrategy extends Object implements FileSynchronizationStrategy
Synchronizes files using the Java WatchService API.

This strategy is intended for environments where file changes should be detected by the operating system instead of polling the last modified timestamp.

Unlike LastModifiedStrategy, synchronization is event-driven. The watcher automatically reloads CustomFile instances whenever their backing files are modified.

  • Constructor Details

    • WatchServiceSynchronizationStrategy

      public WatchServiceSynchronizationStrategy()
      Creates a new WatchServiceSynchronizationStrategy instance.

      This class does not require custom initialization.

  • Method Details

    • synchronize

      public void synchronize(CustomFile file)
      Synchronizes the given file.

      No operation is required here because file synchronization is handled asynchronously by the WatchService.

      Specified by:
      synchronize in interface FileSynchronizationStrategy
      Parameters:
      file - the file to synchronize