Search in sources :

Example 6 with DispatcherHandler

use of cn.taketoday.web.handler.DispatcherHandler 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);
}
Also used : DispatcherHandler(cn.taketoday.web.handler.DispatcherHandler) SelectableReturnValueHandler(cn.taketoday.web.handler.SelectableReturnValueHandler) ReturnValueHandlerManager(cn.taketoday.web.handler.ReturnValueHandlerManager) WebApplicationContext(cn.taketoday.web.WebApplicationContext)

Aggregations

DispatcherHandler (cn.taketoday.web.handler.DispatcherHandler)6 WebApplicationContext (cn.taketoday.web.WebApplicationContext)3 ViewControllerHandlerRegistry (cn.taketoday.web.registry.ViewControllerHandlerRegistry)2 BeanDefinitionRegistrar (cn.taketoday.context.loader.BeanDefinitionRegistrar)1 CompositeHandlerExceptionHandler (cn.taketoday.web.handler.CompositeHandlerExceptionHandler)1 HandlerAdapter (cn.taketoday.web.handler.HandlerAdapter)1 HandlerExceptionHandler (cn.taketoday.web.handler.HandlerExceptionHandler)1 RequestHandlerAdapter (cn.taketoday.web.handler.RequestHandlerAdapter)1 ReturnValueHandlerManager (cn.taketoday.web.handler.ReturnValueHandlerManager)1 SelectableReturnValueHandler (cn.taketoday.web.handler.SelectableReturnValueHandler)1 ViewControllerHandlerAdapter (cn.taketoday.web.handler.ViewControllerHandlerAdapter)1 HandlerRegistries (cn.taketoday.web.registry.HandlerRegistries)1 HandlerRegistry (cn.taketoday.web.registry.HandlerRegistry)1