uk.org.ogsadai.activity.misc
Class DataStoreActivity

java.lang.Object
  |
  +--uk.org.ogsadai.activity.Activity
        |
        +--uk.org.ogsadai.activity.misc.DataStoreActivity

public class DataStoreActivity
extends Activity

The DataStoreActivity acts as a cache of data from which other activities can retrieve blocks at their convenience. These activities must belong to the same request and the cached data does not persist after the request has completed. There are 2 different modes of operation:

  1. one input - the activity reads all the data from the input as soon as possible. Other activities can then read this data from the output.
  2. no input - data is hard-coded into the perform document in blocks. Other activities can read this data from the output.

The

The DataStoreActivity is particularly useful for requests containing a database query connected to an asynchronous delivery activity. Under normal circumstances the database query will not be evaluated until the consumer of the asynchronous delivery begins consumption. A DataStoreActivity can be connected between the database query and asynchrnonous delivery activity to ensure that the database query is evaluated immediately, rather than waiting until the consumer of the asynchronous delivery begins consumption.

Note that at the moment the actual cache implementation is simply an ArrayList accessed through an iterator. For large amounts of data this is likely to generate an OutOfMemoryError. In the future this could be modified to use some kind of semi-persistent storage.

See the activity user documentation for more details: OGSADAI/doc/interaction/activities/misc/dataStore.html

Author:
The OGSA-DAI Project Team

Field Summary
private static java.lang.String COPYRIGHT_NOTICE
          Copyright statement.
private  BlockReader mInput
          Input from which data may be read before activity processing begins.
private  java.util.Iterator mItems
          Iterates through the items stored in the cache.
private  BlockWriter mOutput
          Output to which the data contained in the cache is written.
private  boolean mValuesHardcoded
          Mode of operation: true for data hardcoded, false for data read from input.
 
Fields inherited from class uk.org.ogsadai.activity.Activity
mContext, mExternalInputs, mExternalOutputs, mInternalInputs, mInternalOutputs
 
Constructor Summary
DataStoreActivity(org.w3c.dom.Element element)
           
 
Method Summary
private  void constructHardcoded(org.w3c.dom.Element element)
          Completes construction for the activity using the hardcoded data mode.
private  void constructInputFed(org.w3c.dom.Element element)
          Completes construction for the activity using the input-fed mode.
private  java.lang.Object getItemObject(org.w3c.dom.Element itemElement)
          Adds the contents of an item element to the data store.
 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

mValuesHardcoded

private boolean mValuesHardcoded
Mode of operation: true for data hardcoded, false for data read from input.


mInput

private BlockReader mInput
Input from which data may be read before activity processing begins.


mOutput

private BlockWriter mOutput
Output to which the data contained in the cache is written.


mItems

private java.util.Iterator mItems
Iterates through the items stored in the cache. This is the only field through which the cache is actually available.

Constructor Detail

DataStoreActivity

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

constructInputFed

private void constructInputFed(org.w3c.dom.Element element)
Completes construction for the activity using the input-fed mode.

Parameters:
element - Activity element from the request containing the activity settings.

constructHardcoded

private void constructHardcoded(org.w3c.dom.Element element)
                         throws ActivitySpecificationException
Completes construction for the activity using the hardcoded data mode.

Parameters:
element - Activity element from the request containing the activity settings.
Throws:
ActivitySpecificationException - If the data is not a text node, CDATA section or element, or if the data is a text node or CDATA section it is an XML fragment.

getItemObject

private java.lang.Object getItemObject(org.w3c.dom.Element itemElement)
                                throws ActivitySpecificationException
Adds the contents of an item element to the data store.

Parameters:
itemElement - Element from the activity element in the request that contains the hard-coded data.
Throws:
ActivitySpecificationException - If the data is not a text node, CDATA section or element, or if the data is a text node or CDATA section it is an XML fragment.

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

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.