uk.ac.vamsas.client.simpleclient
Class WatcherElement

java.lang.Object
  extended byuk.ac.vamsas.client.simpleclient.WatcherElement
Direct Known Subclasses:
SessionFileWatcherElement, SessionFlagWatcherElement, VamsasFileWatcherElement

public abstract class WatcherElement
extends java.lang.Object


Field Summary
protected  WatcherCallBack handler
           
protected  boolean handlerCalled
          true when the handler is being called for this watcher
protected  FileWatcher watcher
           
protected  boolean watchForChange
          set this to false to stop the thread
 
Constructor Summary
WatcherElement(WatcherCallBack handler)
           
 
Method Summary
protected  void callHandler(Lock doclock)
          Calls the current eventhandler
 boolean doWatch()
          Originally from the uk.ac.vamsas.test.simpleclient.ArchiveClient method
protected  void enableWatch()
          must be called by implementations of enablewatch
protected abstract  void endWatch()
          called by haltWatch before clearing the FileWatcher reference.
 WatcherCallBack getHandler()
           
protected abstract  java.lang.String getSubject()
          implemented for debug information purposes.
 FileWatcher getWatcher()
           
 void haltWatch()
          will instruct watcher to stop and wait around for one WATCH_SLEEP before returning.
protected abstract  void initWatch()
          called to generate the watcher object by enableWatch and in doWatch
 boolean isHandlerCalled()
           
 boolean isWatchEnabled()
           
 void setHandler(WatcherCallBack handler)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

watcher

protected FileWatcher watcher

handler

protected WatcherCallBack handler

watchForChange

protected boolean watchForChange
set this to false to stop the thread


handlerCalled

protected boolean handlerCalled
true when the handler is being called for this watcher

Constructor Detail

WatcherElement

public WatcherElement(WatcherCallBack handler)
Method Detail

haltWatch

public void haltWatch()
will instruct watcher to stop and wait around for one WATCH_SLEEP before returning. If no thread is running then it returns immediately.


endWatch

protected abstract void endWatch()
called by haltWatch before clearing the FileWatcher reference.


initWatch

protected abstract void initWatch()
called to generate the watcher object by enableWatch and in doWatch


getSubject

protected abstract java.lang.String getSubject()
implemented for debug information purposes.

Returns:
Informative string about what the watcher is watching

enableWatch

protected void enableWatch()
must be called by implementations of enablewatch


doWatch

public boolean doWatch()
Originally from the uk.ac.vamsas.test.simpleclient.ArchiveClient method

Returns:
true if the handler was called for a changeEvent

callHandler

protected void callHandler(Lock doclock)
Calls the current eventhandler

Parameters:
doclock - the lock on the watch file

getHandler

public WatcherCallBack getHandler()
Returns:
the handler

isHandlerCalled

public boolean isHandlerCalled()
Returns:
the handlerCalled

isWatchEnabled

public boolean isWatchEnabled()
Returns:
true if watcher is enabled

setHandler

public void setHandler(WatcherCallBack handler)
Parameters:
handler - the handler to set

getWatcher

public FileWatcher getWatcher()
Returns:
the watcher