public ModelAndView doHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception { return super.handle(request, response, handler); }
/** * {@inheritDoc} */ public Map<String, Object> handleRequest(HttpServletRequest request, HttpServletResponse response) throws Exception { AnnotationMethodHandlerAdapter handlerAdapter = new AnnotationMethodHandlerAdapter(); ModelAndView mav = handlerAdapter.handle(request, response, controller); Map<String, Object> model = Collections.emptyMap(); if (mav != null && mav.getModel() != null && !mav.getModel().isEmpty()) { return mav.getModel(); } return model; }
/** * Call AnnotationMethodHandlerAdapter if State class contains request mappings. */ @Override public ModelAndView tryHandle(PfixServletRequest request, Object handler, String pageName) throws Exception { if(hasRequestMapping(handler.getClass())) { try { ControllerRequestWrapper wrappedRequest = new ControllerRequestWrapper(request, pageName); ControllerResponseWrapper response = new ControllerResponseWrapper(); return adapter.handle(wrappedRequest, response, handler); } catch(NoSuchRequestHandlingMethodException x) { //let implementing a handler method be optional and ignore this exception } } return null; }
/** * Passes the given request to a proper controller. * * @param request * @return * @throws Exception */ public MockHttpServletResponse handle(HttpServletRequest request) throws Exception { MockHttpServletResponse response = new MockHttpServletResponse(); HandlerExecutionChain handlerExecutionChain = null; for (DefaultAnnotationHandlerMapping handlerMapping : handlerMappings) { handlerMapping.setPathMatcher(pathMatcher); handlerExecutionChain = handlerMapping.getHandler(request); if (handlerExecutionChain != null) { break; } } Assert.assertNotNull("The request URI does not exist", handlerExecutionChain); handlerAdapter.setPathMatcher(pathMatcher); handlerAdapter.handle(request, response, handlerExecutionChain.getHandler()); return response; }