Top Description Fields Constructors Methods
org.springframework.web.context.support

public abstract Class AbstractRefreshableWebApplicationContext

extends AbstractRefreshableConfigApplicationContext
implements ConfigurableWebApplicationContext, ThemeSource
Class Inheritance
All Implemented Interfaces
org.springframework.ui.context.ThemeSource, org.springframework.web.context.ConfigurableWebApplicationContext, org.springframework.context.ConfigurableApplicationContext, java.io.Closeable, java.lang.AutoCloseable, org.springframework.context.Lifecycle, org.springframework.context.ApplicationContext, org.springframework.core.io.support.ResourcePatternResolver, org.springframework.core.io.ResourceLoader, org.springframework.context.ApplicationEventPublisher, org.springframework.context.MessageSource, org.springframework.beans.factory.HierarchicalBeanFactory, org.springframework.beans.factory.BeanFactory, org.springframework.beans.factory.ListableBeanFactory, org.springframework.core.env.EnvironmentCapable, org.springframework.web.context.WebApplicationContext
Known Direct Subclasses
org.springframework.web.context.support.AnnotationConfigWebApplicationContext, org.springframework.web.context.support.GroovyWebApplicationContext, org.springframework.web.context.support.XmlWebApplicationContext
Annotations
@SuppressWarnings:deprecation
Imports
jakarta.servlet.ServletConfig, .ServletContext, org.springframework.beans.factory.config.ConfigurableListableBeanFactory, org.springframework.context.support.AbstractRefreshableConfigApplicationContext, org.springframework.core.env.ConfigurableEnvironment, org.springframework.core.io.Resource, org.springframework.core.io.support.ResourcePatternResolver, org.springframework.lang.Nullable, org.springframework.ui.context.Theme, .ThemeSource, org.springframework.ui.context.support.UiApplicationContextUtils, org.springframework.util.Assert, org.springframework.web.context.ConfigurableWebApplicationContext, .ConfigurableWebEnvironment, .ServletConfigAware, .ServletContextAware

Deprecated

as a consequence of ThemeSource being deprecated. See corresponding docs for further information.

org.springframework.context.support.AbstractRefreshableApplicationContext subclass which implements the org.springframework.web.context.ConfigurableWebApplicationContext interface for web environments. Provides a "configLocations" property, to be populated through the ConfigurableWebApplicationContext interface on web application startup.

This class is as easy to subclass as AbstractRefreshableApplicationContext: All you need to implement is the loadBeanDefinitions method; see the superclass javadoc for details. Note that implementations are supposed to load bean definitions from the files specified by the locations returned by the getConfigLocations method.

Interprets resource paths as servlet context resources, i.e. as paths beneath the web application root. Absolute paths, e.g. for files outside the web app root, can be accessed via "file:" URLs, as implemented by org.springframework.core.io.DefaultResourceLoader.

In addition to the special beans detected by org.springframework.context.support.AbstractApplicationContext, this class detects a bean of type org.springframework.ui.context.ThemeSource in the context, under the special bean name "themeSource". Theme support is deprecated as of 6.0 with no direct replacement.

This is the web context to be subclassed for a different bean definition format. Such a context implementation can be specified as "contextClass" context-param for org.springframework.web.context.ContextLoader or as "contextClass" init-param for org.springframework.web.servlet.FrameworkServlet, replacing the default XmlWebApplicationContext. It will then automatically receive the "contextConfigLocation" context-param or init-param, respectively.

Note that WebApplicationContext implementations are generally supposed to configure themselves based on the configuration received through the ConfigurableWebApplicationContext interface. In contrast, a standalone application context might allow for configuration in custom startup code (for example, org.springframework.context.support.GenericApplicationContext).

Author
Juergen Hoeller
Since
1.1.3
See Also
loadBeanDefinitions, org.springframework.web.context.ConfigurableWebApplicationContext#setConfigLocations, XmlWebApplicationContext

Field Summary

Modifier and TypeField and Description
private String
namespace

Namespace of this context, or null if root.

private ServletConfig
servletConfig

Servlet config that this context runs in, if any.

private ServletContext
servletContext

Servlet context that this context runs in.

private ThemeSource
themeSource

the ThemeSource for this ApplicationContext.

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
protected ConfigurableEnvironment
public String
public String[]
public String
getNamespace()

Implements org.springframework.web.context.ConfigurableWebApplicationContext.getNamespace.

