org.jconfig
Class URLFileWatcher

java.lang.Object
  extended byjava.lang.Thread
      extended byorg.jconfig.URLFileWatcher
All Implemented Interfaces:
java.lang.Runnable

public class URLFileWatcher
extends java.lang.Thread

A class which implements an event dispatching mechanism to all classes supporting the FileListener interface. This class will notify all FileListeners when the configuration changes. Once the URLFileWatcher has been shutdown, the class needs to be reinstanciated and restarted.

Author:
Steve Braun
See Also:
FileWatcher

Field Summary
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
URLFileWatcher(java.lang.String url)
          Constructs a FileWatcher watching the specified File
 
Method Summary
 void addFileListener(FileListener fileListener)
          Adds FileListener
 FileListener[] getFileListeners()
          Retrieve an array of FileListeners.
 java.net.URL getURL()
           
 java.lang.String getURLString()
           
 void run()
          Start the thread to call checkFile()
 void setInterval(int seconds)
          Set the timer interval.
 void setURL(java.lang.String url)
          Sets a new File to be watched.
 void setURL(java.net.URL configURL)
           
 void start()
          Start the Thread on its journey to scan for changes to the file it is watching.
 void stopWatching()
          Tell thread to stop watching.
 
Methods inherited from class java.lang.Thread
activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getContextClassLoader, getName, getPriority, getThreadGroup, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setName, setPriority, sleep, sleep, stop, stop, suspend, toString, yield
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

URLFileWatcher

public URLFileWatcher(java.lang.String url)
               throws FileWatcherException
Constructs a FileWatcher watching the specified File

Parameters:
url - The File to be watched
Method Detail

addFileListener

public void addFileListener(FileListener fileListener)
Adds FileListener

Parameters:
fileListener - The FileListener

setInterval

public void setInterval(int seconds)
Set the timer interval. The default is 10 seconds

Parameters:
seconds - The number of seconds to set the interval when to check for the changes to the file.

stopWatching

public void stopWatching()
Tell thread to stop watching. Currently once a Thread is started and stopped, a new FileWatcher will be required.


start

public void start()
Start the Thread on its journey to scan for changes to the file it is watching.


run

public void run()
Start the thread to call checkFile()


getFileListeners

public FileListener[] getFileListeners()
Retrieve an array of FileListeners.

Returns:
FileListeners as array of FileListener

setURL

public void setURL(java.lang.String url)
            throws FileWatcherException
Sets a new File to be watched. This causes the FileWatcher to watch the given File and disregard the File that was used during Construction.

Parameters:
url - The File to be watched
Throws:
FileWatcherException

getURLString

public java.lang.String getURLString()

getURL

public java.net.URL getURL()

setURL

public void setURL(java.net.URL configURL)


Copyright © 2001-2005 Andreas Mecky, Terry Dye. All Rights Reserved.