类 XmlWebApplicationContext

java.lang.Object
cn.taketoday.core.io.DefaultResourceLoader
cn.taketoday.context.support.AbstractApplicationContext
cn.taketoday.context.support.AbstractRefreshableApplicationContext
cn.taketoday.context.support.AbstractRefreshableConfigApplicationContext
cn.taketoday.web.servlet.support.AbstractRefreshableWebApplicationContext
cn.taketoday.web.servlet.support.XmlWebApplicationContext
所有已实现的接口:
cn.taketoday.beans.factory.Aware, cn.taketoday.beans.factory.BeanFactory, cn.taketoday.beans.factory.BeanNameAware, cn.taketoday.beans.factory.HierarchicalBeanFactory, cn.taketoday.beans.factory.InitializingBean, cn.taketoday.beans.factory.support.BeanDefinitionRegistry, cn.taketoday.beans.factory.support.DependencyInjectorProvider, cn.taketoday.context.ApplicationContext, cn.taketoday.context.ApplicationEventPublisher, cn.taketoday.context.ConfigurableApplicationContext, cn.taketoday.context.Lifecycle, cn.taketoday.context.MessageSource, cn.taketoday.core.AliasRegistry, cn.taketoday.core.env.EnvironmentCapable, cn.taketoday.core.io.PatternResourceLoader, cn.taketoday.core.io.ResourceLoader, ConfigurableWebApplicationContext, WebApplicationContext, Closeable, AutoCloseable

public class XmlWebApplicationContext extends AbstractRefreshableWebApplicationContext
WebApplicationContext implementation which takes its configuration from XML documents, understood by an XmlBeanDefinitionReader. This is essentially the equivalent of GenericXmlApplicationContext for a web environment.

By default, the configuration will be taken from "/WEB-INF/applicationContext.xml" for the root context, and "/WEB-INF/test-servlet.xml" for a context with the namespace "test-servlet" (like for a DispatcherServlet instance with the servlet-name "test").

The config location defaults can be overridden via the "contextConfigLocation" context-param of ContextLoader and servlet init-param of DispatcherServlet. Config locations can either denote concrete files like "/WEB-INF/context.xml" or Ant-style patterns like "/WEB-INF/*-context.xml" (see PathMatcher javadoc for pattern details).

Note: In case of multiple config locations, later bean definitions will override ones defined in earlier loaded files. This can be leveraged to deliberately override certain bean definitions via an extra XML file.

For a WebApplicationContext that reads in a different bean definition format, create an analogous subclass of AbstractRefreshableWebApplicationContext. Such a context implementation can be specified as "contextClass" context-param for ContextLoader or "contextClass" init-param for FrameworkServlet.