Return the namespace for this web application context, if any.
protected Resource
getResourceByPath(String
the path to the resource
path
)

Overrides org.springframework.core.io.DefaultResourceLoader.getResourceByPath.

This implementation supports file paths beneath the root of the ServletContext.
protected ResourcePatternResolver
getResourcePatternResolver()

Overrides org.springframework.context.support.AbstractApplicationContext.getResourcePatternResolver.

This implementation supports pattern matching in unexpanded WARs too.
public ServletConfig
getServletConfig()

Implements org.springframework.web.context.ConfigurableWebApplicationContext.getServletConfig.

Return the ServletConfig for this web application context, if any.
public ServletContext
getServletContext()

Implements org.springframework.web.context.WebApplicationContext.getServletContext.

Return the standard Servlet API ServletContext for this application.
public Theme
getTheme(String
the name of the theme
themeName
)

Implements org.springframework.ui.context.ThemeSource.getTheme.

Deprecated
Return the Theme instance for the given theme name.
protected void
initPropertySources()

Overrides org.springframework.context.support.AbstractApplicationContext.initPropertySources.

Replace any stub property sources with actual instances.

protected void
protected void
postProcessBeanFactory(ConfigurableListableBeanFactory
the bean factory used by the application context
beanFactory
)

Overrides org.springframework.context.support.AbstractApplicationContext.postProcessBeanFactory.

Register request/session scopes, a ServletContextAwareProcessor, etc.
public void
setNamespace(String namespace)

Implements org.springframework.web.context.ConfigurableWebApplicationContext.setNamespace.

Set the namespace for this web application context, to be used for building a default context config location.
public void
setServletConfig(ServletConfig servletConfig)

Implements org.springframework.web.context.ConfigurableWebApplicationContext.setServletConfig.

Set the ServletConfig for this web application context.
public void
setServletContext(ServletContext servletContext)

Implements org.springframework.web.context.ConfigurableWebApplicationContext.setServletContext.

Set the ServletContext for this web application context.
Inherited from org.springframework.context.support.AbstractRefreshableConfigApplicationContext:
afterPropertiesSetgetDefaultConfigLocationsresolvePathsetBeanNamesetConfigLocationsetConfigLocationssetId

Field Detail

namespaceback to summary
private String namespace

Namespace of this context, or null if root.

Annotations
@Nullable
servletConfigback to summary
private ServletConfig servletConfig

Servlet config that this context runs in, if any.

Annotations
@Nullable
servletContextback to summary
private ServletContext servletContext

Servlet context that this context runs in.

Annotations
@Nullable
themeSourceback to summary
private ThemeSource themeSource

Deprecated

as a consequence of ThemeSource being deprecated. See corresponding docs for further information.

the ThemeSource for this ApplicationContext.

Annotations
@Nullable

Constructor Detail

AbstractRefreshableWebApplicationContextback to summary
public AbstractRefreshableWebApplicationContext()

Method Detail

createEnvironmentback to summary
protected ConfigurableEnvironment createEnvironment()

Overrides org.springframework.context.support.AbstractApplicationContext.createEnvironment.

Create and return a new StandardServletEnvironment. Subclasses may override in order to configure the environment or specialize the environment type returned.

Annotations
@Override
getApplicationNameback to summary
public String getApplicationName()

Overrides org.springframework.context.support.AbstractApplicationContext.getApplicationName.

Implements org.springframework.context.ApplicationContext.getApplicationName.

Doc from org.springframework.context.ApplicationContext.getApplicationName.

Return a name for the deployed application that this context belongs to.

Returns:String

a name for the deployed application, or the empty String by default

Annotations
@Override
getConfigLocationsback to summary
public String[] getConfigLocations()

Overrides org.springframework.context.support.AbstractRefreshableConfigApplicationContext.getConfigLocations.

Implements org.springframework.web.context.ConfigurableWebApplicationContext.getConfigLocations.

Doc from org.springframework.web.context.ConfigurableWebApplicationContext.getConfigLocations.

Return the config locations for this web application context, or null if none specified.

Returns:String[]

Doc from org.springframework.context.support.AbstractRefreshableConfigApplicationContext.getConfigLocations.

an array of resource locations, or null if none

Annotations
@Override
getNamespaceback to summary
public String getNamespace()

Implements org.springframework.web.context.ConfigurableWebApplicationContext.getNamespace.

Doc from org.springframework.web.context.ConfigurableWebApplicationContext.getNamespace.

Return the namespace for this web application context, if any.

