类 ServletWebServerApplicationContext
- 所有已实现的接口:
Closeable,AutoCloseable,BeanFactory,HierarchicalBeanFactory,ListableBeanFactory,BeanDefinitionRegistry,ConfigurableWebServerApplicationContext,WebServerApplicationContext,ApplicationContext,ApplicationEventPublisher,ConfigurableApplicationContext,Lifecycle,MessageSource,AliasRegistry,EnvironmentCapable,ResourceLoader,ResourcePatternResolver,ThemeSource,ConfigurableWebApplicationContext,WebApplicationContext
WebApplicationContext that can be used to bootstrap itself from a contained
ServletWebServerFactory bean.
This context will create, initialize and run an WebServer by searching for a
single ServletWebServerFactory bean within the ApplicationContext
itself. The ServletWebServerFactory is free to use standard Spring concepts
(such as dependency injection, lifecycle callbacks and property placeholder variables).
In addition, any Servlet or Filter beans defined in the context will be
automatically registered with the web server. In the case of a single Servlet bean, the
'/' mapping will be used. If multiple Servlet beans are found then the lowercase bean
name will be used as a mapping prefix. Any Servlet named 'dispatcherServlet' will
always be mapped to '/'. Filter beans will be mapped to all URLs ('/*').
For more advanced configuration, the context can instead define beans that implement
the ServletContextInitializer interface (most often
ServletRegistrationBeans and/or FilterRegistrationBeans). To prevent
double registration, the use of ServletContextInitializer beans will disable
automatic Servlet and Filter bean registration.
Although this context can be used directly, most developers should consider using the
AnnotationConfigServletWebServerApplicationContext or
XmlServletWebServerApplicationContext variants.
- 从以下版本开始:
- 2.0.0
- 作者:
- Phillip Webb, Dave Syer, Scott Frederick
- 另请参阅:
-
嵌套类概要
嵌套类修饰符和类型类说明static classUtility class to store and restore any user defined scopes.从类继承的嵌套类/接口 org.springframework.core.io.DefaultResourceLoader
DefaultResourceLoader.ClassPathContextResource -
字段概要
字段从类继承的字段 org.springframework.context.support.AbstractApplicationContext
APPLICATION_EVENT_MULTICASTER_BEAN_NAME, LIFECYCLE_PROCESSOR_BEAN_NAME, MESSAGE_SOURCE_BEAN_NAME从接口继承的字段 org.springframework.beans.factory.BeanFactory
FACTORY_BEAN_PREFIX, FACTORY_BEAN_PREFIX_CHAR从接口继承的字段 org.springframework.context.ConfigurableApplicationContext
APPLICATION_STARTUP_BEAN_NAME, BOOTSTRAP_EXECUTOR_BEAN_NAME, CONFIG_LOCATION_DELIMITERS, CONVERSION_SERVICE_BEAN_NAME, ENVIRONMENT_BEAN_NAME, LOAD_TIME_WEAVER_BEAN_NAME, SHUTDOWN_HOOK_THREAD_NAME, SYSTEM_ENVIRONMENT_BEAN_NAME, SYSTEM_PROPERTIES_BEAN_NAME从接口继承的字段 org.springframework.web.context.ConfigurableWebApplicationContext
APPLICATION_CONTEXT_ID_PREFIX, SERVLET_CONFIG_BEAN_NAME从接口继承的字段 org.springframework.core.io.ResourceLoader
CLASSPATH_URL_PREFIX从接口继承的字段 org.springframework.core.io.support.ResourcePatternResolver
CLASSPATH_ALL_URL_PREFIX从接口继承的字段 org.springframework.web.context.WebApplicationContext
CONTEXT_ATTRIBUTES_BEAN_NAME, CONTEXT_PARAMETERS_BEAN_NAME, ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE, SCOPE_APPLICATION, SCOPE_REQUEST, SCOPE_SESSION, SERVLET_CONTEXT_BEAN_NAME -
构造器概要
构造器构造器说明Create a newServletWebServerApplicationContext.Create a newServletWebServerApplicationContextwith the givenDefaultListableBeanFactory. -
方法概要
修饰符和类型方法说明protected voiddoClose()protected ResourcegetResourceByPath(String path) Returns the namespace of the web server application context ornullif no namespace has been set.protected Collection<ServletContextInitializer> ReturnsServletContextInitializers that should be used with the embedded web server.Returns theWebServerthat was created by the context ornullif the server has not yet been created.protected ServletWebServerFactoryReturns theServletWebServerFactorythat should be used to create the embeddedWebServer.protected voidprotected voidpostProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) Register ServletContextAwareProcessor.protected voidprepareWebApplicationContext(ServletContext servletContext) Prepare theWebApplicationContextwith the given fully loadedServletContext.final voidrefresh()voidsetServerNamespace(String serverNamespace) Set the server namespace of the context.voidsetServletConfig(ServletConfig servletConfig) 从类继承的方法 org.springframework.web.context.support.GenericWebApplicationContext
createEnvironment, getApplicationName, getConfigLocations, getNamespace, getResourcePatternResolver, getServletContext, getTheme, initPropertySources, setConfigLocation, setConfigLocations, setNamespace, setServletContext从类继承的方法 org.springframework.context.support.GenericApplicationContext
cancelRefresh, closeBeanFactory, getAutowireCapableBeanFactory, getBeanDefinition, getBeanFactory, getClassLoader, getDefaultListableBeanFactory, getResource, getResources, isAlias, isBeanDefinitionOverridable, isBeanNameInUse, refreshBeanFactory, refreshForAotProcessing, registerAlias, registerBean, registerBean, registerBean, registerBean, registerBean, registerBean, registerBeanDefinition, removeAlias, removeBeanDefinition, setAllowBeanDefinitionOverriding, setAllowCircularReferences, setApplicationStartup, setClassLoader, setParent, setResourceLoader从类继承的方法 org.springframework.context.support.AbstractApplicationContext
addApplicationListener, addBeanFactoryPostProcessor, assertBeanFactoryActive, clearResourceCaches, close, containsBean, containsBeanDefinition, containsLocalBean, destroyBeans, findAllAnnotationsOnBean, findAnnotationOnBean, findAnnotationOnBean, finishBeanFactoryInitialization, finishRefresh, getAliases, getApplicationListeners, getApplicationStartup, getBean, getBean, getBean, getBean, getBean, getBeanDefinitionCount, getBeanDefinitionNames, getBeanFactoryPostProcessors, getBeanNamesForAnnotation, getBeanNamesForType, getBeanNamesForType, getBeanNamesForType, getBeanNamesForType, getBeanProvider, getBeanProvider, getBeanProvider, getBeanProvider, getBeansOfType, getBeansOfType, getBeansWithAnnotation, getDisplayName, getEnvironment, getId, getInternalParentBeanFactory, getInternalParentMessageSource, getMessage, getMessage, getMessage, getParent, getParentBeanFactory, getStartupDate, getType, getType, initApplicationEventMulticaster, initLifecycleProcessor, initMessageSource, invokeBeanFactoryPostProcessors, isActive, isClosed, isPrototype, isRunning, isSingleton, isTypeMatch, isTypeMatch, obtainFreshBeanFactory, onClose, prepareBeanFactory, prepareRefresh, publishEvent, publishEvent, publishEvent, registerBeanPostProcessors, registerListeners, registerShutdownHook, removeApplicationListener, resetCommonCaches, setDisplayName, setEnvironment, setId, start, stop, toString从类继承的方法 org.springframework.core.io.DefaultResourceLoader
addProtocolResolver, getProtocolResolvers, getResourceCache从类继承的方法 java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait从接口继承的方法 org.springframework.core.AliasRegistry
getAliases从接口继承的方法 org.springframework.context.ApplicationContext
getApplicationName, getAutowireCapableBeanFactory, getDisplayName, getId, getParent, getStartupDate从接口继承的方法 org.springframework.context.ApplicationEventPublisher
publishEvent, publishEvent从接口继承的方法 org.springframework.beans.factory.support.BeanDefinitionRegistry
containsBeanDefinition, getBeanDefinitionCount, getBeanDefinitionNames从接口继承的方法 org.springframework.beans.factory.BeanFactory
containsBean, getAliases, getBean, getBean, getBean, getBean, getBean, getBeanProvider, getBeanProvider, getType, getType, isPrototype, isSingleton, isTypeMatch, isTypeMatch从接口继承的方法 org.springframework.context.ConfigurableApplicationContext
addApplicationListener, addBeanFactoryPostProcessor, addProtocolResolver, close, getApplicationStartup, getBeanFactory, getEnvironment, isActive, isClosed, registerShutdownHook, removeApplicationListener, setApplicationStartup, setClassLoader, setEnvironment, setId, setParent从接口继承的方法 org.springframework.beans.factory.HierarchicalBeanFactory
containsLocalBean, getParentBeanFactory从接口继承的方法 org.springframework.beans.factory.ListableBeanFactory
containsBeanDefinition, findAllAnnotationsOnBean, findAnnotationOnBean, findAnnotationOnBean, getBeanDefinitionCount, getBeanDefinitionNames, getBeanNamesForAnnotation, getBeanNamesForType, getBeanNamesForType, getBeanNamesForType, getBeanNamesForType, getBeanProvider, getBeanProvider, getBeansOfType, getBeansOfType, getBeansWithAnnotation从接口继承的方法 org.springframework.context.MessageSource
getMessage, getMessage, getMessage从接口继承的方法 org.springframework.core.io.ResourceLoader
getClassLoader, getResource从接口继承的方法 org.springframework.core.io.support.ResourcePatternResolver
getResources
-
字段详细资料
-
DISPATCHER_SERVLET_NAME
Constant value for the DispatcherServlet bean name. A Servlet bean with this name is deemed to be the "main" servlet and is automatically given a mapping of "/" by default. To change the default behavior you can use aServletRegistrationBeanor a different bean name.- 另请参阅:
-
-
构造器详细资料
-
ServletWebServerApplicationContext
public ServletWebServerApplicationContext()Create a newServletWebServerApplicationContext. -
ServletWebServerApplicationContext
Create a newServletWebServerApplicationContextwith the givenDefaultListableBeanFactory.- 参数:
beanFactory- the DefaultListableBeanFactory instance to use for this context
-
-
方法详细资料
-
postProcessBeanFactory
Register ServletContextAwareProcessor.- 覆盖:
postProcessBeanFactory在类中GenericWebApplicationContext- 另请参阅:
-
refresh
- 指定者:
refresh在接口中ConfigurableApplicationContext- 覆盖:
refresh在类中AbstractApplicationContext- 抛出:
BeansExceptionIllegalStateException
-
onRefresh
protected void onRefresh() -
doClose
protected void doClose()- 覆盖:
doClose在类中AbstractApplicationContext
-
getWebServerFactory
Returns theServletWebServerFactorythat should be used to create the embeddedWebServer. By default this method searches for a suitable bean in the context itself.- 返回:
- a
ServletWebServerFactory(nevernull)
-
getServletContextInitializerBeans
ReturnsServletContextInitializers that should be used with the embedded web server. By default this method will first attempt to findServletContextInitializer,Servlet,Filterand certainEventListenerbeans.- 返回:
- the servlet initializer beans
-
prepareWebApplicationContext
Prepare theWebApplicationContextwith the given fully loadedServletContext. This method is usually called fromServletContextInitializer.onStartup(ServletContext)and is similar to the functionality usually provided by aContextLoaderListener.- 参数:
servletContext- the operational servlet context
-
getResourceByPath
-
getServerNamespace
从接口复制的说明:WebServerApplicationContextReturns the namespace of the web server application context ornullif no namespace has been set. Used for disambiguation when multiple web servers are running in the same application (for example a management context running on a different port).- 指定者:
getServerNamespace在接口中WebServerApplicationContext- 返回:
- the server namespace
-
setServerNamespace
从接口复制的说明:ConfigurableWebServerApplicationContextSet the server namespace of the context.- 指定者:
setServerNamespace在接口中ConfigurableWebServerApplicationContext- 参数:
serverNamespace- the server namespace- 另请参阅:
-
setServletConfig
-
getServletConfig
-
getWebServer
Returns theWebServerthat was created by the context ornullif the server has not yet been created.- 指定者:
getWebServer在接口中WebServerApplicationContext- 返回:
- the embedded web server
-