Search in sources :

Example 1 with ReturnValueHandlerManager

use of cn.taketoday.web.handler.ReturnValueHandlerManager in project today-infrastructure by TAKETODAY.

the class RequestMappingHandlerAdapter method setReturnValueHandlerManager.

/**
 * Configure the complete list of supported return value types thus
 * overriding handlers that would otherwise be configured by default.
 */
public void setReturnValueHandlerManager(@Nullable ReturnValueHandlerManager manager) {
    if (manager == null) {
        manager = new ReturnValueHandlerManager();
        manager.setApplicationContext(getApplicationContext());
        manager.registerDefaultHandlers();
    }
    this.returnValueHandlerManager = manager;
}
Also used : ReturnValueHandlerManager(cn.taketoday.web.handler.ReturnValueHandlerManager)

Example 2 with ReturnValueHandlerManager

use of cn.taketoday.web.handler.ReturnValueHandlerManager in project today-framework by TAKETODAY.

the class RequestMappingHandlerAdapter method setReturnValueHandlerManager.

/**
 * Configure the complete list of supported return value types thus
 * overriding handlers that would otherwise be configured by default.
 */
public void setReturnValueHandlerManager(@Nullable ReturnValueHandlerManager manager) {
    if (manager == null) {
        manager = new ReturnValueHandlerManager();
        manager.setApplicationContext(getApplicationContext());
        manager.registerDefaultHandlers();
    }
    this.returnValueHandlerManager = manager;
}
Also used : ReturnValueHandlerManager(cn.taketoday.web.handler.ReturnValueHandlerManager)

Example 3 with ReturnValueHandlerManager

use of cn.taketoday.web.handler.ReturnValueHandlerManager in project today-framework by TAKETODAY.

the class HandlerMethodTests method setResultHandlers.

private void setResultHandlers(HandlerMethod produceMethod, ApplicationContext applicationContext) {
    final ReturnValueHandlerManager resultHandlers = new ReturnValueHandlerManager();
    resultHandlers.setApplicationContext(applicationContext);
    resultHandlers.setViewResolver(new DefaultTemplateViewResolver());
    resultHandlers.registerDefaultHandlers();
}
Also used : DefaultTemplateViewResolver(cn.taketoday.web.view.template.DefaultTemplateViewResolver) ReturnValueHandlerManager(cn.taketoday.web.handler.ReturnValueHandlerManager)

Example 4 with ReturnValueHandlerManager

use of cn.taketoday.web.handler.ReturnValueHandlerManager 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

ReturnValueHandlerManager (cn.taketoday.web.handler.ReturnValueHandlerManager)4 WebApplicationContext (cn.taketoday.web.WebApplicationContext)1 DispatcherHandler (cn.taketoday.web.handler.DispatcherHandler)1 SelectableReturnValueHandler (cn.taketoday.web.handler.SelectableReturnValueHandler)1 DefaultTemplateViewResolver (cn.taketoday.web.view.template.DefaultTemplateViewResolver)1