|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--uk.org.ogsadai.activity.ActivityRequest
Implementation of interface Request
that encapsulates
all of the objects required to create, process and obtain responses
from a single request. It also encapsulates the state-machine logic
used to track down the processing status of the request.
Nested Class Summary | |
private class |
ActivityRequest.TimeOutTask
Auxialliary timer task class associated with the timeout timer |
Field Summary | |
private static java.lang.String |
COPYRIGHT_NOTICE
Copyright statement. |
private static DAILogger |
LOG
Logger object for this request. |
private ActivityContext |
mActivityContext
Activity context for the activities in the request. |
private EngineConfiguration |
mConfiguration
Engine configuration information. |
private ProcessingStatusObserver |
mObserver
Observer object for detecting completion |
private RequestComponent |
mRequest
References the top-level component of the composite object representing a single request. |
private RequestContext |
mRequestContext
Context for this request. |
private ResponseBuilder |
mResponseBuilder
Response builder used for assembling the response to the request. |
private Session |
mSession
The session that the request has joined. |
private ProcessingStatus |
mStatus
The observable status for this request. |
private SessionStrategy |
mStrategy
The session access strategy for the request. |
private java.lang.Thread |
mThread
Thread used for processing this request. |
private java.util.Timer |
mTimeOutTimer
The timer object responsible for effectinbg time-outs. |
Constructor Summary | |
ActivityRequest(RequestComponent composite,
SessionStrategy strategy)
Constructs an instance associated with a specific request component and session strategy. |
Method Summary | |
private void |
endProcessing()
Ends the processing of this request, leaving the status unaffected. |
(package private) RequestComponent |
getRequestComposite()
Returns the composite RequestComponent for the
request. |
Session |
getSession()
Gets the Session that the session participant is
joined to. |
SessionStrategy |
getSessionStrategy()
Gets the SessionStrategy object for the session
participant. |
ProcessingStatus |
getStatus()
Returns the processing status of this request. |
void |
initialise(EngineConfiguration config,
RequestContext context,
ResponseBuilder builder)
Initialises this request before its processing can commence. |
void |
process()
Initiates the processing of the request. |
private void |
processAsynchronously()
Spawn a processing thread and process the request asynchronously. |
private void |
reportError(java.lang.Exception cause)
This is invoked when an error occurs while processing the request. |
void |
setSession(Session session)
Provides the session participant with the session to which it is joined. |
void |
terminate()
Terminates the request. |
void |
waitForResponse()
Waits for the response building to complete. |
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 RequestComponent mRequest
private java.lang.Thread mThread
private final ProcessingStatus mStatus
private SessionStrategy mStrategy
private Session mSession
private RequestContext mRequestContext
private ActivityContext mActivityContext
private ResponseBuilder mResponseBuilder
private EngineConfiguration mConfiguration
private ProcessingStatusObserver mObserver
private java.util.Timer mTimeOutTimer
null
if timeouts aren't used.
Constructor Detail |
public ActivityRequest(RequestComponent composite, SessionStrategy strategy)
composite
- Request component.strategy
- Session strategy.Method Detail |
public ProcessingStatus getStatus()
getStatus
in interface Request
Status
object.public void initialise(EngineConfiguration config, RequestContext context, ResponseBuilder builder) throws java.lang.IllegalStateException, RequestSpecificationException, RequestExecutionException
Request
Initialisation may be performed once only, prior to invoking
any of the other methods on the Request
interface.
initialise
in interface Request
java.lang.IllegalStateException
- If invoked after the processing of the request has been
initiated or terminated.
RequestExecutionException
- if the request fails to execute due to a problem in the
e.g. a database connection disappears or a file is
corrupted.
RequestSpecificationException
- if the request fails to execute due to a problem in the
request e.g. it specifies an unsupported activity or a
query expression is has incorrect syntax.public void process() throws java.lang.IllegalStateException
Request
ResponseBuilder
passed into the
process
method.
All implementations of this method must ensure that processing is a non-blocking operation; e.g., by delegating the actual processing to a separate thread. This method should return as soon as processing is suitably initiated and should not wait until processing completes.
process
in interface Request
java.lang.IllegalStateException
- if invoked before the request has been initialised, or after
processing has commenced, completed or terminated.public void terminate()
Request
terminate
in interface Request
private void endProcessing()
public void waitForResponse()
Request
ResponseBuilder
. This may or may not indicate that
the request processing is complete, depending on the type of
request. For example some requests produce no response data, so
the response may be available before processing completes.
waitForResponse
in interface Request
private final void reportError(java.lang.Exception cause)
cause
- The cause of the errorprivate void processAsynchronously()
public SessionStrategy getSessionStrategy()
SessionParticipant
SessionStrategy
object for the session
participant.
This object understands how to obtain the session from the
SessionManager
for this session participant.
getSessionStrategy
in interface SessionParticipant
SessionStrategy
object.public void setSession(Session session)
SessionParticipant
getSession()
method.
setSession
in interface SessionParticipant
session
- The Session
for the participant to join.public Session getSession()
SessionParticipant
Session
that the session participant is
joined to.
This can only be invoked after the setSession()
method has been invoked.
getSession
in interface SessionParticipant
RequestComponent getRequestComposite()
RequestComponent
for the
request. This accessor method provided for testing purposes.
ResourceComponent
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |