public class VFSFileChangedReloadingStrategy extends Object implements 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.
| Modifier and Type | Field and Description |
|---|---|
protected FileConfiguration |
configuration
Stores a reference to the configuration to be monitored.
|
protected long |
lastChecked
The last time the file was checked for changes.
|
protected long |
lastModified
The last time the configuration file was modified.
|
protected long |
refreshDelay
The minimum delay in milliseconds between checks.
|
| Constructor and Description |
|---|
VFSFileChangedReloadingStrategy() |
| Modifier and Type | Method and Description |
|---|---|
protected org.apache.commons.vfs2.FileObject |
getFile()
Returns the file that is monitored by this strategy.
|
long |
getRefreshDelay()
Return the minimal time in milliseconds between two reloadings.
|
protected boolean |
hasChanged()
Check if the configuration has changed since the last time it was loaded.
|
void |
init()
Initialize the strategy.
|
void |
reloadingPerformed()
Notify the strategy that the file has been reloaded.
|
boolean |
reloadingRequired()
Tell if the evaluation of the strategy requires to reload the configuration.
|
void |
setConfiguration(FileConfiguration configuration)
Set the configuration managed by this strategy.
|
void |
setRefreshDelay(long refreshDelay)
Set the minimal time between two reloadings.
|
protected void |
updateLastModified()
Update the last modified time.
|
protected FileConfiguration configuration
protected long lastModified
protected long lastChecked
protected long refreshDelay
public void setConfiguration(FileConfiguration configuration)
ReloadingStrategysetConfiguration in interface ReloadingStrategyconfiguration - the configuration to monitorpublic void init()
ReloadingStrategyinit in interface ReloadingStrategypublic boolean reloadingRequired()
ReloadingStrategyreloadingRequired in interface ReloadingStrategypublic void reloadingPerformed()
ReloadingStrategyreloadingPerformed in interface ReloadingStrategypublic long getRefreshDelay()
public void setRefreshDelay(long refreshDelay)
refreshDelay - refresh delay in millisecondsprotected void updateLastModified()
protected boolean hasChanged()
protected org.apache.commons.vfs2.FileObject getFile()
Copyright © 2001–2013 The Apache Software Foundation. All rights reserved.