uk.org.ogsadai.engine
Class Activity

java.lang.Object
  |
  +--uk.org.ogsadai.engine.Activity
Direct Known Subclasses:
AbstractDeliverFromAddressActivity, AbstractDeliverToAddressActivity, AbstractFileActivity, AbstractGDTDeliveryActivity, BfActivity, BlockAggregatorActivity, DataStoreActivity, DeliverToSMTPActivity, DeliverToStreamActivity, ExampleActivity, GZIPCompressionActivity, GZIPDecompressionActivity, HelloWorldActivity, InputStreamActivity, NotificationActivity, OutputStreamActivity, SQLActivity, StringTokenizerActivity, XMLDBActivity, XSLTransformActivity, ZIPArchiveActivity

public abstract class Activity
extends java.lang.Object

This is the abstract base class for all Activity implementations. It manages the internal and external inputs and outputs, general activity termination.

Author:
The OGSA-DAI Project Team

Field Summary
protected  ActivityContext mContext
          Provides access to the data pipes, user credentials etc.
protected  java.lang.String[] mExternalInputs
          The names of the external inputs to the activity.
protected  java.lang.String[] mExternalOutputs
          The names of the external outputs to the activity.
protected  java.lang.String[] mInternalInputs
          The names of the internal inputs of the activity.
protected  java.lang.String[] mInternalOutputs
          The names of the internal outputs of the activity.
 
Constructor Summary
Activity(org.w3c.dom.Element element)
          Constructs an activity using the specified element.
Activity(java.lang.String name)
          Constructs an activity with the specified name.
 
Method Summary
protected  void cleanUp()
          This method can be overridden by any Activity implementations that need to free up resources in the event of an error or intermediate termination of the activity processing.
 boolean connectsTo(Activity activity)
          Indicates whether or not the specified activity is connected to this activity.
protected  ActivityConfiguration getActivityConfiguration()
          Accesses the ActivityConfiguration object, if applicable.
 java.lang.String getName()
          Gets the name of the activity.
protected  ObservableStatus getObservableStatus()
          Gets the current status of the activity as an ObservableStatus that can be observed using Observer implementations.
protected  java.util.Properties getProperties()
          Accesses the activity configuration properties.
protected  Status getStatus()
          Gets the current status of the activity.
protected  boolean hasActivityConfiguration()
          Indicates whether or not this activity has an ActivityConfiguration object.
protected  boolean hasProperties()
          Indicates whether or not this activity has any configuration properties.
protected  void initialise()
          This method can be overridden by subclasses to perform any initialisation they require before the process method iterations begin.
protected abstract  void processBlock()
          Performs an iteration of the processing of an activity.
protected  void processFirst()
          This method is called during the first iteration of processing an activity.
protected  void setCompleted()
          An Activity implementation should call this method to indicate that the processing is complete.
protected  void setError(ActivityException cause)
          An Activity implementation should call this method to indicate that there has been an error during processing.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

mInternalInputs

protected java.lang.String[] mInternalInputs
The names of the internal inputs of the activity.


mInternalOutputs

protected java.lang.String[] mInternalOutputs
The names of the internal outputs of the activity.


mExternalInputs

protected java.lang.String[] mExternalInputs
The names of the external inputs to the activity.


mExternalOutputs

protected java.lang.String[] mExternalOutputs
The names of the external outputs to the activity.


mContext

protected ActivityContext mContext
Provides access to the data pipes, user credentials etc.

Constructor Detail

Activity

public Activity(org.w3c.dom.Element element)
         throws ActivitySystemException,
                ActivityUserException
Constructs an activity using the specified element. The name of the activity will be retrieved from element's name attribute.

Parameters:
element - The Element to configure the activity with.
Throws:
ActivitySystemException - If there is a problem constructing the activity due to an implementation error or OGSA-DAI confguration problem.
ActivityUserException - If there is a problem constructing the activity due to a user mistake such as an invalid setting.

Activity

public Activity(java.lang.String name)
Constructs an activity with the specified name.

Parameters:
name - the String name of the activity
Method Detail

cleanUp

protected void cleanUp()
This method can be overridden by any Activity implementations that need to free up resources in the event of an error or intermediate termination of the activity processing.


getName

public final java.lang.String getName()
Gets the name of the activity. All activity's within a request have distinct names.

Returns:
a String containing the activity's name.

getStatus

protected final Status getStatus()
Gets the current status of the activity.

Returns:
a Status object indicating the activity's current status.

getObservableStatus

protected final ObservableStatus getObservableStatus()
Gets the current status of the activity as an ObservableStatus that can be observed using Observer implementations.

Returns:
an ObservableStatus object indicating the activity's current status.

initialise

protected void initialise()
                   throws ActivitySystemException,
                          ActivityUserException
This method can be overridden by subclasses to perform any initialisation they require before the process method iterations 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.

Throws:
ActivitySystemException - If a system problem prevents the activity from initialising.
ActivityUserException - If a user problem prevents the activity from initialising.

processFirst

protected void processFirst()
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.


processBlock

protected abstract void processBlock()
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.


setCompleted

protected final void setCompleted()
An Activity implementation should call this method to indicate that the processing is complete. This sets the activity status.


setError

protected final void setError(ActivityException cause)
An Activity implementation should call this method to indicate that there has been an error during processing. This sets the activity status and calls the cleanUp method.

Parameters:
cause - an Exception describing the reason for the error.

getProperties

protected java.util.Properties getProperties()
Accesses the activity configuration properties.

Returns:
a Properties object containing the activity properties or null if this activity does not have any properties

hasProperties

protected boolean hasProperties()
Indicates whether or not this activity has any configuration properties. If so, they can be accessed via the getProperties method.

Returns:
true if the activity does has configuration, otherwise false

hasActivityConfiguration

protected boolean hasActivityConfiguration()
Indicates whether or not this activity has an ActivityConfiguration object. If so, it can be accessed using the getActivityConfiguration method.

Returns:
true if the activity does have an ActivityConfiguration object, otherwise false

getActivityConfiguration

protected ActivityConfiguration getActivityConfiguration()
Accesses the ActivityConfiguration object, if applicable.

Returns:
a Properties reference
See Also:
hasActivityConfiguration()

connectsTo

public boolean connectsTo(Activity activity)
Indicates whether or not the specified activity is connected to this activity.

Parameters:
activity - the activity to check for a connection
Returns:
true if the specified activity is connected to this activity, otherwise false