类 EmbeddedWebApplicationContext

  • 所有已实现的接口:
    Closeable, AutoCloseable, org.springframework.beans.factory.BeanFactory, org.springframework.beans.factory.DisposableBean, org.springframework.beans.factory.HierarchicalBeanFactory, org.springframework.beans.factory.ListableBeanFactory, org.springframework.beans.factory.support.BeanDefinitionRegistry, org.springframework.context.ApplicationContext, org.springframework.context.ApplicationEventPublisher, org.springframework.context.ConfigurableApplicationContext, org.springframework.context.Lifecycle, org.springframework.context.MessageSource, org.springframework.core.AliasRegistry, org.springframework.core.env.EnvironmentCapable, org.springframework.core.io.ResourceLoader, org.springframework.core.io.support.ResourcePatternResolver, org.springframework.ui.context.ThemeSource, org.springframework.web.context.ConfigurableWebApplicationContext, org.springframework.web.context.WebApplicationContext
    直接已知子类:
    AnnotationConfigEmbeddedWebApplicationContext, XmlEmbeddedWebApplicationContext

    public class EmbeddedWebApplicationContext
    extends org.springframework.web.context.support.GenericWebApplicationContext
    A WebApplicationContext that can be used to bootstrap itself from a contained EmbeddedServletContainerFactory bean.

    This context will create, initialize and run an EmbeddedServletContainer by searching for a single EmbeddedServletContainerFactory bean within the ApplicationContext itself. The EmbeddedServletContainerFactory 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 embedded Servlet container. 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 AnnotationConfigEmbeddedWebApplicationContext or XmlEmbeddedWebApplicationContext variants.

    另请参阅:
    AnnotationConfigEmbeddedWebApplicationContext, XmlEmbeddedWebApplicationContext, EmbeddedServletContainerFactory
    • 嵌套类概要

      嵌套类 
      修饰符和类型说明
      static class EmbeddedWebApplicationContext.ExistingWebApplicationScopes
      Utility class to store and restore any user defined scopes.
      • 从类继承的嵌套类/接口 org.springframework.core.io.DefaultResourceLoader

        org.springframework.core.io.DefaultResourceLoader.ClassPathContextResource
    • 字段概要

      字段 
      修饰符和类型字段说明
      static StringDISPATCHER_SERVLET_NAME
      Constant value for the DispatcherServlet bean name.
      • 从类继承的字段 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
      • 从接口继承的字段 org.springframework.context.ConfigurableApplicationContext

        CONFIG_LOCATION_DELIMITERS, CONVERSION_SERVICE_BEAN_NAME, ENVIRONMENT_BEAN_NAME, LOAD_TIME_WEAVER_BEAN_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_GLOBAL_SESSION, SCOPE_REQUEST, SCOPE_SESSION, SERVLET_CONTEXT_BEAN_NAME
    • 方法概要

      所有方法 实例方法 具体方法 
      修饰符和类型方法说明
      protected voidfinishRefresh() 
      EmbeddedServletContainergetEmbeddedServletContainer()
      Returns the EmbeddedServletContainer that was created by the context or null if the container has not yet been created.
      protected EmbeddedServletContainerFactorygetEmbeddedServletContainerFactory()
      Returns the EmbeddedServletContainerFactory that should be used to create the embedded servlet container.
      StringgetNamespace() 
      protected org.springframework.core.io.ResourcegetResourceByPath​(String path) 
      javax.servlet.ServletConfiggetServletConfig() 
      protected Collection<ServletContextInitializer>getServletContextInitializerBeans()
      Returns ServletContextInitializers that should be used with the embedded Servlet context.
      protected voidonClose() 
      protected voidonRefresh() 
      protected voidpostProcessBeanFactory​(org.springframework.beans.factory.config.ConfigurableListableBeanFactory beanFactory)
      Register ServletContextAwareProcessor.
      protected voidprepareEmbeddedWebApplicationContext​(javax.servlet.ServletContext servletContext)
      Prepare the WebApplicationContext with the given fully loaded ServletContext.
      voidrefresh() 
      voidsetNamespace​(String namespace) 
      voidsetServletConfig​(javax.servlet.ServletConfig servletConfig) 
      • 从类继承的方法 org.springframework.web.context.support.GenericWebApplicationContext

        createEnvironment, getApplicationName, getConfigLocations, getResourcePatternResolver, getServletContext, getTheme, initPropertySources, setConfigLocation, setConfigLocations, setServletContext
      • 从类继承的方法 org.springframework.context.support.GenericApplicationContext

        cancelRefresh, closeBeanFactory, getAutowireCapableBeanFactory, getBeanDefinition, getBeanFactory, getClassLoader, getDefaultListableBeanFactory, getResource, getResources, isAlias, isBeanNameInUse, refreshBeanFactory, registerAlias, registerBeanDefinition, removeAlias, removeBeanDefinition, setAllowBeanDefinitionOverriding, setAllowCircularReferences, setClassLoader, setId, setParent, setResourceLoader
      • 从类继承的方法 org.springframework.context.support.AbstractApplicationContext

        addApplicationListener, addBeanFactoryPostProcessor, assertBeanFactoryActive, close, containsBean, containsBeanDefinition, containsLocalBean, destroy, destroyBeans, doClose, findAnnotationOnBean, finishBeanFactoryInitialization, getAliases, getApplicationListeners, getBean, getBean, getBean, getBean, getBean, getBeanDefinitionCount, getBeanDefinitionNames, getBeanFactoryPostProcessors, getBeanNamesForAnnotation, getBeanNamesForType, getBeanNamesForType, getBeanNamesForType, getBeansOfType, getBeansOfType, getBeansWithAnnotation, getDisplayName, getEnvironment, getId, getInternalParentBeanFactory, getInternalParentMessageSource, getMessage, getMessage, getMessage, getParent, getParentBeanFactory, getStartupDate, getType, initApplicationEventMulticaster, initLifecycleProcessor, initMessageSource, invokeBeanFactoryPostProcessors, isActive, isPrototype, isRunning, isSingleton, isTypeMatch, isTypeMatch, obtainFreshBeanFactory, prepareBeanFactory, prepareRefresh, publishEvent, publishEvent, publishEvent, registerBeanPostProcessors, registerListeners, registerShutdownHook, resetCommonCaches, setDisplayName, setEnvironment, start, stop, toString
      • 从类继承的方法 org.springframework.core.io.DefaultResourceLoader

        addProtocolResolver, getProtocolResolvers
      • 从接口继承的方法 org.springframework.core.AliasRegistry

        getAliases
      • 从接口继承的方法 org.springframework.context.ApplicationContext

        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, getType, isPrototype, isSingleton, isTypeMatch, isTypeMatch
      • 从接口继承的方法 org.springframework.context.ConfigurableApplicationContext

        addApplicationListener, addBeanFactoryPostProcessor, addProtocolResolver, close, getBeanFactory, getEnvironment, isActive, registerShutdownHook, setEnvironment, setId, setParent
      • 从接口继承的方法 org.springframework.beans.factory.HierarchicalBeanFactory

        containsLocalBean, getParentBeanFactory
      • 从接口继承的方法 org.springframework.context.Lifecycle

        isRunning, start, stop
      • 从接口继承的方法 org.springframework.beans.factory.ListableBeanFactory

        containsBeanDefinition, findAnnotationOnBean, getBeanDefinitionCount, getBeanDefinitionNames, getBeanNamesForAnnotation, getBeanNamesForType, getBeanNamesForType, getBeanNamesForType, 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

        public static final String 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 behaviour you can use a ServletRegistrationBean or a different bean name.
        另请参阅:
        常量字段值
    • 方法详细资料

      • postProcessBeanFactory

        protected void postProcessBeanFactory​(org.springframework.beans.factory.config.ConfigurableListableBeanFactory beanFactory)
        Register ServletContextAwareProcessor.
        覆盖:
        postProcessBeanFactory 在类中 org.springframework.web.context.support.GenericWebApplicationContext
        另请参阅:
        ServletContextAwareProcessor
      • refresh

        public final void refresh()
                           throws org.springframework.beans.BeansException,
                                  IllegalStateException
        指定者:
        refresh 在接口中 org.springframework.context.ConfigurableApplicationContext
        覆盖:
        refresh 在类中 org.springframework.context.support.AbstractApplicationContext
        抛出:
        org.springframework.beans.BeansException
        IllegalStateException
      • onRefresh

        protected void onRefresh()
        覆盖:
        onRefresh 在类中 org.springframework.web.context.support.GenericWebApplicationContext
      • finishRefresh

        protected void finishRefresh()
        覆盖:
        finishRefresh 在类中 org.springframework.context.support.AbstractApplicationContext
      • onClose

        protected void onClose()
        覆盖:
        onClose 在类中 org.springframework.context.support.AbstractApplicationContext
      • prepareEmbeddedWebApplicationContext

        protected void prepareEmbeddedWebApplicationContext​(javax.servlet.ServletContext servletContext)
        Prepare the WebApplicationContext with the given fully loaded ServletContext. This method is usually called from ServletContextInitializer.onStartup(ServletContext) and is similar to the functionality usually provided by a ContextLoaderListener.
        参数:
        servletContext - the operational servlet context
      • getResourceByPath

        protected org.springframework.core.io.Resource getResourceByPath​(String path)
        覆盖:
        getResourceByPath 在类中 org.springframework.web.context.support.GenericWebApplicationContext
      • setNamespace

        public void setNamespace​(String namespace)
        指定者:
        setNamespace 在接口中 org.springframework.web.context.ConfigurableWebApplicationContext
        覆盖:
        setNamespace 在类中 org.springframework.web.context.support.GenericWebApplicationContext
      • getNamespace

        public String getNamespace()
        指定者:
        getNamespace 在接口中 org.springframework.web.context.ConfigurableWebApplicationContext
        覆盖:
        getNamespace 在类中 org.springframework.web.context.support.GenericWebApplicationContext
      • setServletConfig

        public void setServletConfig​(javax.servlet.ServletConfig servletConfig)
        指定者:
        setServletConfig 在接口中 org.springframework.web.context.ConfigurableWebApplicationContext
        覆盖:
        setServletConfig 在类中 org.springframework.web.context.support.GenericWebApplicationContext
      • getServletConfig

        public javax.servlet.ServletConfig getServletConfig()
        指定者:
        getServletConfig 在接口中 org.springframework.web.context.ConfigurableWebApplicationContext
        覆盖:
        getServletConfig 在类中 org.springframework.web.context.support.GenericWebApplicationContext