uk.org.ogsadai.activity.transform
Class BytesToTempFileActivity

java.lang.Object
  |
  +--uk.org.ogsadai.activity.Activity
        |
        +--uk.org.ogsadai.activity.transform.BytesToTempFileActivity

public class BytesToTempFileActivity
extends Activity

This activity takes an stream of byte arrays and writes them to a temporary file on the server. A reference to this file is written to the output.

This activity is useful when writing BLOBs to relational databases. The output of this activity can be passed to one of the parameterized inputs of the SQLUpdateStatement activity in order to write BLOBS to a database.

The activity has a one input. This input passed blocks of type byte[]. The bytes in the input blocks will be written to the temporary file in the order in which they are received.

The activity has one output to which the java.io.File object that refers to the temporary file.

For information on this activity see the OGSA-DAI user doc: OGSA-DAI/doc/interaction/activities/transform/bytesToTempFile.html

Author:
OGSA-DAI team

Field Summary
private static java.lang.String COPYRIGHT_NOTICE
          Copyright statement
static java.lang.String FROM_ATTRIBUTE
           
static java.lang.String INPUT_ELEMENT
           
private static DAILogger LOG
          Logger object for logging in this class
protected  java.io.OutputStream mFileOutputStream
           
protected  BlockReader mInput
          Reader that provides the activity's only input
protected  java.lang.String mInputStreamName
          Name of the activity's only input stream
protected  BlockWriter mOutput
          Write to which the activity's output is written
protected  java.io.File mOutputFile
           
protected  java.lang.String mOutputStreamName
          Name of the activity's only output stream
static java.lang.String NAME_ATTRIBUTE
           
static java.lang.String OUTPUT_ELEMENT
           
 
Fields inherited from class uk.org.ogsadai.activity.Activity
mContext, mExternalInputs, mExternalOutputs, mInternalInputs, mInternalOutputs
 
Constructor Summary
BytesToTempFileActivity(org.w3c.dom.Element element)
          Constructs an instance of the BytesToTempFileActivity activity.
 
Method Summary
 java.lang.String getInputStreamName()
          Gets the activity's input stream name.
 java.lang.String getOutputStreamName()
          Gets the activity's output stream name.
 void initialise()
          This method should be overridden by subclasses to perform any initialisation they require before the process method invocations begin.
protected  void processBlock()
          Performs an iteration of the processing of an activity.
 
Methods inherited from class uk.org.ogsadai.activity.Activity
cleanUp, connectsTo, createOutputPipe, getActivityConfiguration, getActivityName, getCause, getName, getObservableStatus, getProperties, getSession, getStatus, hasActivityConfiguration, hasProperties, process, processFirst, 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 DAILogger LOG
Logger object for logging in this class


INPUT_ELEMENT

public static final java.lang.String INPUT_ELEMENT
See Also:
Constant Field Values

OUTPUT_ELEMENT

public static final java.lang.String OUTPUT_ELEMENT
See Also:
Constant Field Values

FROM_ATTRIBUTE

public static final java.lang.String FROM_ATTRIBUTE
See Also:
Constant Field Values

NAME_ATTRIBUTE

public static final java.lang.String NAME_ATTRIBUTE
See Also:
Constant Field Values

mInputStreamName

protected java.lang.String mInputStreamName
Name of the activity's only input stream


mInput

protected BlockReader mInput
Reader that provides the activity's only input


mOutputStreamName

protected java.lang.String mOutputStreamName
Name of the activity's only output stream


mOutput

protected BlockWriter mOutput
Write to which the activity's output is written


mOutputFile

protected java.io.File mOutputFile

mFileOutputStream

protected java.io.OutputStream mFileOutputStream
Constructor Detail

BytesToTempFileActivity

public BytesToTempFileActivity(org.w3c.dom.Element element)
                        throws ActivitySpecificationException,
                               ActivityCreationException
Constructs an instance of the BytesToTempFileActivity activity.

The schema of the input XML element is defined in bytes_to_temp_file.xsd. An example is:

 <bytesToTempFile name="myActivityInstance">
   <input from="inputStream"/>
   <output name="outputStream"/>
 </bytesToTempFile>
 
The input element specifies the input to this activity. The output element output stream.

Parameters:
element - parameters for the activity expressed in XML format.
Throws:
ActivitySpecificationException - if an error occurs due to the user's incorrect input.
ActivityCreationException - if a error occurs beyond the specification of the input parameters.
Method Detail

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.

getInputStreamName

public java.lang.String getInputStreamName()
Gets the activity's input stream name.

Returns:
Name of the activity's input stream.

getOutputStreamName

public java.lang.String getOutputStreamName()
Gets the activity's output stream name.

Returns:
Name of activity's output stream.

processBlock

protected 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