类 DispatcherServlet
- 所有已实现的接口:
cn.taketoday.beans.factory.Aware,cn.taketoday.beans.factory.BeanNameAware,cn.taketoday.context.ApplicationContextAware,cn.taketoday.context.EnvironmentAware,cn.taketoday.core.env.EnvironmentCapable,Servlet,Serializable
- 从以下版本开始:
- 2.0
- 作者:
- TODAY 2018-06-25 19:47:14
- 另请参阅:
-
字段概要
字段修饰符和类型字段说明private StringServletContext attribute to find the WebApplicationContext in.private booleanShould we publish the context as a ServletContext attribute?.private static final longstatic final StringPrefix for the ServletContext attribute for the ApplicationContext.private ServletConfig从类继承的字段 cn.taketoday.web.handler.DispatcherHandler
BEAN_NAME, webAsyncManagerFactory从类继承的字段 cn.taketoday.web.handler.InfraHandler
APPLICATION_CONTEXT_ID_PREFIX, beanName, DEFAULT_CONTEXT_CLASS, INIT_PARAM_DELIMITERS, initialized, log -
构造器概要
构造器构造器说明DispatcherServlet(cn.taketoday.context.ApplicationContext context) Create a newInfraHandlerwith the given application context. -
方法概要
修饰符和类型方法说明protected voidThis method will be invoked after any bean properties have been set and the ApplicationContext has been loaded.protected voidapplyDefaultContextId(cn.taketoday.context.ConfigurableApplicationContext context) protected voidapplyInitializers(cn.taketoday.context.ConfigurableApplicationContext context, List<cn.taketoday.context.ApplicationContextInitializer> initializers) Delegate the ApplicationContext before it is refreshed to anyApplicationContextInitializerinstances specified by the "contextInitializerClasses" servlet init-param.protected cn.taketoday.core.env.ConfigurableEnvironmentCreate and return a newStandardEnvironment.protected cn.taketoday.context.ApplicationContextReturn the name of the ServletContext attribute which should be used to retrieve theWebApplicationContextthat this servlet is supposed to use.protected cn.taketoday.context.ApplicationContextReturns a reference to theServletContextin which this servlet is running.Return the ServletContext attribute name for this servlet's WebApplicationContext.final StringReturns the name of this servlet instance.voidinit(ServletConfig servletConfig) protected voidLog internalprotected voidpostProcessApplicationContext(cn.taketoday.context.ConfigurableApplicationContext context) Post-process the given ApplicationContext before it is refreshed and activated as context for this handler.voidservice(ServletRequest request, ServletResponse response) voidsetContextAttribute(String contextAttribute) Set the name of the ServletContext attribute which should be used to retrieve theWebApplicationContextthat this servlet is supposed to use.voidsetPublishContext(boolean publishContext) Set whether to publish this servlet's context as a ServletContext attribute, available to all objects in the web container.从类继承的方法 cn.taketoday.web.handler.DispatcherHandler
addRequestCompletedActions, addRequestCompletedActions, dispatch, handleConcurrentResult, handlerNotFound, initStrategies, lookupHandler, lookupHandlerAdapter, onRefresh, processDispatchResult, processHandlerException, requestCompleted, setDetectAllHandlerAdapters, setDetectAllHandlerExceptionHandlers, setDetectAllHandlerMapping, setExceptionHandler, setHandlerAdapter, setHandlerAdapters, setHandlerMapping, setNotFoundHandler, setRequestCompletedActions, setReturnValueHandler, setThrowExceptionIfNoHandlerFound, setWebAsyncManagerFactory从类继承的方法 cn.taketoday.web.handler.InfraHandler
configureAndRefreshApplicationContext, createApplicationContext, destroy, getApplicationContext, getContextClass, getContextConfigLocation, getContextId, getEnvironment, init, initApplicationContext, isEnableLoggingRequestDetails, loadInitializer, onApplicationEvent, refresh, setApplicationContext, setBeanName, setContextClass, setContextConfigLocation, setContextId, setContextInitializerClasses, setContextInitializers, setEnableLoggingRequestDetails, setEnvironment
-
字段详细资料
-
serialVersionUID
private static final long serialVersionUID- 另请参阅:
-
SERVLET_CONTEXT_PREFIX
Prefix for the ServletContext attribute for the ApplicationContext. The completion is the servlet name. -
servletConfig
-
contextAttribute
ServletContext attribute to find the WebApplicationContext in. -
publishContext
private boolean publishContextShould we publish the context as a ServletContext attribute?.
-
-
构造器详细资料
-
DispatcherServlet
public DispatcherServlet() -
DispatcherServlet
public DispatcherServlet(cn.taketoday.context.ApplicationContext context) Create a newInfraHandlerwith the given application context. This constructor is useful in Servlet environments where instance-based registration of servlets is possible through theServletContext.addServlet(java.lang.String, java.lang.String)API.Using this constructor indicates that the following properties / init-params will be ignored:
InfraHandler.setContextClass(Class)/ 'contextClass'InfraHandler.setContextConfigLocation(String)/ 'contextConfigLocation'
The given application context may or may not yet be refreshed. If it (a) is an implementation of
ConfigurableApplicationContextand (b) has not already been refreshed (the recommended approach), then the following will occur:- If the given context does not already have a parent, the root application context will be set as the parent.
- If the given context has not already been assigned an id, one will be assigned to it
ServletContextandServletConfigobjects will be delegated to the application contextpostProcessApplicationContext(cn.taketoday.context.ConfigurableApplicationContext)will be called- Any
ApplicationContextInitializersspecified through the "contextInitializerClasses" init-param or through theInfraHandler.setContextInitializers(cn.taketoday.context.ApplicationContextInitializer...)property will be applied. refresh()will be called
ConfigurableApplicationContext, none of the above will occur under the assumption that the user has performed these actions (or not) per his or her specific needs.- 参数:
context- the context to use- 另请参阅:
-
-
方法详细资料
-
setContextAttribute
Set the name of the ServletContext attribute which should be used to retrieve theWebApplicationContextthat this servlet is supposed to use.- 从以下版本开始:
- 4.0
-
getContextAttribute
Return the name of the ServletContext attribute which should be used to retrieve theWebApplicationContextthat this servlet is supposed to use.- 从以下版本开始:
- 4.0
-
setPublishContext
public void setPublishContext(boolean publishContext) Set whether to publish this servlet's context as a ServletContext attribute, available to all objects in the web container. Default is "true".This is especially handy during testing, although it is debatable whether it's good practice to let other application objects access the context this way.
- 从以下版本开始:
- 4.0
-
createEnvironment
protected cn.taketoday.core.env.ConfigurableEnvironment createEnvironment()从类复制的说明:InfraHandlerCreate and return a newStandardEnvironment.Subclasses may override this in order to configure the environment or specialize the environment type returned.
- 覆盖:
createEnvironment在类中InfraHandler
-
init
-
afterApplicationContextInit
protected void afterApplicationContextInit()从类复制的说明:InfraHandlerThis method will be invoked after any bean properties have been set and the ApplicationContext has been loaded. The default implementation is empty; subclasses may override this method to perform any initialization they require. -
applyInitializers
protected void applyInitializers(cn.taketoday.context.ConfigurableApplicationContext context, List<cn.taketoday.context.ApplicationContextInitializer> initializers) 从类复制的说明:InfraHandlerDelegate the ApplicationContext before it is refreshed to anyApplicationContextInitializerinstances specified by the "contextInitializerClasses" servlet init-param.See also
InfraHandler.postProcessApplicationContext(cn.taketoday.context.ConfigurableApplicationContext), which is designed to allow subclasses (as opposed to end-users) to modify the application context, and is called immediately before this method.- 覆盖:
applyInitializers在类中InfraHandler- 参数:
context- the configured ApplicationContext (not refreshed yet)initializers- ApplicationContextInitializer list- 另请参阅:
-
postProcessApplicationContext
protected void postProcessApplicationContext(cn.taketoday.context.ConfigurableApplicationContext context) 从类复制的说明:InfraHandlerPost-process the given ApplicationContext before it is refreshed and activated as context for this handler.The default implementation is empty.
refresh()will be called automatically after this method returns.Note that this method is designed to allow subclasses to modify the application context, while
InfraHandler.initApplicationContext()is designed to allow end-users to modify the context through the use ofApplicationContextInitializers.- 覆盖:
postProcessApplicationContext在类中InfraHandler- 参数:
context- the configured ApplicationContext (not refreshed yet)- 另请参阅:
-
InfraHandler.createApplicationContext(cn.taketoday.context.ApplicationContext)InfraHandler.initApplicationContext()ConfigurableApplicationContext.refresh()
-
applyDefaultContextId
protected void applyDefaultContextId(cn.taketoday.context.ConfigurableApplicationContext context) - 覆盖:
applyDefaultContextId在类中InfraHandler
-
getRootApplicationContext
protected cn.taketoday.context.ApplicationContext getRootApplicationContext() -
getServletContext
Returns a reference to theServletContextin which this servlet is running. SeeServletConfig.getServletContext().This method is supplied for convenience. It gets the context from the servlet's
ServletConfigobject.- 返回:
- ServletContext the
ServletContextobject passed to this servlet by theinitmethod
-
findApplicationContext
@Nullable protected cn.taketoday.context.ApplicationContext findApplicationContext()Retrieve aApplicationContextfrom theServletContextattribute with theconfigured name. TheApplicationContextmust have already been loaded and stored in theServletContextbefore this servlet gets initialized (or invoked).Subclasses may override this method to provide a different
ApplicationContextretrieval strategy.- 覆盖:
findApplicationContext在类中InfraHandler- 返回:
- the ApplicationContext for this servlet, or
nullif not found - 另请参阅:
-
getServletContextAttributeName
Return the ServletContext attribute name for this servlet's WebApplicationContext.The default implementation returns
SERVLET_CONTEXT_PREFIX + servlet name. -
service
- 指定者:
service在接口中Servlet- 抛出:
ServletException
-
getServletConfig
- 指定者:
getServletConfig在接口中Servlet
-
getServletInfo
- 指定者:
getServletInfo在接口中Servlet
-
getServletName
Returns the name of this servlet instance. SeeServletConfig.getServletName().- 返回:
- the name of this servlet instance
-
logInfo
从类复制的说明:InfraHandlerLog internal- 覆盖:
logInfo在类中InfraHandler- 参数:
msg- Log message
-