use of cn.taketoday.web.handler.SelectableReturnValueHandler in project today-framework by TAKETODAY.
the class WebApplicationLoader method configureReturnValueHandler.
/**
* Configure {@link ReturnValueHandler} to resolve handler method result
*
* @param handlers {@link ReturnValueHandler} registry
* @param mvcConfiguration All {@link WebMvcConfiguration} object
*/
protected void configureReturnValueHandler(List<ReturnValueHandler> handlers, WebMvcConfiguration mvcConfiguration) {
DispatcherHandler obtainDispatcher = obtainDispatcher();
SelectableReturnValueHandler existingHandlers = obtainDispatcher.getReturnValueHandler();
if (existingHandlers != null) {
handlers.addAll(existingHandlers.getInternalHandlers());
}
WebApplicationContext context = obtainApplicationContext();
// @since 3.0
ReturnValueHandlerManager manager = context.getBean(ReturnValueHandlerManager.class);
Assert.state(manager != null, "No ReturnValueHandlers");
// user config
mvcConfiguration.configureResultHandler(handlers);
manager.addHandlers(handlers);
// apply result handler
SelectableReturnValueHandler selectable = new SelectableReturnValueHandler(manager.getHandlers());
selectable.trimToSize();
obtainDispatcher.setReturnValueHandler(selectable);
}
Aggregations