类 DispatcherHandler

java.lang.Object
cn.taketoday.web.handler.InfraHandler
cn.taketoday.web.handler.DispatcherHandler
所有已实现的接口:
cn.taketoday.beans.factory.Aware, cn.taketoday.beans.factory.BeanNameAware, cn.taketoday.context.ApplicationContextAware, cn.taketoday.context.EnvironmentAware, cn.taketoday.core.env.EnvironmentCapable
直接已知子类:
DispatcherServlet

public class DispatcherHandler extends InfraHandler
Central dispatcher for HTTP request handlers/controllers
从以下版本开始:
3.0
作者:
TODAY 2019-11-16 19:05
  • 字段详细资料

    • BEAN_NAME

      public static final String BEAN_NAME
      另请参阅:
    • handlerMapping

      private HandlerMapping handlerMapping
      Action mapping registry
    • handlerAdapter

      private HandlerAdapter handlerAdapter
    • exceptionHandler

      private HandlerExceptionHandler exceptionHandler
      exception handler
    • returnValueHandler

      private ReturnValueHandlerManager returnValueHandler
      从以下版本开始:
      4.0
    • throwExceptionIfNoHandlerFound

      private boolean throwExceptionIfNoHandlerFound
      Throw a HandlerNotFoundException if no Handler was found to process this request? @since 4.0
    • detectAllHandlerMapping

      private boolean detectAllHandlerMapping
      Detect all HandlerMappings or just expect "HandlerRegistry" bean?.
    • detectAllHandlerAdapters

      private boolean detectAllHandlerAdapters
      Detect all HandlerAdapters or just expect "HandlerAdapter" bean?.
    • detectAllHandlerExceptionHandlers

      private boolean detectAllHandlerExceptionHandlers
      Detect all HandlerExceptionHandlers or just expect "HandlerExceptionHandler" bean?.
    • notFoundHandler

      private HttpRequestHandler notFoundHandler
    • requestCompletedActions

      private final cn.taketoday.util.ArrayHolder<RequestCompletedListener> requestCompletedActions
    • webAsyncManagerFactory

      protected WebAsyncManagerFactory webAsyncManagerFactory
  • 构造器详细资料

    • DispatcherHandler

      public DispatcherHandler()
    • DispatcherHandler

      public DispatcherHandler(cn.taketoday.context.ApplicationContext context)
  • 方法详细资料

    • onRefresh

      protected void onRefresh(cn.taketoday.context.ApplicationContext context)
      从类复制的说明: InfraHandler
      Template method which can be overridden to add servlet-specific refresh work. Called after successful context refresh.

      This implementation is empty.

      覆盖:
      onRefresh 在类中 InfraHandler
      参数:
      context - the current ApplicationContext
      另请参阅:
    • initStrategies

      protected void initStrategies(cn.taketoday.context.ApplicationContext context)
      Initialize the strategy objects that this servlet uses.

      May be overridden in subclasses in order to initialize further strategy objects.

    • initHandlerMapping

      private void initHandlerMapping(cn.taketoday.context.ApplicationContext context)
      Initialize the HandlerRegistries used by this class.

      If no HandlerRegistry beans are defined in the BeanFactory for this namespace, we default to BeanNameUrlHandlerRegistry.

    • initHandlerAdapters

      private void initHandlerAdapters(cn.taketoday.context.ApplicationContext context)
      Initialize the HandlerAdapters used by this class.

      If no HandlerAdapter beans are defined in the BeanFactory for this namespace, we default to RequestHandlerAdapter.

    • initReturnValueHandler

      private void initReturnValueHandler(cn.taketoday.context.ApplicationContext context)
      Initialize the ReturnValueHandler used by this class.

      If no ReturnValueHandlerManager beans are defined in the BeanFactory for this namespace, we default to ReturnValueHandlerManager.registerDefaultHandlers().

      另请参阅:
    • initExceptionHandler

      private void initExceptionHandler(cn.taketoday.context.ApplicationContext context)
      Initialize the HandlerExceptionHandler used by this class.

      If no HandlerExceptionHandler beans are defined in the BeanFactory for this namespace, we default to ExceptionHandlerAnnotationExceptionHandler.

      另请参阅:
    • initNotFoundHandler

      private void initNotFoundHandler(cn.taketoday.context.ApplicationContext context)
      Initialize the NotFoundHandler used by this class.

      If no NotFoundHandler beans are defined in the BeanFactory for this namespace, we default to NotFoundHandler.

      另请参阅:
    • initRequestCompletedListeners

      private void initRequestCompletedListeners(cn.taketoday.context.ApplicationContext context)
      Collect all the RequestHandledListener used by this class.
      另请参阅:
    • initWebAsyncManagerFactory

      private void initWebAsyncManagerFactory(cn.taketoday.context.ApplicationContext context)
      Initialize the WebAsyncManagerFactory used by this class.
      另请参阅:
    • lookupHandler

      @Nullable public Object lookupHandler(RequestContext context) throws Exception
      Find a suitable handler to handle this HTTP request
      参数:
      context - Current HTTP request context
      返回:
      Target handler, if returns null indicates that there isn't a handler to handle this request
      抛出:
      Exception
    • lookupHandlerAdapter

      public HandlerAdapter lookupHandlerAdapter(@Nullable Object handler)
      Find a HandlerAdapter for input handler
      参数:
      handler - HTTP handler
      返回:
      A HandlerAdapter
      抛出:
      HandlerAdapterNotFoundException - If there isn't a HandlerAdapter for target handler
    • setThrowExceptionIfNoHandlerFound

      public void setThrowExceptionIfNoHandlerFound(boolean throwExceptionIfNoHandlerFound)
      Set whether to throw a HandlerNotFoundException when no Handler was found for this request. This exception can then be caught with a HandlerExceptionHandler or an @ExceptionHandler controller method.
      从以下版本开始:
      4.0
    • handleConcurrentResult

      public void handleConcurrentResult(RequestContext context, @Nullable Object handler, Object concurrentResult) throws Throwable
      handle async results
      参数:
      context - async request
      handler - sync handler
      concurrentResult - async result
      抛出:
      Throwable
    • dispatch

      public void dispatch(RequestContext context) throws Throwable
      Process the actual dispatching to the handler.
      参数:
      context - current HTTP request and HTTP response
      抛出:
      Exception - in case of any kind of processing failure
      Throwable
      从以下版本开始:
      4.0
    • processDispatchResult

      protected void processDispatchResult(RequestContext request, @Nullable Object handler, @Nullable Object returnValue, @Nullable Throwable exception) throws Throwable
      Handle the result of handler selection and handler invocation, which is either a view or an Exception to be resolved to a view.
      抛出:
      Throwable
    • processHandlerException

      @Nullable protected Object processHandlerException(RequestContext request, @Nullable Object handler, Throwable ex) throws Throwable
      Determine an error view via the registered HandlerExceptionHandlers.
      参数:
      request - current HTTP request
      handler - the executed handler, or null if none chosen at the time of the exception
      ex - the exception that got thrown during handler execution
      返回:
      a corresponding view to forward to
      抛出:
      Throwable - if no handler can handle the exception
    • handlerNotFound

      @Nullable protected Object handlerNotFound(RequestContext request) throws Throwable
      No handler found → set appropriate HTTP response status.
      参数:
      request - current HTTP request
      抛出:
      Exception - if preparing the response failed
      Throwable
    • requestCompleted

      protected void requestCompleted(RequestContext request, @Nullable Throwable notHandled) throws Throwable
      抛出:
      Throwable
    • setHandlerMapping

      public void setHandlerMapping(HandlerMapping handlerMapping)
    • setHandlerAdapters

      public void setHandlerAdapters(HandlerAdapter... handlerAdapters)
    • setHandlerAdapter

      public void setHandlerAdapter(HandlerAdapter handlerAdapter)
    • setExceptionHandler

      public void setExceptionHandler(HandlerExceptionHandler exceptionHandler)
    • setReturnValueHandler

      public void setReturnValueHandler(ReturnValueHandlerManager returnValueHandler)
      Set ReturnValueHandlerManager
      参数:
      returnValueHandler - ReturnValueHandlerManager
    • setDetectAllHandlerMapping

      public void setDetectAllHandlerMapping(boolean detectAllHandlerMapping)
      Set whether to detect all HandlerMapping beans in this handler's context. Otherwise, just a single bean with name "HandlerMapping" will be expected.

      Default is "true". Turn this off if you want this servlet to use a single HandlerMapping, despite multiple HandlerMapping beans being defined in the context.

      从以下版本开始:
      4.0
    • setDetectAllHandlerAdapters

      public void setDetectAllHandlerAdapters(boolean detectAllHandlerAdapters)
      Set whether to detect all HandlerAdapter beans in this handler's context. Otherwise, just a single bean with name "handlerAdapter" will be expected.

      Default is "true". Turn this off if you want this servlet to use a single HandlerAdapter, despite multiple HandlerAdapter beans being defined in the context.

      从以下版本开始:
      4.0
    • setDetectAllHandlerExceptionHandlers

      public void setDetectAllHandlerExceptionHandlers(boolean detectAllHandlerExceptionHandlers)
      Set whether to detect all HandlerExceptionHandler beans in this handler's context. Otherwise, just a single bean with name "handlerExceptionHandler" will be expected.

      Default is "true". Turn this off if you want this servlet to use a single HandlerExceptionHandler, despite multiple HandlerExceptionHandler beans being defined in the context.

      从以下版本开始:
      4.0
    • setNotFoundHandler

      public void setNotFoundHandler(HttpRequestHandler notFoundHandler)
      Set not found handler
      参数:
      notFoundHandler - HttpRequestHandler
      从以下版本开始:
      4.0
    • setWebAsyncManagerFactory

      public void setWebAsyncManagerFactory(WebAsyncManagerFactory factory)
      Set WebAsyncManagerFactory
      参数:
      factory - WebAsyncManagerFactory
      从以下版本开始:
      4.0
    • addRequestCompletedActions

      public void addRequestCompletedActions(@Nullable RequestCompletedListener... array)
      add RequestHandledListener array to the list of listeners to be notified when a request is handled.
      参数:
      array - RequestHandledListener array
      从以下版本开始:
      4.0
    • addRequestCompletedActions

      public void addRequestCompletedActions(@Nullable Collection<RequestCompletedListener> list)
      add RequestHandledListener list to the list of listeners to be notified when a request is handled.
      参数:
      list - RequestHandledListener list
      从以下版本开始:
      4.0
    • setRequestCompletedActions

      public void setRequestCompletedActions(@Nullable Collection<RequestCompletedListener> list)
      Set RequestHandledListener list to the list of listeners to be notified when a request is handled.
      参数:
      list - RequestHandledListener list
      从以下版本开始:
      4.0
    • logRequest

      private void logRequest(RequestContext request)
    • logResult

      private void logResult(RequestContext request, @Nullable Throwable failureCause)