|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--uk.org.ogsadai.activity.Activity
This is the abstract base class for all Activity
implementations. It provides access to the activity inputs and outputs, configuration, context and session. It also defines a number of methods for setting the status of activity processing.
A concrete activity implementation must define a constructor and implement the processBlock
method, and may override the initialise
, processFirst
and cleanUp
methods.
Field Summary | |
private static java.lang.String |
COPYRIGHT_NOTICE Copyright statement. |
private static DAILogger |
LOG Logger object for logging in this class. |
private java.lang.String |
mActivityName The type of the activity. |
private java.lang.Throwable |
mCause Cause of any error that arises during processing. |
private ActivityConfiguration |
mConfiguration Activity configuration object, if applicable, otherwise null . |
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. |
private java.lang.String |
mName The name of the activity. |
private java.util.Properties |
mProperties Activity configuration properties, if applicable, otherwise null . |
private ActivityRequest |
mRequest Activity request containing the activity. |
private Session |
mSession Session that the activity belongs to. |
private ObservableStatus |
mStatus Current status 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. |
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. |
(package private) void |
configureContext(ActivityContext context, Session session) Configures the activity by creating pipes for each internal output, and each external input and output. |
boolean |
connectsTo(Activity activity) Indicates whether or not the specified activity is connected to this activity. |
protected Pipe |
createOutputPipe(int i) Creates an output pipe for an internal output. |
protected ActivityConfiguration |
getActivityConfiguration() Accesses the ActivityConfiguration object, if applicable. |
java.lang.String |
getActivityName() Returns the name of the activity type. |
(package private) java.lang.String[] |
getAllOutputs() Gets the names of the internal and external activity outputs. |
java.lang.Throwable |
getCause() If the activity has entered a Status.ERROR state during processing then this method can be used to retrieve the cause of the error. |
(package private) java.lang.String[] |
getExternalInputs() Gets the names of the external activity inputs. |
(package private) java.lang.String[] |
getExternalOutputs() Gets the names of the external outputs of this activity. |
(package private) java.lang.String[] |
getInputs() Gets the names of the internal activity inputs. |
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. |
(package private) java.lang.String[] |
getOutputs() Gets the names of the internal activity outputs. |
protected java.util.Properties |
getProperties() Accesses the activity configuration properties. |
protected Session |
getSession() Gets the session that this activity belongs to. |
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 should be overridden by subclasses to perform any initialisation they require before the process method invocations begin. |
void |
process() Processes the activity implementation. |
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. |
(package private) void |
setActivityConfiguration(ActivityConfiguration configuration) Sets the ActivityConfiguration object. |
void |
setActivityName(java.lang.String activityName) Sets the name of the activity type. |
protected void |
setCompleted() An Activity implementation should call this method to indicate that the processing is complete. |
protected void |
setError(java.lang.Throwable cause) An Activity implementation should call this method to indicate that there has been an error during processing. |
(package private) void |
setProperties(java.util.Properties properties) Sets the (optional) activity configuation properties. |
(package private) void |
terminate() Terminates the activity processing. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
private static final java.lang.String COPYRIGHT_NOTICE
private static final DAILogger LOG
private final java.lang.String mName
private java.lang.String mActivityName
private java.util.Properties mProperties
null
.
private ActivityConfiguration mConfiguration
null
.
protected java.lang.String[] mInternalInputs
protected java.lang.String[] mInternalOutputs
protected java.lang.String[] mExternalInputs
protected java.lang.String[] mExternalOutputs
protected ActivityContext mContext
private Session mSession
private ActivityRequest mRequest
private final ObservableStatus mStatus
private java.lang.Throwable mCause
Constructor Detail |
public Activity(org.w3c.dom.Element element) throws ActivityCreationException, ActivitySpecificationException
name
attribute.
element
- Element
to configure the activity with - from a perform document.ActivityCreationException
- If there is a problem constructing the activity due to an implementation error or OGSA-DAI confguration problem.ActivitySpecificationException
- If there is a problem constructing the activity due to an invalid setting in element
. mistake such as an invalid setting.public Activity(java.lang.String name)
name
- The String
name of the activityMethod Detail |
protected void cleanUp()
Activity
implementations that need to free up resources in the event of an error or intermediate termination of the activity processing.
final void configureContext(ActivityContext context, Session session) throws SessionRequestException, DuplicatePipeException
initialise
method to be invoked and then for processing to commence.
context
- Context for the activity RequestContext
to configure.session
- Session that the request containing the activity has been joined to.DuplicatePipeException
- If there is a duplicate pipe declared in the activity.SessionRequestException
- If there is a problem storing the external inputs or outputs in the session.protected Pipe createOutputPipe(int i)
i
- Index of the output pipe.final java.lang.String[] getInputs()
String[]
containing the input names. If there are no inputs then this will be an empty array.final java.lang.String[] getOutputs()
String[]
containing the output names. If there are no outputs then this will be an empty array.final java.lang.String[] getAllOutputs()
String[]
containing output names. If there are no outputs then this will be an empty array.final java.lang.String[] getExternalInputs()
String[]
containing the external input names. If there are no inputs then this will be an empty array.final java.lang.String[] getExternalOutputs()
String[]
containing the external output names. If there are no outputs then this will be an empty array.public final java.lang.String getName()
String
containing the activity's name.public final Status getStatus()
protected final ObservableStatus getObservableStatus()
ObservableStatus
that can be observed using Observer
implementations.
ObservableStatus
object indicating the activity's current status.protected void initialise() throws ActivitySpecificationException, ActivityExecutionException
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
.
ActivitySpecificationException
- If a problem with settings provided by a client prevents the activity from initialising.ActivityExecutionException
- If some system problem prevents the activity from initialising.public final void process()
getStatus().isFinished()
returns true.
protected void processFirst()
protected abstract void processBlock()
setCompleted
method to indicate that processing is complete, or the setError
method if an error occurs that will prevent the processing from completing.
protected final void setCompleted()
Activity
implementation should call this method to indicate that the processing is complete. This sets the activity status to completed.
protected final void setError(java.lang.Throwable cause)
Activity
implementation should call this method to indicate that there has been an error during processing. This sets the activity status to error and calls the cleanUp
method.
cause
- An exception describing the reason for the error.public final java.lang.Throwable getCause()
Status.ERROR
state during processing then this method can be used to retrieve the cause of the error.
null
if there were no errors.final void terminate()
Status.TERMINATED
and invokes the cleanUp
method.
void setProperties(java.util.Properties properties)
properties
- Activity configuration properties.protected java.util.Properties getProperties()
Properties
object containing the activity properties or null
if this activity does not have any properties.protected boolean hasProperties()
getProperties
method.
true
if the activity does has configuration, otherwise false
.void setActivityConfiguration(ActivityConfiguration configuration)
ActivityConfiguration
object. This is invoked by an ActivityCreator
, if an Activity
makes use of an individual ActivityConfiguration
object. Note that many activities do not use ActivityConfiguration
objects. TODO TS move this method into ConfigurarableActivity interface
configuration
- Activity configuration information.protected boolean hasActivityConfiguration()
ActivityConfiguration
object. If so, it can be accessed using the getActivityConfiguration
method. TODO TS move this method into ConfigurarableActivity interface or remove if no longer necessary
true
if the activity does have an ActivityConfiguration
object, otherwise false
.protected ActivityConfiguration getActivityConfiguration()
ActivityConfiguration
object, if applicable. TODO TS move this method into ConfigurarableActivity interface
Properties
referencehasActivityConfiguration()
public boolean connectsTo(Activity activity)
activity
- The activity to check for a connectiontrue
if the specified activity is connected to this activity, otherwise false
protected final Session getSession()
java.lang.IllegalStateException
- If invoked before the activity's session has been set. An activity should wait until it's initialise
method is called before attempting to access its session.public final void setActivityName(java.lang.String activityName)
activityName
- activity type namepublic final java.lang.String getActivityName()
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |