程序包 cn.taketoday.web

接口 HandlerAdapter

所有已知实现类:
AbstractHandlerAdapter, AbstractHandlerMethodAdapter, HandlerAdapters, HandlerFunctionAdapter, InterceptableHandlerAdapterDecorator, RequestMappingHandlerAdapter, ServletHandlerAdapter

public interface HandlerAdapter
MVC framework SPI, allowing parameterization of the core MVC workflow.

Interface that must be implemented for each handler type to handle a request. This interface is used to allow the DispatcherHandler to be indefinitely extensible. The DispatcherHandler accesses all installed handlers through this interface, meaning that it does not contain code specific to any handler type.

Note that a handler can be of type Object. This is to enable handlers from other frameworks to be integrated with this framework without custom coding, as well as to allow for annotation-driven handler objects that do not obey any specific Java interface.

This interface is not intended for application developers. It is available to handlers who want to develop their own web workflow.

Note: HandlerAdapter implementors may implement the Ordered interface to be able to specify a sorting order (and thus a priority) for getting applied by the DispatcherHandler. Non-Ordered instances get treated as lowest priority.

Note: This framework allows use HandlerAdapterCapable to specific a HandlerAdapter at startup time

从以下版本开始:
2019-12-08 20:23
作者:
Harry Yang
另请参阅:
  • 字段概要

    字段
    修饰符和类型
    字段
    说明
    static final String
    Well-known name for the HandlerAdapter object in the bean factory for this namespace.
    static final Object
    This value indicates that the handler did not return a value, or the result has been processed
  • 方法概要

    修饰符和类型
    方法
    说明
    find(cn.taketoday.context.ApplicationContext context)
     
    find(cn.taketoday.context.ApplicationContext context, boolean detectAllHandlerAdapters)
     
    handle(RequestContext context, Object handler)
    Use the given handler to handle this request.
    of(List<HandlerAdapter> handlerAdapters)
     
    boolean
    supports(Object handler)
    Given a handler instance, return whether support or not this RequestHandlerAdapter can support it.
  • 字段详细资料

    • HANDLER_ADAPTER_BEAN_NAME

      static final String HANDLER_ADAPTER_BEAN_NAME
      Well-known name for the HandlerAdapter object in the bean factory for this namespace. Only used when "detectAllHandlerAdapters" is turned off.
      另请参阅:
    • NONE_RETURN_VALUE

      static final Object NONE_RETURN_VALUE
      This value indicates that the handler did not return a value, or the result has been processed
  • 方法详细资料

    • supports

      boolean supports(Object handler)
      Given a handler instance, return whether support or not this RequestHandlerAdapter can support it. Typical RequestHandlerAdapters will base the decision on the handler type. RequestHandlerAdapters will usually only support one handler type each.

      A typical implementation:

      return (handler instanceof MyHandler);

      参数:
      handler - handler object to check
      返回:
      whether support or not this object can use the given handler
    • handle

      @Nullable Object handle(RequestContext context, Object handler) throws Throwable
      Use the given handler to handle this request. The workflow that is required may vary widely.

      this result will handle by ReturnValueHandler

      参数:
      context - current HTTP request context
      handler - handler to use. This object must have previously been passed to the supports method of this interface, which must have returned true.
      返回:
      an object with the name of the view and the required model data, or null if the request has been handled directly
      抛出:
      Throwable - in case of errors
      另请参阅:
    • of

      static HandlerAdapter of(List<HandlerAdapter> handlerAdapters)
    • find

      static HandlerAdapter find(cn.taketoday.context.ApplicationContext context)
    • find

      static HandlerAdapter find(cn.taketoday.context.ApplicationContext context, boolean detectAllHandlerAdapters)