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 Summary
FieldsModifier and TypeFieldDescriptionprotected FileConfigurationStores a reference to the configuration to be monitored.protected longThe last time the file was checked for changes.protected longThe last time the configuration file was modified.protected longThe minimum delay in milliseconds between checks. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected org.apache.commons.vfs2.FileObjectgetFile()Returns the file that is monitored by this strategy.longReturn the minimal time in milliseconds between two reloadings.protected booleanCheck if the configuration has changed since the last time it was loaded.voidinit()Initialize the strategy.voidNotify the strategy that the file has been reloaded.booleanTell if the evaluation of the strategy requires to reload the configuration.voidsetConfiguration(FileConfiguration configuration) Set the configuration managed by this strategy.voidsetRefreshDelay(long refreshDelay) Set the minimal time between two reloadings.protected voidUpdate the last modified time.
-
Field Details
-
configuration
Stores a reference to the configuration to be monitored. -
lastModified
The last time the configuration file was modified. -
lastChecked
The last time the file was checked for changes. -
refreshDelay
The minimum delay in milliseconds between checks.
-
-
Constructor Details
-
VFSFileChangedReloadingStrategy
public VFSFileChangedReloadingStrategy()
-
-
Method Details
-
setConfiguration
Description copied from interface:ReloadingStrategySet the configuration managed by this strategy.- Specified by:
setConfigurationin interfaceReloadingStrategy- Parameters:
configuration- the configuration to monitor
-
init
Description copied from interface:ReloadingStrategyInitialize the strategy.- Specified by:
initin interfaceReloadingStrategy
-
reloadingRequired
Description copied from interface:ReloadingStrategyTell if the evaluation of the strategy requires to reload the configuration.- Specified by:
reloadingRequiredin interfaceReloadingStrategy- Returns:
- a flag whether a reload should be performed
-
reloadingPerformed
Description copied from interface:ReloadingStrategyNotify the strategy that the file has been reloaded.- Specified by:
reloadingPerformedin interfaceReloadingStrategy
-
getRefreshDelay
Return the minimal time in milliseconds between two reloadings.- Returns:
- the refresh delay (in milliseconds)
-
setRefreshDelay
Set the minimal time between two reloadings.- Parameters:
refreshDelay- refresh delay in milliseconds
-
updateLastModified
Update the last modified time. -
hasChanged
Check if the configuration has changed since the last time it was loaded.- Returns:
- a flag whether the configuration has changed
-
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
-