|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--java.util.Observable | +--uk.org.ogsadai.engine.RequestEngine
This implementation of the Engine
interface is designed to process perform documents containing sequences of activity elements that correspond to Activity
implementations. The RequestEngine
can not process mutliple request simultaneously and a ActivityUserException
will be thrown by the invoke
method is an attempt is made to do so. The ObservableStatus
contained in the EngineConfiguration
can be monitored to determine the status of the current request.
Field Summary | |
private static java.lang.String |
COPYRIGHT_NOTICE Copyright statement. |
private static DAILogger |
LOG Logger object for logging in this class. |
private EngineConfiguration |
mConfiguration Engine configuration information. |
private boolean |
mHasQueue Flags whether this instance has been configured with a queue or not. |
private java.util.HashSet |
mProcessingPool Processing pool of active requests |
private java.util.Observer |
mProgressMonitor Observer that monitors the processing status of active requests and removes them from the processing pool once they have stopped. |
private boolean |
mProgressMonitorEnabled Flag for enabling/disabling the progress monitor (see below) |
private Queue |
mQueue Queue of requests in waiting |
Fields inherited from class java.util.Observable |
|
Constructor Summary | |
RequestEngine(EngineConfiguration config) Constructs an engine with the specified configuration. |
Method Summary | |
int |
activeLoad() Return the active load of the request queue. |
private void |
fillUpPool() Manages the flow of requests from the queue to the processing pool. |
boolean |
isProcessing(Request request) Is the given request processing? |
boolean |
isQueueing(Request request) Is the given request queueing? |
private void |
joinSession(Request request) Joins the request to a session. |
int |
latentLoad() Return the latent load of the request queue. |
private void |
logStartOfRequest(org.w3c.dom.Document request) Logs the start of a request. |
void |
perform(Request request, RequestContext context, ResponseBuilder builder) Submits a request, in the form of a request object, and initiates its processing by the engine. |
private boolean |
process(Request request) Attempts to admit a request for active processing in the processing pool. |
private boolean |
processingPoolFull() Tests whether the processing pool can admit any further requests. |
private void |
releaseSession(Request request) Releases the request from its session. |
void |
terminate() Terminates the requests that are currently processing. |
void |
terminate(SessionID sessionID) Terminates any requests that are joined to the specified session. |
private void |
terminateActiveRequests(SessionID sessionID) Terminates any requests contained in the specified iterator that are joined to the specified session. |
private void |
terminateQueuedRequests(SessionID sessionID) Terminates any requests contained in the specified iterator that are joined to the specified session. |
Methods inherited from class java.util.Observable |
addObserver, clearChanged, countObservers, deleteObserver, deleteObservers, hasChanged, notifyObservers, notifyObservers, setChanged |
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 EngineConfiguration mConfiguration
private final java.util.HashSet mProcessingPool
private final Queue mQueue
private final boolean mHasQueue
private boolean mProgressMonitorEnabled
private final java.util.Observer mProgressMonitor
Constructor Detail |
public RequestEngine(EngineConfiguration config)
config
- An EngineConfiguration
object holding the configuration information requeired by the engine.Method Detail |
public void perform(Request request, RequestContext context, ResponseBuilder builder) throws RequestAuthorizationException, RequestSpecificationException, RequestExecutionException
Engine
perform
in interface Engine
request
- The request to be processed.context
- The context within which the request is to be processed.builder
- ResponseBuilder
to use for assembling the response to the request.RequestAuthorizationException
- if the request fails because of an authorization problem.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 terminate()
Engine
terminate
in interface Engine
public void terminate(SessionID sessionID)
Engine
terminate
in interface Engine
sessionID
- The identity of the sessionprivate void terminateActiveRequests(SessionID sessionID)
sessionID
- Session whose requests are to be terminated.private void terminateQueuedRequests(SessionID sessionID)
sessionID
- Session whose requests are to be terminated.private final void logStartOfRequest(org.w3c.dom.Document request)
request
- The request.public int latentLoad()
latentLoad
in interface Engine
public int activeLoad()
activeLoad
in interface Engine
public boolean isProcessing(Request request)
request
- A request.true
if request is processing, false
otherwise.public boolean isQueueing(Request request)
request
- A request.true
if request is queueing, false
otherwise.private void joinSession(Request request) throws RequestSpecificationException, RequestExecutionException
request
- The request to join to a sessionRequestSpecificationException
- If the request is not allowed to join the session or the session is not known.RequestExecutionException
- If some internal problem prevents the request from joining the session.private void releaseSession(Request request)
request
- The request to release. EX-TODO - THROW THESE?RequestSpecificationException
- If the session is not known.RequestExecutionException
- If some internal problem prevents the request from being released from the session.private final boolean processingPoolFull()
true
if the processing pool can admit further requests, false
otherwise.private final boolean process(Request request)
If successful, it changes the status of the request to ProcessingStatus.PROCESSING
by invoking the (non-blocking) process()
method in Request
.
Assumes that no changes are being made externally to the status of the request.
request
- The request to be admitted, assumed non-null. Unless this has a current status of ProcessingStatus.INITIALISING
the method will fail.true
if the request was successfully admitted, false
otherwise.private final void fillUpPool()
processingPoolFull()
should normally follow each invocation of this method to check whether the pool has become entirely full.
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |