uk.org.ogsadai.activity.delivery
Class AbstractDeliverFromAddressActivity

java.lang.Object
  |
  +--uk.org.ogsadai.activity.Activity
        |
        +--uk.org.ogsadai.activity.delivery.AbstractDeliverFromAddressActivity
Direct Known Subclasses:
DeliverFromFileActivity, DeliverFromURLActivity

public abstract class AbstractDeliverFromAddressActivity
extends Activity

This abstract class contains methods to connect to a java.io.InputStream and pull all the information on that stream into OGSA-DAI, either in one byte array block, or via multiple set sized byte array blocks.

The output can then be connected to the input of another activity,

Author:
The OGSA-DAI Project Team

Field Summary
private static java.lang.String COPYRIGHT_NOTICE
          Copyright statement
private static DAILogger LOG
          Logger object for logging in this class
protected  boolean mBlockMode
          Size of blocks placed onto the stream
protected  byte[] mBuffer
          Buffer to hold data
protected  java.io.ByteArrayOutputStream mByteBuffer
          ByteArrayOutputStream to hold output data
protected  java.lang.String mFromAddress
          Address to read data from
protected  java.io.InputStream mFromInputStream
          Input stream configured to read data from the address
protected  BlockWriter mOutput
          Activity output - data read from address
 
Fields inherited from class uk.org.ogsadai.activity.Activity
mContext, mExternalInputs, mExternalOutputs, mInternalInputs, mInternalOutputs
 
Constructor Summary
AbstractDeliverFromAddressActivity(org.w3c.dom.Element element)
           
 
Method Summary
 void initialise()
          This method should be overridden by subclasses to perform any initialisation they require before the process method invocations begin.
 void processBlock()
          Performs an iteration of the processing of an activity.
abstract  void processFirst()
          This method is called during the first iteration of processing an activity.
protected  void setupBlocking(org.w3c.dom.Element fromElement)
          Gets the block size, in bytes, from a blockSizeInBytes attribute of the given element and saves this in an instance variable.
protected  void setupOutput(org.w3c.dom.Element toElement)
          Gets the name of the activity output stream from a name attribute of the given element and saves this in the activity's list of internal outputs.
 
Methods inherited from class uk.org.ogsadai.activity.Activity
cleanUp, connectsTo, createOutputPipe, getActivityConfiguration, getActivityName, getCause, getName, getObservableStatus, getProperties, getSession, getStatus, hasActivityConfiguration, hasProperties, process, setActivityName, setCompleted, setError
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

COPYRIGHT_NOTICE

private static final java.lang.String COPYRIGHT_NOTICE
Copyright statement

See Also:
Constant Field Values

LOG

private static final DAILogger LOG
Logger object for logging in this class


mFromAddress

protected java.lang.String mFromAddress
Address to read data from


mFromInputStream

protected java.io.InputStream mFromInputStream
Input stream configured to read data from the address


mBlockMode

protected boolean mBlockMode
Size of blocks placed onto the stream


mBuffer

protected byte[] mBuffer
Buffer to hold data


mByteBuffer

protected final java.io.ByteArrayOutputStream mByteBuffer
ByteArrayOutputStream to hold output data


mOutput

protected BlockWriter mOutput
Activity output - data read from address

Constructor Detail

AbstractDeliverFromAddressActivity

public AbstractDeliverFromAddressActivity(org.w3c.dom.Element element)
                                   throws ActivityCreationException,
                                          ActivitySpecificationException
Method Detail

setupBlocking

protected void setupBlocking(org.w3c.dom.Element fromElement)
                      throws ActivitySpecificationException,
                             ActivityExecutionException
Gets the block size, in bytes, from a blockSizeInBytes attribute of the given element and saves this in an instance variable.

Parameters:
fromElement - Element from the request.
Throws:
ActivitySpecificationException - If the block size is not an integer > 0.
ActivityExecutionException - If there is not enough memory.

setupOutput

protected void setupOutput(org.w3c.dom.Element toElement)
Gets the name of the activity output stream from a name attribute of the given element and saves this in the activity's list of internal outputs.

Parameters:
toElement - Element from the request.

initialise

public void initialise()
                throws ActivitySpecificationException,
                       ActivityExecutionException
Description copied from class: Activity
This method should be overridden by subclasses to perform any initialisation they require before the process method invocations begin. This might be used for setting up convenient fields to reference objects contained in the context. It shouldn't be used for opening resources. That should be done in processFirst.

Overrides:
initialise in class Activity
Throws:
ActivityExecutionException - If some system problem prevents the activity from initialising.
ActivitySpecificationException - If a problem with settings provided by a client prevents the activity from initialising.

processFirst

public abstract void processFirst()
Description copied from class: Activity
This method is called during the first iteration of processing an activity. It can be overridden by subclasses to define some processing that should be done only once during the first iteration of the activity processing, for example evaluating a database query.

Overrides:
processFirst in class Activity

processBlock

public void processBlock()
Description copied from class: Activity
Performs an iteration of the processing of an activity. This may involve reading a block of input data and writing a block of output data, or may involve some other kind of processing. When an activity is processed by the OGSA-DAI engine, this method will be invoked repeatedly until the activity either completes or stops due to an error or termination call. An implementation of this method should invoke the setCompleted method to indicate that processing is complete, or the setError method if an error occurs that will prevent the processing from completing.

Specified by:
processBlock in class Activity