从以下版本开始:
4.0 2022/3/6 22:17
作者:
Rod Johnson, Juergen Hoeller, Harry Yang
另请参阅:
  • 嵌套类概要

    从类继承的嵌套类/接口 cn.taketoday.core.io.DefaultResourceLoader

    cn.taketoday.core.io.DefaultResourceLoader.ClassPathContextResource

    从接口继承的嵌套类/接口 cn.taketoday.context.ApplicationContext

    cn.taketoday.context.ApplicationContext.State
  • 字段概要

    字段
    修饰符和类型
    字段
    说明
    static final String
    Default config location for the root context.
    static final String
    Default prefix for building a config location for a namespace.
    static final String
    Default suffix for building a config location for a namespace.

    从类继承的字段 cn.taketoday.context.support.AbstractApplicationContext

    APPLICATION_EVENT_MULTICASTER_BEAN_NAME, LIFECYCLE_PROCESSOR_BEAN_NAME, log, MESSAGE_SOURCE_BEAN_NAME

    从接口继承的字段 cn.taketoday.context.ApplicationContext

    APPLICATION_NAME

    从接口继承的字段 cn.taketoday.beans.factory.BeanFactory

    FACTORY_BEAN_PREFIX

    从接口继承的字段 cn.taketoday.context.ConfigurableApplicationContext

    CONFIG_LOCATION_DELIMITERS, CONVERSION_SERVICE_BEAN_NAME, LOAD_TIME_WEAVER_BEAN_NAME, SHUTDOWN_HOOK_THREAD_NAME

    从接口继承的字段 cn.taketoday.web.servlet.ConfigurableWebApplicationContext

    SERVLET_CONFIG_BEAN_NAME

    从接口继承的字段 cn.taketoday.core.io.PatternResourceLoader

    CLASSPATH_ALL_URL_PREFIX

    从接口继承的字段 cn.taketoday.core.io.ResourceLoader

    CLASSPATH_URL_PREFIX
  • 构造器概要

    构造器
    构造器
    说明
     
  • 方法概要

    修饰符和类型
    方法
    说明
    protected String[]
    The default location for the root context is "/WEB-INF/applicationContext.xml", and "/WEB-INF/test-servlet.xml" for a context with the namespace "test-servlet" (like for a DispatcherServlet instance with the servlet-name "test").
    protected void
    initBeanDefinitionReader(cn.taketoday.beans.factory.xml.XmlBeanDefinitionReader beanDefinitionReader)
    Initialize the bean definition reader used for loading the bean definitions of this context.
    protected void
    loadBeanDefinitions(cn.taketoday.beans.factory.support.StandardBeanFactory beanFactory)
    Loads the bean definitions via an XmlBeanDefinitionReader.
    protected void
    loadBeanDefinitions(cn.taketoday.beans.factory.xml.XmlBeanDefinitionReader reader)
    Load the bean definitions with the given XmlBeanDefinitionReader.

    从类继承的方法 cn.taketoday.context.support.AbstractRefreshableConfigApplicationContext

    afterPropertiesSet, resolvePath, setBeanName, setConfigLocation, setConfigLocations, setId

    从类继承的方法 cn.taketoday.context.support.AbstractRefreshableApplicationContext

    assertBeanFactoryActive, cancelRefresh, closeBeanFactory, containsBeanDefinition, containsBeanDefinition, containsBeanDefinition, containsBeanDefinition, createBeanFactory, createBootstrapContext, customizeBeanFactory, getAliasList, getBeanDefinition, getBeanDefinition, getBeanDefinitionCount, getBeanDefinitionNames, getBeanFactory, hasBeanFactory, isAlias, isAllowBeanDefinitionOverriding, isBeanDefinitionOverridable, isBeanNameInUse, refreshBeanFactory, registerAlias, registerBeanDefinition, removeAlias, removeBeanDefinition, setAllowBeanDefinitionOverriding, setAllowCircularReferences

    从类继承的方法 cn.taketoday.context.support.AbstractApplicationContext

    addApplicationListener, addBeanFactoryPostProcessor, applyState, close, containsBean, containsLocalBean, destroyBeans, doClose, findAllAnnotationsOnBean, findAnnotationOnBean, findAnnotationOnBean, findSynthesizedAnnotation, finishBeanFactoryInitialization, finishRefresh, formatStartupDate, getAliases, getAnnotatedBeans, getApplicationEventMulticaster, getApplicationListeners, getAutowireCapableBeanFactory, getBean, getBean, getBean, getBean, getBean, getBeanNamesForAnnotation, getBeanNamesForType, getBeanNamesForType, getBeanNamesForType, getBeanNamesForType, getBeanProvider, getBeanProvider, getBeanProvider, getBeanProvider, getBeans, getBeansOfType, getBeansOfType, getBeansOfType, getBeansWithAnnotation, getBeansWithAnnotation, getBootstrapContext, getDisplayName, getEnvironment, getExpressionEvaluator, getId, getInjector, getInternalParentBeanFactory, getInternalParentMessageSource, getLifecycleProcessor, getMessage, getMessage, getMessage, getParent, getParentBeanFactory, getResources, getStartupDate, getState, getType, getType, hasStarted, initApplicationEventMulticaster, initLifecycleProcessor, initMessageSource, invokeBeanFactoryPostProcessors, isActive, isPrototype, isRunning, isSingleton, isTypeMatch, isTypeMatch, obtainFreshBeanFactory, onClose, onRefresh, prepareBeanFactory, prepareRefresh, publishEvent, publishEvent, publishEvent, refresh, registerApplicationListeners, registerBeanPostProcessors, registerFrameworkComponents, registerShutdownHook, removeApplicationListener, resetCommonCaches, scan, setBootstrapContext, setDisplayName, setEnvironment, setParent, start, stop, toString, unwrapFactory

    从类继承的方法 cn.taketoday.core.io.DefaultResourceLoader

    addProtocolResolver, clearResourceCaches, getClassLoader, getProtocolResolvers, getResource, getResourceCache, setClassLoader

    从类继承的方法 java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait

    从接口继承的方法 cn.taketoday.core.AliasRegistry

    getAliases

    从接口继承的方法 cn.taketoday.context.ApplicationContext

    getAutowireCapableBeanFactory, getDisplayName, getExpressionEvaluator, getId, getParent, getStartupDate, getState, hasStarted, unwrapFactory

    从接口继承的方法 cn.taketoday.context.ApplicationEventPublisher

    publishEvent, publishEvent

    从接口继承的方法 cn.taketoday.beans.factory.BeanFactory

    containsBean, containsBeanDefinition, findAllAnnotationsOnBean, findAnnotationOnBean, findAnnotationOnBean, findSynthesizedAnnotation, getAliases, getAnnotatedBeans, getBean, getBean, getBean, getBean, getBean, getBeanDefinition, getBeanDefinitionCount, getBeanDefinitionNames, getBeanNamesForAnnotation, getBeanNamesForType, getBeanNamesForType, getBeanNamesForType, getBeanNamesForType, getBeanNamesForType, getBeanProvider, getBeanProvider, getBeanProvider, getBeanProvider, getBeans, getBeansOfType, getBeansOfType, getBeansOfType, getBeansWithAnnotation, getBeansWithAnnotation, getType, getType, isPrototype, isSingleton, isTypeMatch, isTypeMatch, unwrap

    从接口继承的方法 cn.taketoday.context.ConfigurableApplicationContext

    addApplicationListener, addBeanFactoryPostProcessor, addProtocolResolver, close, getBeanFactory, getBootstrapContext, getEnvironment, isActive, refresh, registerShutdownHook, removeApplicationListener, setClassLoader, setEnvironment, setId, setParent

    从接口继承的方法 cn.taketoday.web.servlet.ConfigurableWebApplicationContext

    setConfigLocation, setConfigLocations

    从接口继承的方法 cn.taketoday.beans.factory.support.DependencyInjectorProvider

    getInjector

    从接口继承的方法 cn.taketoday.beans.factory.HierarchicalBeanFactory

    containsLocalBean, getParentBeanFactory

    从接口继承的方法 cn.taketoday.context.Lifecycle

    isRunning, start, stop

    从接口继承的方法 cn.taketoday.context.MessageSource

    getMessage, getMessage, getMessage

    从接口继承的方法 cn.taketoday.core.io.PatternResourceLoader

    getResources, getResourcesArray, scan

    从接口继承的方法 cn.taketoday.core.io.ResourceLoader

    getClassLoader, getResource
  • 字段详细资料

    • DEFAULT_CONFIG_LOCATION

      public static final String DEFAULT_CONFIG_LOCATION
      Default config location for the root context.
      另请参阅:
    • DEFAULT_CONFIG_LOCATION_PREFIX

      public static final String DEFAULT_CONFIG_LOCATION_PREFIX
      Default prefix for building a config location for a namespace.
      另请参阅:
    • DEFAULT_CONFIG_LOCATION_SUFFIX

      public static final String DEFAULT_CONFIG_LOCATION_SUFFIX
      Default suffix for building a config location for a namespace.
      另请参阅:
  • 构造器详细资料

    • XmlWebApplicationContext

      public XmlWebApplicationContext()
  • 方法详细资料

    • loadBeanDefinitions

      protected void loadBeanDefinitions(cn.taketoday.beans.factory.support.StandardBeanFactory beanFactory) throws cn.taketoday.beans.BeansException, IOException
      Loads the bean definitions via an XmlBeanDefinitionReader.
      指定者:
      loadBeanDefinitions 在类中 cn.taketoday.context.support.AbstractRefreshableApplicationContext
      抛出:
      cn.taketoday.beans.BeansException
      IOException
      另请参阅:
    • initBeanDefinitionReader

      protected void initBeanDefinitionReader(cn.taketoday.beans.factory.xml.XmlBeanDefinitionReader beanDefinitionReader)
      Initialize the bean definition reader used for loading the bean definitions of this context. Default implementation is empty.

      Can be overridden in subclasses, e.g. for turning off XML validation or using a different XmlBeanDefinitionParser implementation.

      参数:
      beanDefinitionReader - the bean definition reader used by this context
      另请参阅:
      • XmlBeanDefinitionReader.setValidationMode(int)
      • XmlBeanDefinitionReader.setDocumentReaderClass(java.lang.Class<? extends cn.taketoday.beans.factory.xml.BeanDefinitionDocumentReader>)
    • loadBeanDefinitions

      protected void loadBeanDefinitions(cn.taketoday.beans.factory.xml.XmlBeanDefinitionReader reader) throws IOException
      Load the bean definitions with the given XmlBeanDefinitionReader.

      The lifecycle of the bean factory is handled by the refreshBeanFactory method; therefore this method is just supposed to load and/or register bean definitions.

      Delegates to a ResourcePatternResolver for resolving location patterns into Resource instances.

      抛出:
      IOException - if the required XML document isn't found
      另请参阅:
    • getDefaultConfigLocations

      protected String[] getDefaultConfigLocations()
      The default location for the root context is "/WEB-INF/applicationContext.xml", and "/WEB-INF/test-servlet.xml" for a context with the namespace "test-servlet" (like for a DispatcherServlet instance with the servlet-name "test").
      覆盖:
      getDefaultConfigLocations 在类中 cn.taketoday.context.support.AbstractRefreshableConfigApplicationContext