Class FilesWatcher

  • All Implemented Interfaces:
    Loggable

    public class FilesWatcher
    extends Object
    implements Loggable
    Watches for changes in files.
    • Field Detail

      • TEAMCITY_FILES_WATCHER_INIT_STATE_DELAY_PROP

        public static final String TEAMCITY_FILES_WATCHER_INIT_STATE_DELAY_PROP
        See Also:
        Constant Field Values
    • Method Detail

      • changesDetected

        public boolean changesDetected()
        Computes whether files state has been changed.
        Returns:
        true if files changes and false otherwise
      • getNewFiles

        @NotNull
        public List<File> getNewFiles()
        Returns files detected as new
        Returns:
        new files
      • getRemovedFiles

        @NotNull
        public List<File> getRemovedFiles()
        Returns files detected as removed
        Returns:
        removed files
      • getModifiedFiles

        @NotNull
        public List<File> getModifiedFiles()
        Returns modified files
        Returns:
        modified files
      • describe

        @NotNull
        public String describe​(boolean verbose)
        Specified by:
        describe in interface Loggable
        Parameters:
        verbose - verbosity of object description
        Returns:
        description of this object. If verbose is true, description should have mode details.
      • registerListener

        public void registerListener​(@NotNull
                                     FileWatcherListener listener)
        Registers FileWatcherListener
        Parameters:
        listener - ChangeListener
        Since:
        10.0
      • unregisterListener

        public void unregisterListener​(@NotNull
                                       FileWatcherListener listener)
        Removes previously registered listener
        Since:
        10.0
      • start

        public void start()
        Starts observer, should be called only once
      • stop

        public void stop()
        Stops observer
      • setSleepingPeriod

        public void setSleepingPeriod​(long time)
        Sets sleeping period in this observer. The observer should be restarted after this.
        Parameters:
        time - sleeping period
      • getSleepingPeriod

        public long getSleepingPeriod()
        Returns sleeping period
        Returns:
        sleeping period
      • runActionWithDisabledObserver

        public void runActionWithDisabledObserver​(@NotNull
                                                  Runnable runnable)
        Runs the specified runnable with paused changes watcher thread. After the runnable finishes the watcher will be activated.
        Parameters:
        runnable - runnable
      • checkForModifications

        public boolean checkForModifications()
        Performs unscheduled checking for modifications.
      • detectChanges

        @Nullable
        protected FilesState detectChanges()
        Returns:
        null if no changes detected or current files state if changes were detected
      • shutdownAll

        public static void shutdownAll()
        Shutdowns internal executor service
      • isStarted

        public boolean isStarted()
        Returns:
        true if this files watcher is started
        Since:
        10.0
      • waitForReadyState

        public void waitForReadyState()
        Since:
        10.0