List of usage examples for org.springframework.web.servlet.mvc.method.annotation ServletInvocableHandlerMethod setHandlerMethodReturnValueHandlers
public void setHandlerMethodReturnValueHandlers(HandlerMethodReturnValueHandlerComposite returnValueHandlers)
From source file:org.fao.geonet.kernel.SpringLocalServiceInvoker.java
public Object invoke(HttpServletRequest request, HttpServletResponse response) throws Exception { HandlerExecutionChain handlerExecutionChain = requestMappingHandlerMapping.getHandler(request); HandlerMethod handlerMethod = (HandlerMethod) handlerExecutionChain.getHandler(); ServletInvocableHandlerMethod servletInvocableHandlerMethod = new ServletInvocableHandlerMethod( handlerMethod);//from ww w .ja v a 2s.com servletInvocableHandlerMethod.setHandlerMethodArgumentResolvers(argumentResolvers); servletInvocableHandlerMethod.setHandlerMethodReturnValueHandlers(returnValueHandlers); servletInvocableHandlerMethod.setDataBinderFactory(webDataBinderFactory); Object o = servletInvocableHandlerMethod.invokeForRequest(new ServletWebRequest(request, response), null, new Object[0]); // check whether we need to further process a "forward:" response if (o instanceof String) { String checkForward = (String) o; if (checkForward.startsWith("forward:")) { // // if the original url ends with the first component of the fwd url, then concatenate them, otherwise // just invoke it and hope for the best... // eg. local://srv/api/records/urn:marlin.csiro.au:org:1_organisation_name // returns forward:urn:marlin.csiro.au:org:1_organisation_name/formatters/xml // so we join the original url and the forwarded url as: // /api/records/urn:marlin.csiro.au:org:1_organisation_name/formatters/xml and invoke it. // String fwdUrl = StringUtils.substringAfter(checkForward, "forward:"); String lastComponent = StringUtils.substringAfterLast(request.getRequestURI(), "/"); if (lastComponent.length() > 0 && StringUtils.startsWith(fwdUrl, lastComponent)) { return invoke(request.getRequestURI() + StringUtils.substringAfter(fwdUrl, lastComponent)); } else { return invoke(fwdUrl); } } } return o; }