uk.ac.rdg.resc.jstyx.server
Class MonitoredFileOnDisk

java.lang.Object
  extended by uk.ac.rdg.resc.jstyx.server.StyxFile
      extended by uk.ac.rdg.resc.jstyx.server.AsyncStyxFile
          extended by uk.ac.rdg.resc.jstyx.server.MonitoredFileOnDisk
All Implemented Interfaces:
java.lang.Runnable, StyxFileChangeListener

public class MonitoredFileOnDisk
extends AsyncStyxFile
implements java.lang.Runnable

A file on disk that is continuously monitored. This is basically an AsyncStyxFile that wraps a FileOnDisk, with a separate thread that monitors the underlying file (checks for changes to the last modified time and length of the file). Note that the underlying file does not have to exist at the time the MonitoredFileOnDisk object is constructed or at the time the monitor is started.

Author:
Jon Blower $Revision: 223 $ $Date: 2005-05-11 16:15:35 +0100 (Wed, 11 May 2005) $ $Log$ Revision 1.5 2005/05/11 15:15:35 jonblower Added new constructor Revision 1.4 2005/05/11 10:33:50 jonblower Implemented MonitoredFileOnDisk.java Revision 1.1 2005/05/09 13:22:43 jonblower Initial import

Field Summary
 
Fields inherited from class uk.ac.rdg.resc.jstyx.server.AsyncStyxFile
baseFile
 
Fields inherited from class uk.ac.rdg.resc.jstyx.server.StyxFile
auth, directory, lastModifiedTime, name, parent
 
Constructor Summary
MonitoredFileOnDisk(java.io.File file)
          Creates a new instance of MonitoredFileOnDisk that monitors the underlying file every 2 seconds.
MonitoredFileOnDisk(java.io.File file, long monitorInterval)
          Creates a new instance of MonitoredFileOnDisk.
MonitoredFileOnDisk(java.lang.String filename)
          Creates a new instance of MonitoredFileOnDisk that monitors the underlying file every 2 seconds.
MonitoredFileOnDisk(java.lang.String name, java.io.File file, long monitorInterval)
          Creates a new instance of MonitoredFileOnDisk.
MonitoredFileOnDisk(java.lang.String filename, long monitorInterval)
          Creates a new instance of MonitoredFileOnDisk.
 
Method Summary
 ULong getLength()
           
static void main(java.lang.String[] args)
          Simple test program
 void run()
           
 void startMonitoring()
          Starts monitoring the file
 void stopMonitoring()
          Stops monitoring the file
 
Methods inherited from class uk.ac.rdg.resc.jstyx.server.AsyncStyxFile
clientDisconnected, delete, fileContentsChanged, fileContentsChanged, getBaseFile, read, setMinReplyInterval, write
 
Methods inherited from class uk.ac.rdg.resc.jstyx.server.StyxFile
addChangeListener, addClient, checkSetLastModifiedTime, checkSetLength, checkSetMode, checkSetName, clientConnected, contentsChanged, fireContentsChanged, getClient, getDirEntry, getFullPath, getGroup, getName, getNumClients, getOwner, getParent, getPermissions, getQid, getVersion, incrementVersion, isAppendOnly, isAuth, isDirectory, isExclusive, processAndReplyRead, processAndReplyRead, processAndReplyRead, refresh, remove, removeChangeListener, removeClient, rename, replyRead, replyRead, replyRead, replyRead, replyRead, replyWrite, setLastAccessTime, setLastModified, setLength, setMode, setName, setPermissions, setReadOnly
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MonitoredFileOnDisk

public MonitoredFileOnDisk(java.lang.String filename,
                           long monitorInterval)
                    throws StyxException
Creates a new instance of MonitoredFileOnDisk. Call startMonitoring() to start monitoring the underlying file.

Parameters:
filename - The name of the underlying file to monitor. Note that this file does not need to exist yet
monitorInterval - The time in milliseconds between each check to see if the file has changed
Throws:
StyxException - if the file name is illegal

MonitoredFileOnDisk

public MonitoredFileOnDisk(java.lang.String filename)
                    throws StyxException
Creates a new instance of MonitoredFileOnDisk that monitors the underlying file every 2 seconds. Call startMonitoring() to start monitoring the underlying file.

Parameters:
filename - The name of the underlying file to monitor. Note that this file does not need to exist yet
Throws:
StyxException - if the file name is illegal

MonitoredFileOnDisk

public MonitoredFileOnDisk(java.lang.String name,
                           java.io.File file,
                           long monitorInterval)
                    throws StyxException
Creates a new instance of MonitoredFileOnDisk. Call startMonitoring() to start monitoring the underlying file.

Parameters:
name - The name of the file as it will appear in the Styx namespace
file - The underlying file to monitor. Note that this file does not need to exist yet
monitorInterval - The time in milliseconds between each check to see if the file has changed
Throws:
StyxException - if the file name is illegal

MonitoredFileOnDisk

public MonitoredFileOnDisk(java.io.File file,
                           long monitorInterval)
                    throws StyxException
Creates a new instance of MonitoredFileOnDisk. Call startMonitoring() to start monitoring the underlying file.

Parameters:
file - The underlying file to monitor. Note that this file does not need to exist yet
monitorInterval - The time in milliseconds between each check to see if the file has changed
Throws:
StyxException - if the file name is illegal

MonitoredFileOnDisk

public MonitoredFileOnDisk(java.io.File file)
                    throws StyxException
Creates a new instance of MonitoredFileOnDisk that monitors the underlying file every 2 seconds. Call startMonitoring() to start monitoring the underlying file.

Parameters:
file - The underlying file to monitor. Note that this file does not need to exist yet
Throws:
StyxException - if the file name is illegal
Method Detail

run

public void run()
Specified by:
run in interface java.lang.Runnable

getLength

public ULong getLength()
Overrides:
getLength in class AsyncStyxFile
Returns:
the length of the StyxFile that is wrapped by this AsyncStyxFile

startMonitoring

public void startMonitoring()
Starts monitoring the file


stopMonitoring

public void stopMonitoring()
Stops monitoring the file


main

public static void main(java.lang.String[] args)
                 throws java.lang.Exception
Simple test program

Throws:
java.lang.Exception


Copyright © 2004-2006 Reading e-Science Centre. All Rights Reserved.