|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectuk.ac.rdg.resc.jstyx.server.StyxFile
uk.ac.rdg.resc.jstyx.server.AsyncStyxFile
public class AsyncStyxFile
A wrapper for a StyxFile that implements asynchronous behaviour: the first read from a given client returns the file's data as normal. If the file is not closed, subsequent reads from the same client block until the file content is changed.
| Field Summary | |
|---|---|
protected StyxFile |
baseFile
|
| Fields inherited from class uk.ac.rdg.resc.jstyx.server.StyxFile |
|---|
auth, directory, lastModifiedTime, name, parent |
| Constructor Summary | |
|---|---|
AsyncStyxFile(StyxFile file)
Creates a new AsyncStyxFile with the same name as the underlying file. |
|
AsyncStyxFile(StyxFile file,
java.lang.String name)
|
|
AsyncStyxFile(StyxFile file,
java.lang.String name,
int permissions)
|
|
AsyncStyxFile(StyxFile file,
java.lang.String name,
int permissions,
boolean isAppendOnly,
boolean isExclusive)
|
|
| Method Summary | |
|---|---|
protected void |
clientDisconnected(StyxFileClient client)
Called when a client disconnects from the file. |
void |
delete()
Free all resources associated with this file |
void |
fileContentsChanged()
This is called when the contents of the underlying StyxFile are changed (required by StyxFileChangeListener interface). |
void |
fileContentsChanged(boolean force)
Called to notify that the underlying data have changed. |
StyxFile |
getBaseFile()
Gets the StyxFile that is wrapped by this AsyncStyxFile |
ULong |
getLength()
|
static void |
main(java.lang.String[] args)
Simple test function |
void |
read(StyxFileClient client,
long offset,
int count,
int tag)
Reads data from this file. |
void |
setMinReplyInterval(float seconds)
Sets a minimum reply interval, i.e. |
void |
write(StyxFileClient client,
long offset,
int count,
org.apache.mina.common.ByteBuffer data,
boolean truncate,
int tag)
This simply calls write() in the contained StyxFile object. |
| 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 |
| Field Detail |
|---|
protected StyxFile baseFile
| Constructor Detail |
|---|
public AsyncStyxFile(StyxFile file)
throws StyxException
StyxException
public AsyncStyxFile(StyxFile file,
java.lang.String name)
throws StyxException
StyxException
public AsyncStyxFile(StyxFile file,
java.lang.String name,
int permissions)
throws StyxException
StyxException
public AsyncStyxFile(StyxFile file,
java.lang.String name,
int permissions,
boolean isAppendOnly,
boolean isExclusive)
throws StyxException
StyxException| Method Detail |
|---|
public void setMinReplyInterval(float seconds)
public void read(StyxFileClient client,
long offset,
int count,
int tag)
throws StyxException
StyxFile
read in class StyxFileclient - The client that is performing the readoffset - The point in the file at which to start readingcount - The maximum number of bytes to readtag - The tag of the incoming Tread message (this is needed when
calling readReply())
StyxException
public void write(StyxFileClient client,
long offset,
int count,
org.apache.mina.common.ByteBuffer data,
boolean truncate,
int tag)
throws StyxException
write in class StyxFileclient - The client that is performing the write operationoffset - The place in the file where the new data will be addedcount - The number of bytes to writedata - The data to write. The position and limit of this ByteBuffer
will be set correctly, but subclasses should note that the position might
not be zero.truncate - If this is true the file will be truncated at the end of
the new datatag - The tag of the incoming Twrite message (this is needed when
calling writeReply())
StyxExceptionpublic void fileContentsChanged(boolean force)
force - If this is true, clients will be notified of changes to
the underlying data, irrespective of how long they have waited.public StyxFile getBaseFile()
public ULong getLength()
getLength in class StyxFilepublic void fileContentsChanged()
fileContentsChanged in interface StyxFileChangeListenerpublic void delete()
delete in class StyxFileprotected void clientDisconnected(StyxFileClient client)
clientDisconnected in class StyxFileclient - The client that has just disconnected from the file. This
will not be null.
public static void main(java.lang.String[] args)
throws java.lang.Exception
java.lang.Exception
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||