org.apache.commons.io.monitor

Class FileAlterationMonitor

  • All Implemented Interfaces:
    Runnable


    public final class FileAlterationMonitorextends Objectimplements Runnable
    A runnable that spawns a monitoring thread triggering any registered FileAlterationObserver at a specified interval.
    Since:
    2.0
    Version:
    $Id: FileAlterationMonitor.java 1415850 2012-11-30 20:51:39Z ggregory $
    See Also:
    FileAlterationObserver
    • Constructor Detail

      • FileAlterationMonitor

        public FileAlterationMonitor()
        Construct a monitor with a default interval of 10 seconds.
      • FileAlterationMonitor

        public FileAlterationMonitor(long interval)
        Construct a monitor with the specified interval.
        Parameters:
        interval - The amount of time in miliseconds to wait between checks of the file system
      • FileAlterationMonitor

        public FileAlterationMonitor(long interval,                     FileAlterationObserver... observers)
        Construct a monitor with the specified interval and set of observers.
        Parameters:
        interval - The amount of time in miliseconds to wait between checks of the file system
        observers - The set of observers to add to the monitor.
    • Method Detail

      • getInterval

        public long getInterval()
        Return the interval.
        Returns:
        the interval
      • setThreadFactory

        public void setThreadFactory(ThreadFactory threadFactory)
        Set the thread factory.
        Parameters:
        threadFactory - the thread factory
      • addObserver

        public void addObserver(FileAlterationObserver observer)
        Add a file system observer to this monitor.
        Parameters:
        observer - The file system observer to add
      • removeObserver

        public void removeObserver(FileAlterationObserver observer)
        Remove a file system observer from this monitor.
        Parameters:
        observer - The file system observer to remove
      • start

        public void start()           throws Exception
        Start monitoring.
        Throws:
        Exception - if an error occurs initializing the observer
      • stop

        public void stop()          throws Exception
        Stop monitoring.
        Throws:
        Exception - if an error occurs initializing the observer
      • stop

        public void stop(long stopInterval)          throws Exception
        Stop monitoring.
        Parameters:
        stopInterval - the amount of time in milliseconds to wait for the thread to finish. A value of zero will wait until the thread is finished (see Thread.join(long)).
        Throws:
        Exception - if an error occurs initializing the observer
        Since:
        2.1
      • run

        public void run()
        Run.
        Specified by:
        run in interface Runnable

Copyright © 2002–2016 The Apache Software Foundation. All rights reserved.



NOTHING
NOTHING
Add the Maven Dependecy to your project: maven dependecy for com.amazonaws : aws-java-sdk : 1.3.14