类 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
- 从以下版本开始:
- 3.0
- 作者:
- TODAY 2019-11-16 19:05
-
字段概要
字段修饰符和类型字段说明static final Stringprivate booleanDetect all HandlerAdapters or just expect "HandlerAdapter" bean?.private booleanDetect all HandlerExceptionHandlers or just expect "HandlerExceptionHandler" bean?.private booleanDetect all HandlerMappings or just expect "HandlerRegistry" bean?.private HandlerExceptionHandlerexception handlerprivate HandlerAdapterprivate HandlerMappingAction mapping registryprivate HttpRequestHandlerprivate final cn.taketoday.util.ArrayHolder<RequestCompletedListener>private ReturnValueHandlerManagerprivate booleanThrow a HandlerNotFoundException if no Handler was found to process this request?protected WebAsyncManagerFactory从类继承的字段 cn.taketoday.web.handler.InfraHandler
APPLICATION_CONTEXT_ID_PREFIX, beanName, DEFAULT_CONTEXT_CLASS, INIT_PARAM_DELIMITERS, initialized, log -
构造器概要
构造器 -
方法概要
修饰符和类型方法说明voidadd RequestHandledListener array to the list of listeners to be notified when a request is handled.voidadd RequestHandledListener list to the list of listeners to be notified when a request is handled.voiddispatch(RequestContext context) Process the actual dispatching to the handler.voidhandleConcurrentResult(RequestContext context, Object handler, Object concurrentResult) handle async resultsprotected ObjecthandlerNotFound(RequestContext request) No handler found → set appropriate HTTP response status.private voidinitExceptionHandler(cn.taketoday.context.ApplicationContext context) Initialize the HandlerExceptionHandler used by this class.private voidinitHandlerAdapters(cn.taketoday.context.ApplicationContext context) Initialize the HandlerAdapters used by this class.private voidinitHandlerMapping(cn.taketoday.context.ApplicationContext context) Initialize the HandlerRegistries used by this class.private voidinitNotFoundHandler(cn.taketoday.context.ApplicationContext context) Initialize the NotFoundHandler used by this class.private voidinitRequestCompletedListeners(cn.taketoday.context.ApplicationContext context) Collect all the RequestHandledListener used by this class.private voidinitReturnValueHandler(cn.taketoday.context.ApplicationContext context) Initialize the ReturnValueHandler used by this class.protected voidinitStrategies(cn.taketoday.context.ApplicationContext context) Initialize the strategy objects that this servlet uses.private voidinitWebAsyncManagerFactory(cn.taketoday.context.ApplicationContext context) Initialize the WebAsyncManagerFactory used by this class.private voidlogRequest(RequestContext request) private voidlogResult(RequestContext request, Throwable failureCause) lookupHandler(RequestContext context) Find a suitable handler to handle this HTTP requestlookupHandlerAdapter(Object handler) Find aHandlerAdapterfor input handlerprotected voidonRefresh(cn.taketoday.context.ApplicationContext context) Template method which can be overridden to add servlet-specific refresh work.protected voidprocessDispatchResult(RequestContext request, Object handler, Object returnValue, Throwable exception) Handle the result of handler selection and handler invocation, which is either a view or an Exception to be resolved to a view.protected ObjectprocessHandlerException(RequestContext request, Object handler, Throwable ex) Determine an error view via the registered HandlerExceptionHandlers.protected voidrequestCompleted(RequestContext request, Throwable notHandled) voidsetDetectAllHandlerAdapters(boolean detectAllHandlerAdapters) Set whether to detect all HandlerAdapter beans in this handler's context.voidsetDetectAllHandlerExceptionHandlers(boolean detectAllHandlerExceptionHandlers) Set whether to detect all HandlerExceptionHandler beans in this handler's context.voidsetDetectAllHandlerMapping(boolean detectAllHandlerMapping) Set whether to detect all HandlerMapping beans in this handler's context.voidsetExceptionHandler(HandlerExceptionHandler exceptionHandler) voidsetHandlerAdapter(HandlerAdapter handlerAdapter) voidsetHandlerAdapters(HandlerAdapter... handlerAdapters) voidsetHandlerMapping(HandlerMapping handlerMapping) voidsetNotFoundHandler(HttpRequestHandler notFoundHandler) Set not found handlervoidSet RequestHandledListener list to the list of listeners to be notified when a request is handled.voidsetReturnValueHandler(ReturnValueHandlerManager returnValueHandler) Set ReturnValueHandlerManagervoidsetThrowExceptionIfNoHandlerFound(boolean throwExceptionIfNoHandlerFound) Set whether to throw a HandlerNotFoundException when no Handler was found for this request.voidSet WebAsyncManagerFactory从类继承的方法 cn.taketoday.web.handler.InfraHandler
afterApplicationContextInit, applyDefaultContextId, applyInitializers, configureAndRefreshApplicationContext, createApplicationContext, createEnvironment, destroy, findApplicationContext, getApplicationContext, getContextClass, getContextConfigLocation, getContextId, getEnvironment, getRootApplicationContext, init, initApplicationContext, isEnableLoggingRequestDetails, loadInitializer, logInfo, onApplicationEvent, postProcessApplicationContext, refresh, setApplicationContext, setBeanName, setContextClass, setContextConfigLocation, setContextId, setContextInitializerClasses, setContextInitializers, setEnableLoggingRequestDetails, setEnvironment
-
字段详细资料
-
BEAN_NAME
- 另请参阅:
-
handlerMapping
Action mapping registry -
handlerAdapter
-
exceptionHandler
exception handler -
returnValueHandler
- 从以下版本开始:
- 4.0
-
throwExceptionIfNoHandlerFound
private boolean throwExceptionIfNoHandlerFoundThrow a HandlerNotFoundException if no Handler was found to process this request? @since 4.0 -
detectAllHandlerMapping
private boolean detectAllHandlerMappingDetect all HandlerMappings or just expect "HandlerRegistry" bean?. -
detectAllHandlerAdapters
private boolean detectAllHandlerAdaptersDetect all HandlerAdapters or just expect "HandlerAdapter" bean?. -
detectAllHandlerExceptionHandlers
private boolean detectAllHandlerExceptionHandlersDetect all HandlerExceptionHandlers or just expect "HandlerExceptionHandler" bean?. -
notFoundHandler
-
requestCompletedActions
-
webAsyncManagerFactory
-
-
构造器详细资料
-
DispatcherHandler
public DispatcherHandler() -
DispatcherHandler
public DispatcherHandler(cn.taketoday.context.ApplicationContext context)
-
-
方法详细资料
-
onRefresh
protected void onRefresh(cn.taketoday.context.ApplicationContext context) 从类复制的说明:InfraHandlerTemplate 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
Find a suitable handler to handle this HTTP request- 参数:
context- Current HTTP request context- 返回:
- Target handler, if returns
nullindicates that there isn't a handler to handle this request - 抛出:
Exception
-
lookupHandlerAdapter
Find aHandlerAdapterfor input handler- 参数:
handler- HTTP handler- 返回:
- A
HandlerAdapter - 抛出:
HandlerAdapterNotFoundException- If there isn't aHandlerAdapterfor 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@ExceptionHandlercontroller method.- 从以下版本开始:
- 4.0
-
handleConcurrentResult
public void handleConcurrentResult(RequestContext context, @Nullable Object handler, Object concurrentResult) throws Throwable handle async results- 参数:
context- async requesthandler- sync handlerconcurrentResult- async result- 抛出:
Throwable
-
dispatch
Process the actual dispatching to the handler. -
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 requesthandler- the executed handler, ornullif none chosen at the time of the exceptionex- the exception that got thrown during handler execution- 返回:
- a corresponding view to forward to
- 抛出:
Throwable- if no handler can handle the exception
-
handlerNotFound
No handler found → set appropriate HTTP response status. -
requestCompleted
protected void requestCompleted(RequestContext request, @Nullable Throwable notHandled) throws Throwable - 抛出:
Throwable
-
setHandlerMapping
-
setHandlerAdapters
-
setHandlerAdapter
-
setExceptionHandler
-
setReturnValueHandler
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
Set not found handler- 参数:
notFoundHandler- HttpRequestHandler- 从以下版本开始:
- 4.0
-
setWebAsyncManagerFactory
Set WebAsyncManagerFactory- 参数:
factory- WebAsyncManagerFactory- 从以下版本开始:
- 4.0
-
addRequestCompletedActions
add RequestHandledListener array to the list of listeners to be notified when a request is handled.- 参数:
array- RequestHandledListener array- 从以下版本开始:
- 4.0
-
addRequestCompletedActions
add RequestHandledListener list to the list of listeners to be notified when a request is handled.- 参数:
list- RequestHandledListener list- 从以下版本开始:
- 4.0
-
setRequestCompletedActions
Set RequestHandledListener list to the list of listeners to be notified when a request is handled.- 参数:
list- RequestHandledListener list- 从以下版本开始:
- 4.0
-
logRequest
-
logResult
-