Annotations
@Override
@Nullable
getResourceByPathback to summary
protected Resource getResourceByPath(String path)

Overrides org.springframework.core.io.DefaultResourceLoader.getResourceByPath.

This implementation supports file paths beneath the root of the ServletContext.

Parameters
path:String

Doc from org.springframework.core.io.DefaultResourceLoader.getResourceByPath.

the path to the resource

Returns:Resource

Doc from org.springframework.core.io.DefaultResourceLoader.getResourceByPath.

the corresponding Resource handle

Annotations
@Override
See Also
ServletContextResource
getResourcePatternResolverback to summary
protected ResourcePatternResolver getResourcePatternResolver()

Overrides org.springframework.context.support.AbstractApplicationContext.getResourcePatternResolver.

This implementation supports pattern matching in unexpanded WARs too.

Returns:ResourcePatternResolver

Doc from org.springframework.context.support.AbstractApplicationContext.getResourcePatternResolver.

the ResourcePatternResolver for this context

Annotations
@Override
See Also
ServletContextResourcePatternResolver
getServletConfigback to summary
public ServletConfig getServletConfig()

Implements org.springframework.web.context.ConfigurableWebApplicationContext.getServletConfig.

Doc from org.springframework.web.context.ConfigurableWebApplicationContext.getServletConfig.

Return the ServletConfig for this web application context, if any.

Annotations
@Override
@Nullable
getServletContextback to summary
public ServletContext getServletContext()

Implements org.springframework.web.context.WebApplicationContext.getServletContext.

Doc from org.springframework.web.context.WebApplicationContext.getServletContext.

Return the standard Servlet API ServletContext for this application.

Annotations
@Override
@Nullable
getThemeback to summary
public Theme getTheme(String themeName)

Implements org.springframework.ui.context.ThemeSource.getTheme.

Doc from org.springframework.ui.context.ThemeSource.getTheme.

Deprecated

Return the Theme instance for the given theme name.

The returned Theme will resolve theme-specific messages, codes, file paths, etc (e.g. CSS and image files in a web environment).

Parameters
themeName:String

the name of the theme

Returns:Theme

the corresponding Theme, or null if none defined. Note that, by convention, a ThemeSource should at least be able to return a default Theme for the default theme name "theme" but may also return default Themes for other theme names.

Annotations
@Override
@Nullable
@Deprecated
initPropertySourcesback to summary
protected void initPropertySources()

Overrides org.springframework.context.support.AbstractApplicationContext.initPropertySources.

Doc from org.springframework.context.support.AbstractApplicationContext.initPropertySources.

Replace any stub property sources with actual instances.

Replace Servlet-related property sources.

Annotations
@Override
onRefreshback to summary
protected void onRefresh()

Overrides org.springframework.context.support.AbstractApplicationContext.onRefresh.

Initialize the theme capability.

Annotations
@Override
postProcessBeanFactoryback to summary
protected void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory)

Overrides org.springframework.context.support.AbstractApplicationContext.postProcessBeanFactory.

Register request/session scopes, a ServletContextAwareProcessor, etc.

Parameters
beanFactory:ConfigurableListableBeanFactory

Doc from org.springframework.context.support.AbstractApplicationContext.postProcessBeanFactory.

the bean factory used by the application context

Annotations
@Override
setNamespaceback to summary
public void setNamespace(String namespace)

Implements org.springframework.web.context.ConfigurableWebApplicationContext.setNamespace.

Doc from org.springframework.web.context.ConfigurableWebApplicationContext.setNamespace.

Set the namespace for this web application context, to be used for building a default context config location. The root web application context does not have a namespace.

Annotations
@Override
setServletConfigback to summary
public void setServletConfig(ServletConfig servletConfig)

Implements org.springframework.web.context.ConfigurableWebApplicationContext.setServletConfig.

Doc from org.springframework.web.context.ConfigurableWebApplicationContext.setServletConfig.

Set the ServletConfig for this web application context. Only called for a WebApplicationContext that belongs to a specific Servlet.

Annotations
@Override
setServletContextback to summary
public void setServletContext(ServletContext servletContext)

Implements org.springframework.web.context.ConfigurableWebApplicationContext.setServletContext.

Doc from org.springframework.web.context.ConfigurableWebApplicationContext.setServletContext.

Set the ServletContext for this web application context.

Does not cause an initialization of the context: refresh needs to be called after the setting of all configuration properties.

Annotations
@Override