uk.org.ogsadai.engine.controlflow
Interface RequestComponent

All Known Implementing Classes:
ActivityPipelineRequestComponent, CompositeRequestComponent, FlowRequestComponent, SequenceRequestComponent

public interface RequestComponent

A RequestComponent represents a part or the whole of an OGSA-DAI request. It declares an interfact through which the component can be initialised and processed. Implementations must be thread safe because one thread may invoke the terminate method while another is running the process method.

This class is an example of the Composite design pattern and its interface declares methods for adding and retrieving child components.

Author:
The OGSA-DAI Project Team

Method Summary
 void add(RequestComponent child)
          Adds a child to a composite component.
 java.util.List children()
          Returns a non-mutable list of the children of this RequestComponent.
 boolean generatesResultData()
          Indicates whether or not this component will generate any result data.
 void initialise(ActivityContext context, Session session, ResponseBuilder responseBuilder)
          Initialises the component.
 void process(ActivityContext context, ResponseBuilder responseBuilder)
          Processes the component.
 void terminate()
          Terminates the processing of the request component.
 

Method Detail

initialise

public void initialise(ActivityContext context,
                       Session session,
                       ResponseBuilder responseBuilder)
                throws RequestSpecificationException,
                       RequestExecutionException
Initialises the component. After this method has been returned the generatesResultData method must operational.

Parameters:
context - The context for the request
session - The session for the request
responseBuilder - The response builder for assembling the response document
Throws:
RequestSpecificationException - If there is an initialisation problem caused by incorrect information in the request.
RequestExecutionException - If a problem occurs during initialisation that is not caused by incorrect information in the request.

generatesResultData

public boolean generatesResultData()
Indicates whether or not this component will generate any result data. This can only be invoked after the initialise method has returned. This method is used by the engine to determine whether to process a request synchronously or asynchronously.

Returns:
true if so, false otherwise

process

public void process(ActivityContext context,
                    ResponseBuilder responseBuilder)
             throws RequestSpecificationException,
                    RequestExecutionException
Processes the component. If this is a composite component, then any child components will be processed recursively. Wherever possible an implementation should be coded in such a way that the processing can be terminated prematurely by an invocation of the terminate method by another thread. Hence, when this method returns processing will be either complete or terminated.

Parameters:
context - The context for the request
responseBuilder - The response builder for assembling the response document during processing
Throws:
RequestSpecificationException - If there is a processing problem caused by incorrect information in the request.
RequestExecutionException - If a problem occurs during processing that is not caused by incorrect information in the request.

terminate

public void terminate()
Terminates the processing of the request component. When this method returns, any threads and other resources associated with the processing of this request must be finished with.


add

public void add(RequestComponent child)
Adds a child to a composite component. Note that an empty implementation of this method should be provided for any leaf components.

Parameters:
child - The child RequestComponent

children

public java.util.List children()
Returns a non-mutable list of the children of this RequestComponent. If this component is a leaf and not a composite then java.util.Collections.EMPTY_LIST should be returned.

Returns:
a java.util.List containing any children.