public void writeJsonResponse( HttpServletRequest request, HttpServletResponse response, Object responseObject, Class<?> jsonView) throws IOException, JsonGenerationException, JsonMappingException { writeJsonResponse( response, responseObject, jsonView, configurationService.getConfiguration().isStreamResponse(), ExtDirectSpringUtil.isMultipart(request)); }
@RequestMapping(value = "/router", method = RequestMethod.POST, params = "extAction") public String router( HttpServletRequest request, HttpServletResponse response, @RequestParam("extAction") String extAction, @RequestParam("extMethod") String extMethod) throws IOException { ExtDirectResponse directResponse = new ExtDirectResponse(request); MethodInfo methodInfo = MethodInfoCache.INSTANCE.get(extAction, extMethod); Class<?> jsonView = null; boolean streamResponse; if (methodInfo != null && methodInfo.getForwardPath() != null) { return methodInfo.getForwardPath(); } else if (methodInfo != null && methodInfo.getHandlerMethod() != null) { streamResponse = configurationService.getConfiguration().isStreamResponse() || methodInfo.isStreamResponse(); HandlerMethod handlerMethod = methodInfo.getHandlerMethod(); try { ModelAndView modelAndView = null; if (configurationService.getConfiguration().isSynchronizeOnSession() || methodInfo.isSynchronizeOnSession()) { HttpSession session = request.getSession(false); if (session != null) { Object mutex = WebUtils.getSessionMutex(session); synchronized (mutex) { modelAndView = handlerAdapter.handle(request, response, handlerMethod); } } else { modelAndView = handlerAdapter.handle(request, response, handlerMethod); } } else { modelAndView = handlerAdapter.handle(request, response, handlerMethod); } ExtDirectFormPostResult formPostResult = (ExtDirectFormPostResult) modelAndView.getModel().get("extDirectFormPostResult"); directResponse.setResult(formPostResult.getResult()); directResponse.setJsonView(getJsonView(formPostResult, methodInfo.getJsonView())); } catch (Exception e) { log.error("Error calling method: " + extMethod, e.getCause() != null ? e.getCause() : e); directResponse.setResult(handleException(methodInfo, directResponse, e, request)); } } else { streamResponse = configurationService.getConfiguration().isStreamResponse(); log.error( "Error invoking method '" + extAction + "." + extMethod + "'. Method or Bean not found"); handleMethodNotFoundError(directResponse, extAction, extMethod); } writeJsonResponse( response, directResponse, jsonView, streamResponse, ExtDirectSpringUtil.isMultipart(request)); return null; }