throws ServletException, IOException {
ControllerDatabase controllerDb = (ControllerDatabase) ctx.getAttribute(ControllerDatabase.KEY);
ErrorHandlerFactory errorHandlerFactory = (ErrorHandlerFactory) ctx.getAttribute(ErrorHandlerFactory.KEY);
ErrorHandler errorHandler = errorHandlerFactory.createErrorHandler();
Injector injector = (Injector) ctx.getAttribute(GuiceInitializer.KEY);
AppProperties properties = (AppProperties) ctx.getAttribute(AppProperties.KEY);
ServletResourceModule.set(req, res);
View view;
try {
RequestRouter router = new HttpRequestRouter(path,
new HttpParameterMapSource(req), controllerDb.getRouter());
RoutedRequest routed = router.route();
ActionResolver resolver = new HttpActionResolver(ctx, req, httpMethod, controllerDb, injector);
ActionInvoker invoker = new HttpActionInvoker(req, res, controllerDb, routed, injector);
RequestProcessor requestProcessor = new RequestProcessor(resolver, invoker, errorHandler);
view = requestProcessor.process(routed.getController(), routed.getAction(), properties);
logger.debug("processed request for " + requestProcessor.getControllerClassName() + "; rendering...");
view.render(req, res, properties);
} catch (Throwable e) {
logger.error("error processing request: ", e);
view = errorHandler.handleError(e, properties);
if (view != null) {
/*
* we're not catching any exceptions thrown from rendering the
* error view
*/