org.eclipse.jetty.util

## Class Scanner

- java.lang.Object
- - org.eclipse.jetty.util.component.AbstractLifeCycle
  - - org.eclipse.jetty.util.Scanner

- All Implemented Interfaces:
    LifeCycle

      public class Scanner
      extends AbstractLifeCycle

  Scanner Utility for scanning a directory for added, removed and changed files and reporting these events via registered Listeners.

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class and Description
    --- | ---
    `static interface` | `Scanner.BulkListener`
    `static interface` | `Scanner.DiscreteListener`
    `static interface` | `Scanner.Listener` Listener Marker for notifications re file changes.
    `static class` | `Scanner.Notification`
    `static interface` | `Scanner.ScanCycleListener` Listener that notifies when a scan has started and when it has ended.
    `static interface` | `Scanner.ScanListener`

    - ### Nested classes/interfaces inherited from class org.eclipse.jetty.util.component.AbstractLifeCycle

      `AbstractLifeCycle.AbstractLifeCycleListener`

  - ### Field Summary

    - ### Fields inherited from class org.eclipse.jetty.util.component.AbstractLifeCycle

      `FAILED, RUNNING, STARTED, STARTING, STOPPED, STOPPING`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `Scanner()`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `addListener(Scanner.Listener listener)` Add an added/removed/changed listener
    `void` | `addScanDir(File dir)`
    `void` | `doStart()` Start the scanning action.
    `void` | `doStop()` Stop the scanning.
    `FilenameFilter` | `getFilenameFilter()` Get any filter applied to files in the scan dir.
    `boolean` | `getRecursive()`
    `boolean` | `getReportDirs()`
    `boolean` | `getReportExistingFilesOnStartup()`
    `int` | `getScanDepth()` Get the scanDepth.
    `File` | `getScanDir()` Deprecated. use getScanDirs() instead
    `List<File>` | `getScanDirs()`
    `int` | `getScanInterval()` Get the scan interval
    `Timer` | `newTimer()`
    `TimerTask` | `newTimerTask()`
    `void` | `removeListener(Scanner.Listener listener)` Remove a registered listener
    `void` | `reportDifferences(Map<String,org.eclipse.jetty.util.Scanner.TimeNSize> currentScan, Map<String,org.eclipse.jetty.util.Scanner.TimeNSize> oldScan)` Report the adds/changes/removes to the registered listeners
    `void` | `scan()` Perform a pass of the scanner and report changes
    `void` | `scanFiles()` Recursively scan all files in the designated directories.
    `void` | `schedule()`
    `void` | `setFilenameFilter(FilenameFilter filter)` Apply a filter to files found in the scan directory.
    `void` | `setRecursive(boolean recursive)`
    `void` | `setReportDirs(boolean dirs)` Set if found directories should be reported.
    `void` | `setReportExistingFilesOnStartup(boolean reportExisting)` Whether or not an initial scan will report all files as being added.
    `void` | `setScanDepth(int scanDepth)` Set the scanDepth.
    `void` | `setScanDir(File dir)` Deprecated. use setScanDirs(List dirs) instead
    `void` | `setScanDirs(List<File> dirs)`
    `void` | `setScanInterval(int scanInterval)` Set the scan interval

    - ### Methods inherited from class org.eclipse.jetty.util.component.AbstractLifeCycle

      `addLifeCycleListener, getState, getState, isFailed, isRunning, isStarted, isStarting, isStopped, isStopping, removeLifeCycleListener, start, stop`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### Scanner

          public Scanner()

  - ### Method Detail

    - #### getScanInterval

          public int getScanInterval()

      Get the scan interval
      Returns:
        interval between scans in seconds

    - #### setScanInterval

          public void setScanInterval(int scanInterval)

      Set the scan interval
      Parameters:
        `scanInterval` - pause between scans in seconds, or 0 for no scan after the initial scan.

    - #### setScanDir

          @Deprecated
          public void setScanDir(File dir)

      Deprecated. use setScanDirs(List dirs) instead
      Set the location of the directory to scan.
      Parameters:
        `dir` -

    - #### getScanDir

          @Deprecated
          public File getScanDir()

      Deprecated. use getScanDirs() instead
      Get the location of the directory to scan
      Returns:
        the first directory (of `getScanDirs()` being scanned)

    - #### setScanDirs

          public void setScanDirs(List<File> dirs)

    - #### addScanDir

          public void addScanDir(File dir)

    - #### getScanDirs

          public List<File> getScanDirs()

    - #### setRecursive

          public void setRecursive(boolean recursive)

      Parameters:
        `recursive` - True if scanning is recursive
      See Also:
        `setScanDepth(int)`

    - #### getRecursive

          public boolean getRecursive()

      Returns:
        True if scanning is fully recursive (scandepth==-1)
      See Also:
        `getScanDepth()`

    - #### getScanDepth

          public int getScanDepth()

      Get the scanDepth.
      Returns:
        the scanDepth

    - #### setScanDepth

          public void setScanDepth(int scanDepth)

      Set the scanDepth.
      Parameters:
        `scanDepth` - the scanDepth to set

    - #### setFilenameFilter

          public void setFilenameFilter(FilenameFilter filter)

      Apply a filter to files found in the scan directory. Only files matching the filter will be reported as added/changed/removed.
      Parameters:
        `filter` -

    - #### getFilenameFilter

          public FilenameFilter getFilenameFilter()

      Get any filter applied to files in the scan dir.
      Returns:
        the filename filter

    - #### setReportExistingFilesOnStartup

          public void setReportExistingFilesOnStartup(boolean reportExisting)

      Whether or not an initial scan will report all files as being added.
      Parameters:
        `reportExisting` - if true, all files found on initial scan will be reported as being added, otherwise not

    - #### getReportExistingFilesOnStartup

          public boolean getReportExistingFilesOnStartup()

    - #### setReportDirs

          public void setReportDirs(boolean dirs)

      Set if found directories should be reported.
      Parameters:
        `dirs` -

    - #### getReportDirs

          public boolean getReportDirs()

    - #### addListener

          public void addListener(Scanner.Listener listener)

      Add an added/removed/changed listener
      Parameters:
        `listener` -

    - #### removeListener

          public void removeListener(Scanner.Listener listener)

      Remove a registered listener
      Parameters:
        `listener` - the Listener to be removed

    - #### doStart

          public void doStart()

      Start the scanning action.
      Overrides:
        `doStart` in class `AbstractLifeCycle`

    - #### newTimerTask

          public TimerTask newTimerTask()

    - #### newTimer

          public Timer newTimer()

    - #### schedule

          public void schedule()

    - #### doStop

          public void doStop()

      Stop the scanning.
      Overrides:
        `doStop` in class `AbstractLifeCycle`

    - #### scan

          public void scan()

      Perform a pass of the scanner and report changes

    - #### scanFiles

          public void scanFiles()

      Recursively scan all files in the designated directories.

    - #### reportDifferences

          public void reportDifferences(Map<String,org.eclipse.jetty.util.Scanner.TimeNSize> currentScan,
                               Map<String,org.eclipse.jetty.util.Scanner.TimeNSize> oldScan)

      Report the adds/changes/removes to the registered listeners
      Parameters:
        `currentScan` - the info from the most recent pass
        `oldScan` - info from the previous pass

Copyright © 1995-2012 Mort Bay Consulting. All Rights Reserved.