uk.ac.rdg.resc.jstyx.gridservice.server
Class SGSParamFile

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.gridservice.server.SGSParamFile
All Implemented Interfaces:
StyxFileChangeListener

public class SGSParamFile
extends AsyncStyxFile

A StyxFile interface to a parameter that is passed to an SGS instance as part of the command line of the underlying executable. This is an AsyncStyxFile so clients can be automatically notified of changes to the value of the parameter.

Author:
Jon Blower $Revision: 609 $ $Date: 2006-03-31 18:09:42 +0100 (Fri, 31 Mar 2006) $ $Log$ Revision 1.21 2006/02/17 09:24:55 jonblower Change to comments Revision 1.20 2005/12/07 17:47:58 jonblower Changed "commandline" file to "args" - now just contains arguments, not program name Revision 1.19 2005/11/14 21:31:54 jonblower Got SGSRun working for SC2005 demo Revision 1.18 2005/11/11 21:57:21 jonblower Implemented passing of URLs to input files Revision 1.17 2005/11/07 21:06:42 jonblower Now allows setting of empty values for non-required parameters Revision 1.16 2005/11/04 19:31:16 jonblower Added code to disallow parameter setting while service is running Revision 1.15 2005/11/04 09:11:23 jonblower Made SGSParamFile inherit from AsyncStyxFile instead of InMemoryFile Revision 1.14 2005/11/03 07:42:47 jonblower Implemented JSAP-based parameter parsing Revision 1.10 2005/09/08 07:08:59 jonblower Removed "String user" from list of parameters to StyxFile.write() Revision 1.9 2005/08/01 16:38:05 jonblower Implemented simple parameter handling Revision 1.8 2005/07/29 16:56:07 jonblower Implementing reading command line asynchronously Revision 1.7 2005/06/20 07:17:34 jonblower Wrapped SGSParamFile as AsyncStyxFile Revision 1.6 2005/04/27 16:11:43 jonblower Added capability to add documentation files to SGS namespace Revision 1.5 2005/04/26 07:46:11 jonblower Continuing to improve setting of parameters in Styx Grid Services Revision 1.2 2005/03/26 14:30:17 jonblower Modified to use SGSConfigException Revision 1.1 2005/03/24 17:34:58 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
SGSParamFile(SGSParam param, uk.ac.rdg.resc.jstyx.gridservice.server.StyxGridServiceInstance instance)
           
 
Method Summary
 void checkValid()
          Checks to see if the contents of this file are valid.
 java.lang.String getCommandLineFragment()
           
 com.martiansoftware.jsap.Parameter getJSAPParameter()
           
 java.lang.String getParameterValue()
           
 void setParameterValue(java.lang.String newValue)
          Sets the parameter value, checking that the value is OK.
 void write(StyxFileClient client, long offset, int count, org.apache.mina.common.ByteBuffer data, boolean truncate, int tag)
          The new value for the parameter must come in a single message (i.e.
 
Methods inherited from class uk.ac.rdg.resc.jstyx.server.AsyncStyxFile
clientDisconnected, delete, fileContentsChanged, fileContentsChanged, getBaseFile, getLength, main, read, setMinReplyInterval
 
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

SGSParamFile

public SGSParamFile(SGSParam param,
                    uk.ac.rdg.resc.jstyx.gridservice.server.StyxGridServiceInstance instance)
             throws StyxException
Throws:
StyxException
Method Detail

getJSAPParameter

public com.martiansoftware.jsap.Parameter getJSAPParameter()
Returns:
the JSAP Parameter object that is associated with this file

write

public void write(StyxFileClient client,
                  long offset,
                  int count,
                  org.apache.mina.common.ByteBuffer data,
                  boolean truncate,
                  int tag)
           throws StyxException
The new value for the parameter must come in a single message (i.e. the offset must be zero and the incoming ByteBuffer must contain the entire parameter value). Must also write with truncation.

Overrides:
write in class AsyncStyxFile
Parameters:
client - The client that is performing the write operation
offset - The place in the file where the new data will be added
count - The number of bytes to write
data - 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 data
tag - The tag of the incoming Twrite message (this is needed when calling writeReply())
Throws:
StyxException

getCommandLineFragment

public java.lang.String getCommandLineFragment()
Returns:
the parameter as it will appear on the command line, including the flag, if present (e.g. "-p 12"). Returns an empty string if no value has yet been set

getParameterValue

public java.lang.String getParameterValue()
Returns:
the current value of this parameter

setParameterValue

public void setParameterValue(java.lang.String newValue)
                       throws StyxException
Sets the parameter value, checking that the value is OK.

Throws:
StyxException - if the parameter is not valid

checkValid

public void checkValid()
                throws StyxException
Checks to see if the contents of this file are valid. At the moment, this just checks to see if a value has been set for a required parameter.

Throws:
StyxException - if the file contents are not valid for some reason.


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