Class VFSFileChangedReloadingStrategy

java.lang.Object
org.apache.commons.configuration.reloading.VFSFileChangedReloadingStrategy
All Implemented Interfaces:
ReloadingStrategy

A file-based reloading strategy that uses Commons VFS to determine when a file was changed.

This reloading strategy is very similar to FileChangedReloadingStrategy, except for the fact that it uses VFS and thus can deal with a variety of different configuration sources.

This strategy only works with FileConfiguration instances.

Since:
1.7
Version:
$Id: VFSFileChangedReloadingStrategy.java 1162383 2011-08-27 15:57:11Z oheger $
Author:
Commons Configuration team
  • Field Details

    • configuration

      Stores a reference to the configuration to be monitored.
    • lastModified

      protected long lastModified
      The last time the configuration file was modified.
    • lastChecked

      protected long lastChecked
      The last time the file was checked for changes.
    • refreshDelay

      protected long refreshDelay
      The minimum delay in milliseconds between checks.
  • Constructor Details

  • Method Details

    • setConfiguration

      public void setConfiguration(FileConfiguration configuration)
      Description copied from interface: ReloadingStrategy
      Set the configuration managed by this strategy.
      Specified by:
      setConfiguration in interface ReloadingStrategy
      Parameters:
      configuration - the configuration to monitor
    • init

      public void init()
      Description copied from interface: ReloadingStrategy
      Initialize the strategy.
      Specified by:
      init in interface ReloadingStrategy
    • reloadingRequired

      public boolean reloadingRequired()
      Description copied from interface: ReloadingStrategy
      Tell if the evaluation of the strategy requires to reload the configuration.
      Specified by:
      reloadingRequired in interface ReloadingStrategy
      Returns:
      a flag whether a reload should be performed
    • reloadingPerformed

      public void reloadingPerformed()
      Description copied from interface: ReloadingStrategy
      Notify the strategy that the file has been reloaded.
      Specified by:
      reloadingPerformed in interface ReloadingStrategy
    • getRefreshDelay

      public long getRefreshDelay()
      Return the minimal time in milliseconds between two reloadings.
      Returns:
      the refresh delay (in milliseconds)
    • setRefreshDelay

      public void setRefreshDelay(long refreshDelay)
      Set the minimal time between two reloadings.
      Parameters:
      refreshDelay - refresh delay in milliseconds
    • updateLastModified

      protected void updateLastModified()
      Update the last modified time.
    • hasChanged

      protected boolean hasChanged()
      Check if the configuration has changed since the last time it was loaded.
      Returns:
      a flag whether the configuration has changed
    • getFile

      protected org.apache.commons.vfs2.FileObject getFile()
      Returns the file that is monitored by this strategy. Note that the return value can be null under some circumstances.
      Returns:
      the monitored file