uk.org.ogsadai.engine.controlflow
Class FlowRequestComponent

java.lang.Object
  |
  +--uk.org.ogsadai.engine.controlflow.CompositeRequestComponent
        |
        +--uk.org.ogsadai.engine.controlflow.FlowRequestComponent
All Implemented Interfaces:
RequestComponent

public class FlowRequestComponent
extends CompositeRequestComponent
implements RequestComponent

A composite RequestComponent that contains a number of child components which will be processed concurrently when the process method is invoked.

Author:
The OGSA-DAI Project Team

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.Exception mCause
??????????The exception that caused the processing to fail.
private ?java.lang.String mName
??????????Unique name of this flow request component.
private ?java.util.List mThreads
??????????The additional threads spawned to process child 2 to n.
?
Fields inherited from class uk.org.ogsadai.engine.controlflow.CompositeRequestComponent
?
Constructor Summary
FlowRequestComponent(java.lang.String?name)
??????????Constructor
?
Method Summary
private ?boolean hasException()
??????????Was there an exception raised during processing?
private ?void joinThreads()
??????????Joins any additional threads that were spawned.
?void process(ActivityContext?context, ResponseBuilder?responseBuilder)
??????????Processes the component.
private ?void raiseException()
??????????If an exception was raised during processing then throw it now.
private ?void reportException(java.lang.Exception?cause, ResponseBuilder?responseBuilder)
??????????Invoked when an exception is raised by one of the processing threads.
private ?void spawnThreads(java.util.List?children, ActivityContext?context, ResponseBuilder?responseBuilder)
??????????This will spawn any additional processing threads that are needed.
?void terminate()
??????????Terminates the processing of the request component.
?
Methods inherited from class uk.org.ogsadai.engine.controlflow.CompositeRequestComponent
add, children, generatesResultData, initialise
?
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
?
Methods inherited from interface uk.org.ogsadai.engine.controlflow.RequestComponent
add, children, generatesResultData, initialise
?

Field Detail

COPYRIGHT_NOTICE

private static final java.lang.String COPYRIGHT_NOTICE
Copyright statement.

See Also:
Constant Field Values

LOG

private static final DAILogger LOG
Logger object for logging in this class.


mThreads

private java.util.List mThreads
The additional threads spawned to process child 2 to n.


mCause

private java.lang.Exception mCause
The exception that caused the processing to fail.


mName

private final java.lang.String mName
Unique name of this flow request component.

Constructor Detail

FlowRequestComponent

public FlowRequestComponent(java.lang.String?name)
Constructor

Parameters:
name - Unique name of this flow request component.
Method Detail

process

public void process(ActivityContext?context,
                    ResponseBuilder?responseBuilder)
             throws RequestSpecificationException,
                    RequestExecutionException
Description copied from interface: RequestComponent
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.

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

spawnThreads

private void spawnThreads(java.util.List?children,
                          ActivityContext?context,
                          ResponseBuilder?responseBuilder)
This will spawn any additional processing threads that are needed. If there is only 1 child, then none are needed, but otherwise each additional component will be spawned in its own thread. After invocation the mThreads attribute will be populated.

Parameters:
children - Child components of the flow request component.
context - Execution context for activity execution.
responseBuilder - Response document builder - used to handle insertion of information about processing results and exceptions.

joinThreads

private void joinThreads()
Joins any additional threads that were spawned.


reportException

private void reportException(java.lang.Exception?cause,
                             ResponseBuilder?responseBuilder)
Invoked when an exception is raised by one of the processing threads. In this case, all of the request components are explicitly terminated.

Parameters:
cause - Exception raised by processing thread.
responseBuilder - Response document builder - used to handle insertion of information about the exception.

hasException

private boolean hasException()
Was there an exception raised during processing?

Returns:
true if an exception was raised, false otherwise.

raiseException

private void raiseException()
                     throws RequestSpecificationException,
                            RequestExecutionException
If an exception was raised during processing then throw it now.

Throws:
RequestExecutionException - if that was the exception raised during processing.
RequestSpecificationException - if that was the exception raised during processing.

terminate

public void terminate()
Description copied from interface: RequestComponent
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.

Specified by:
terminate in interface RequestComponent