public ModelAndView doHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception { return super.handle(request, response, handler); }
@Override public void afterPropertiesSet() throws Exception { adapter = new AnnotationMethodHandlerAdapter(); adapter.setCustomArgumentResolvers(adapterConfig.getCustomArgumentResolvers()); }
@Override protected WebDataBinder createBinder(NativeWebRequest webRequest, Object target, String objectName) throws Exception { return AnnotationMethodHandlerAdapter.this.createBinder( webRequest.getNativeRequest(HttpServletRequest.class), target, objectName); }
/** * {@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; }
/** * 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; }
@Override public void setServletContext(ServletContext servletContext) { for (DefaultAnnotationHandlerMapping handlerMapping : handlerMappings) { handlerMapping.setPathMatcher(pathMatcher); } handlerAdapter.setPathMatcher(pathMatcher); } }
@Override public ModelAndView handle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception { Class<?> clazz = ClassUtils.getUserClass(handler); Boolean annotatedWithSessionAttributes = this.sessionAnnotatedClassesCache.get(clazz); if (annotatedWithSessionAttributes == null) { annotatedWithSessionAttributes = (AnnotationUtils.findAnnotation(clazz, SessionAttributes.class) != null); this.sessionAnnotatedClassesCache.put(clazz, annotatedWithSessionAttributes); } if (annotatedWithSessionAttributes) { checkAndPrepare(request, response, this.cacheSecondsForSessionAttributeHandlers, true); } else { checkAndPrepare(request, response, true); } // Execute invokeHandlerMethod in synchronized block if required. if (this.synchronizeOnSession) { HttpSession session = request.getSession(false); if (session != null) { Object mutex = WebUtils.getSessionMutex(session); synchronized (mutex) { return invokeHandlerMethod(request, response, handler); } } } return invokeHandlerMethod(request, response, handler); }
@Override protected HttpInputMessage createHttpInputMessage(NativeWebRequest webRequest) throws Exception { HttpServletRequest servletRequest = webRequest.getNativeRequest(HttpServletRequest.class); return AnnotationMethodHandlerAdapter.this.createHttpInputMessage(servletRequest); }
@Override protected HttpOutputMessage createHttpOutputMessage(NativeWebRequest webRequest) throws Exception { HttpServletResponse servletResponse = (HttpServletResponse) webRequest.getNativeResponse(); return AnnotationMethodHandlerAdapter.this.createHttpOutputMessage(servletResponse); }
/** * 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; }