This section provides an overview of the lifecycle of an
AJAX request in the IBM® WebSphere® Multichannel Bank
Transformation Toolkit AJAX channel.
Figure 1 shows the lifecycle of
an AJAX request in the WebSphere Multichannel
Bank Transformation Toolkit AJAX channel.
Figure 1. Lifecycle of an AJAX request in the WebSphere Multichannel
Bank Transformation Toolkit AJAX channel
The following list is a detailed description of how an AJAX request
is processed in the
WebSphere Multichannel
Bank Transformation Toolkit AJAX channel:
- An AJAX request that has been initiated by a user is received
by the AjaxRequestServlet servlet.
- The AjaxRequestServlet class retrieves a thread and assigns necessary
system resources that are required by the thread, and then delegates
the service method of the servlet to the thread. The thread handles
the request by running the service method.
- The service() method delegates the AJAX request to BTTChannelDriver
class, and then the driver assembles the necessary resources that
are required to process the request, e.g create handlers, initial
device, and pre-handle request data, create necessary channel data.
The BTTChannelDriver then delegates the AJAX request to the AjaxRequestHandler.
- The AjaxHtmlRequestHandler handler determines whether the AJAX
request is a duplicated request. If the AJAX request is a duplicated
request, it is ignored. For more information on the handling of duplicated
requests, refer to the “Duplicated request handling” section.
- The request operation instance is created from the operation definition
file.
- If the AJAX request is sent from an HTML processor page, the
AjaxHtmlRequestHandler will restore the processor context from the
cache, update the processor timestamp, and rebuild the processor context
hierarchy.
- If the AJAX request is not sent from an HTML processor page, the
AjaxHtmlRequestHandler chains the AJAX operation context to a session
context. If the AJAX request is sent from an HTML processor page,
the AjaxHtmlRequestHandler chains the operation context to the processor
context. Note that if the page has a state context, the current processor
context is used as the state context.
- Operations that execute with the context hierarchy retrieve necessary
data from the context tree at run time. Attention that it is suggested
to not update outer-scope contexts that are required by AJAX operations
in the concurrency environment, as this may cause critical errors.
- When an execution is complete, the operation context is unchained
from the parent context.
- The AjaxHtmlPresentationHandler method invokes the processReply()
method, which updates the data for the HTTP response message.
- If the AJAX request operation is sent from an HTML processor page,
it updates the processor timestamp and saves the processor context
into the cache.
- The response data is sent to the browser.
- The AjaxRequestServlet class determines whether the session has
expired and thenit releases resources that are no longer required.
The processor context and environment must loaded and saved an
AJAX request is received because, in an HTML channel, when a processor
state changed, e.g. processor page navigated to next page, before
state changed, it will load/create the processor environment and context
from cache, and then do processor state change, then the processor
environment and context will be saved into cache, then you can see
the page new state page displayed. So if the Ajax operation will leverage
outer-scope data to finish task, the AjaxRequestHandler method will
first repeat the processor current environment and context hierarchy
and save the processor context when Ajax request finished, so that
for the processor itself it will seems that nothing happens.