Class FileWatchdog

  • All Implemented Interfaces:
    java.lang.Runnable

    public abstract class FileWatchdog
    extends java.lang.Thread
    Check every now and then that a certain file has not changed. If it has, then call the doOnChange() method.
    Since:
    version 0.9.1
    Author:
    Ceki Gülcü
    • Nested Class Summary

      • Nested classes/interfaces inherited from class java.lang.Thread

        java.lang.Thread.State, java.lang.Thread.UncaughtExceptionHandler
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static long DEFAULT_DELAY
      The default delay between every file modification check, set to 60 seconds.
      protected long delay
      The delay to observe between every check.
      protected java.lang.String filename
      The name of the file to observe for changes.
      • Fields inherited from class java.lang.Thread

        MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      protected FileWatchdog​(java.lang.String filename)  
    • Method Summary

      All Methods Instance Methods Abstract Methods Concrete Methods 
      Modifier and Type Method Description
      protected void checkAndConfigure()  
      protected abstract void doOnChange()  
      void run()  
      void setDelay​(long delay)
      Set the delay to observe between each check of the file changes.
      • Methods inherited from class java.lang.Thread

        activeCount, checkAccess, clone, countStackFrames, currentThread, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, onSpinWait, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, suspend, toString, yield
      • Methods inherited from class java.lang.Object

        equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Field Detail

      • DEFAULT_DELAY

        public static final long DEFAULT_DELAY
        The default delay between every file modification check, set to 60 seconds.
        See Also:
        Constant Field Values
      • filename

        protected java.lang.String filename
        The name of the file to observe for changes.
      • delay

        protected long delay
        The delay to observe between every check. By default set DEFAULT_DELAY.
    • Constructor Detail

      • FileWatchdog

        protected FileWatchdog​(java.lang.String filename)
    • Method Detail

      • setDelay

        public void setDelay​(long delay)
        Set the delay to observe between each check of the file changes.
      • doOnChange

        protected abstract void doOnChange()
      • checkAndConfigure

        protected void checkAndConfigure()
      • run

        public void run()
        Specified by:
        run in interface java.lang.Runnable
        Overrides:
        run in class java.lang.Thread