org.glite.slcs.config
Class FileConfigurationMonitor

java.lang.Object
  extended by java.util.Timer
      extended by org.glite.slcs.config.FileConfigurationMonitor

public class FileConfigurationMonitor
extends java.util.Timer

FileConfigurationMonitor checks if the monitored file have been modified, and if so sends a FileConfigurationEvent to all the registered FileConfigurationListener.

Version:
$Revision: 1.10 $
Author:
Valery Tschopp <tschopp@switch.ch>

Field Summary
static long DEFAULT_MONITORING_INTERVAL
          Default sleep time between 2 check (300000 millis = 300 sec = 5 min)
 
Constructor Summary
FileConfigurationMonitor(java.io.File file)
          Constr.
FileConfigurationMonitor(java.io.File file, long monitoringInterval)
          Const.
 
Method Summary
 void addFileConfigurationListener(FileConfigurationListener listener)
          Adds the listener to the FileConfigurationListener list.
static FileConfigurationMonitor createFileConfigurationMonitor(java.io.File file, java.lang.String monitoringInterval, FileConfigurationListener listener)
          Creates a FileConfigurationMonitor for the given FileConfiguration.
protected  void dispatchFileConfigurationEvent(int eventType)
          Disptaches the FileConfigurationEvent type to all FileConfigurationListener registered.
 boolean removeFileConfigurationListener(FileConfigurationListener listener)
          Removes the listener from the FileConfigurationListener list.
 void shutdown()
          Stops to monitor the file.
 void start()
          Starts the FileConfigurationMonitorTask to monitor the file.
 
Methods inherited from class java.util.Timer
cancel, purge, schedule, schedule, schedule, schedule, scheduleAtFixedRate, scheduleAtFixedRate
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_MONITORING_INTERVAL

public static long DEFAULT_MONITORING_INTERVAL
Default sleep time between 2 check (300000 millis = 300 sec = 5 min)

Constructor Detail

FileConfigurationMonitor

public FileConfigurationMonitor(java.io.File file)
Constr. Monitor the file associated with the given FileConfiguration and check for change every DEFAULT_MONITORING_INTERVAL (5 min).

Parameters:
file - The file to monitor

FileConfigurationMonitor

public FileConfigurationMonitor(java.io.File file,
                                long monitoringInterval)
Const. Monitor the file associated with the given FileConfiguration and check for change every given monitoringInterval.

Parameters:
file - The file to monitor.
monitoringInterval - The pause between 2 check in millis.
Method Detail

createFileConfigurationMonitor

public static FileConfigurationMonitor createFileConfigurationMonitor(java.io.File file,
                                                                      java.lang.String monitoringInterval,
                                                                      FileConfigurationListener listener)
Creates a FileConfigurationMonitor for the given FileConfiguration.

Parameters:
file - The file associated with the file to monitor.
monitoringInterval - The time (in seconds) between 2 checks.
listener - The FileConfigurationListener (this).
Returns:
The new FileConfigurationMonitor object.

start

public void start()
Starts the FileConfigurationMonitorTask to monitor the file.


shutdown

public void shutdown()
Stops to monitor the file.


addFileConfigurationListener

public void addFileConfigurationListener(FileConfigurationListener listener)
Adds the listener to the FileConfigurationListener list.

Parameters:
listener - The listener to add.
See Also:
FileConfigurationListener

removeFileConfigurationListener

public boolean removeFileConfigurationListener(FileConfigurationListener listener)
Removes the listener from the FileConfigurationListener list.

Parameters:
listener - The listener to remove.
Returns:
true if the listener was in the list, false otherwise.
See Also:
FileConfigurationListener

dispatchFileConfigurationEvent

protected void dispatchFileConfigurationEvent(int eventType)
Disptaches the FileConfigurationEvent type to all FileConfigurationListener registered.

Parameters:
eventType - The FileConfigurationEvent type.