* Delegate method for the servlet. Services the request.
*/
public void service(WebRequest request, WebResponse response) throws IOException
{
IRequestCycle cycle = null;
IMonitor monitor = null;
IEngineService service = null;
if (_infrastructure == null)
_infrastructure = (Infrastructure) request.getAttribute(Constants.INFRASTRUCTURE_KEY);
try
{
try
{
cycle = _infrastructure.getRequestCycleFactory().newRequestCycle(this);
monitor = cycle.getMonitor();
service = cycle.getService();
monitor.serviceBegin(service.getName(), _infrastructure.getRequest()
.getRequestURI());
// Let the service handle the rest of the request.
service.service(cycle);
return;
}
catch (PageRedirectException ex)
{
handlePageRedirectException(cycle, ex);
}
catch (RedirectException ex)
{
handleRedirectException(cycle, ex);
}
catch (StaleLinkException ex)
{
handleStaleLinkException(cycle, ex);
}
catch (StaleSessionException ex)
{
handleStaleSessionException(cycle, ex);
}
}
catch (Exception ex)
{
monitor.serviceException(ex);
// Attempt to switch to the exception page. However, this may itself
// fail for a number of reasons, in which case an ApplicationRuntimeException is
// thrown.
if (LOG.isDebugEnabled())
LOG.debug("Uncaught exception", ex);
activateExceptionPage(cycle, ex);
}
finally
{
if (service != null)
monitor.serviceEnd(service.getName());
try
{
cycle.cleanup();
_infrastructure.getApplicationStateManager().flush();
}
catch (Exception ex)
{
reportException(EngineMessages.exceptionDuringCleanup(ex), ex);