| java.lang.Object org.jaffa.cache.CacheSourceMonitor
CacheSourceMonitor | public class CacheSourceMonitor (Code) | | This is a helper class to monitor file(s), which provide data to a cache. The cache will be cleared, whenever any of the source files are modified. Note that any open iterators on the cache will have unpredictable results, whenever the cache is flushed.
Create an instance of this class, providing the cache and the file(s) to be monitored. Then invoke the startMonitoring method. This will create a daemon Thread, which will monitor the files for any changes. Invoke the stopMonitoring method to stop the thread.
author: GautamJ |
Inner Class :public class CacheSourceMonitorThread extends Thread | |
Constructor Summary | |
public | CacheSourceMonitor(ICache cache) Creates a new instance of CacheSourceMonitor. | public | CacheSourceMonitor(ICache cache, String file) Creates a new instance of CacheSourceMonitor.
Parameters: cache - The cache to be cleared, if any of the source files are modified. Parameters: file - The file to be monitored. |
Method Summary | |
public void | addFile(String file) Add a file to be monitored for changes. | public void | startMonitoring() This will create a daemon Thread for monitoring the files. | public void | startMonitoring(int minutes) This will create a daemon Thread for monitoring the files. | public void | stopMonitoring() This will stop the Thread, that was created by the call to the startMonitoring method. |
CacheSourceMonitor | public CacheSourceMonitor(ICache cache)(Code) | | Creates a new instance of CacheSourceMonitor.
Parameters: cache - The cache to be cleared, if any of the source files are modified. |
CacheSourceMonitor | public CacheSourceMonitor(ICache cache, String file)(Code) | | Creates a new instance of CacheSourceMonitor.
Parameters: cache - The cache to be cleared, if any of the source files are modified. Parameters: file - The file to be monitored. In case, the input represents a directory, then all the files (one level deep) under that directory will be monitored for any changes. |
addFile | public void addFile(String file)(Code) | | Add a file to be monitored for changes. In case, the input represents a directory, then all the files (one level deep) under that directory will be monitored for any changes.
Parameters: file - The file to be monitored. In case, the input represents a directory, then all the files (one level deep) under that directory will be monitored for any changes. |
startMonitoring | public void startMonitoring()(Code) | | This will create a daemon Thread for monitoring the files. This thread will be run at the lowest priority, every 5 minutes by default.
|
startMonitoring | public void startMonitoring(int minutes)(Code) | | This will create a daemon Thread for monitoring the files. This thread will be run at the lowest priority at the input frequency.
Parameters: minutes - The frequency at which the files will be monitored. |
stopMonitoring | public void stopMonitoring()(Code) | | This will stop the Thread, that was created by the call to the startMonitoring method.
|
|
|