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
See Also:
CompositeRequestComponent

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(EngineConfiguration config, RequestContext context, ResponseBuilder responseBuilder)
          Initialises the component.
 void process(EngineConfiguration config, RequestContext context, ResponseBuilder responseBuilder)
          Processes the component.
 void terminate()
          Terminates the processing of the request component.
 

Method Detail

initialise

public void initialise(EngineConfiguration config,
                       RequestContext context,
                       ResponseBuilder responseBuilder)
                throws RequestSystemException,
                       RequestUserException
Initialises the component. After this method has been returned the generatesResultData method must operational.

Parameters:
config - the configuration object for the engine that will process this request component
context - the context for the request
responseBuilder - the response builder for assembling the response document
Throws:
RequestSystemException - if there is a system problem during initialisation.
RequestUserException - if there is a user problem during initialisation.

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(EngineConfiguration config,
                    RequestContext context,
                    ResponseBuilder responseBuilder)
             throws RequestSystemException,
                    RequestUserException
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:
config - the configuration object for the engine that is processing this request component
context - the context for the request
responseBuilder - the response builder for assembling the response document during processing
Throws:
RequestSystemException - if there is a system problem initialising or processing the request.
RequestUserException - if there is a user problem initialising or processing 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