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

public Class StaticWebApplicationContext

extends StaticApplicationContext
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
Annotations
@SuppressWarnings:deprecation
Imports
jakarta.servlet.ServletConfig, .ServletContext, org.springframework.beans.factory.config.ConfigurableListableBeanFactory, org.springframework.context.support.StaticApplicationContext, 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, .ServletConfigAware, .ServletContextAware

Deprecated

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

Static org.springframework.web.context.WebApplicationContext implementation for testing. Not intended for use in production applications.

Implements the org.springframework.web.context.ConfigurableWebApplicationContext interface to allow for direct replacement of an XmlWebApplicationContext, despite not actually supporting external configuration files.

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.

Authors
Rod Johnson, Juergen Hoeller
See Also
org.springframework.ui.context.ThemeSource

Field Summary

Modifier and TypeField and Description
private String
private ServletConfig
private ServletContext
private ThemeSource
themeSource

Deprecated as a consequence of ThemeSource being deprecated.

Constructor Summary

AccessConstructor and Description
public

Method Summary

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

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

Return the config locations for this web application context, or null if none specified.
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
public void
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 that this WebApplicationContext runs in.
Inherited from org.springframework.context.support.StaticApplicationContext:
addMessageassertBeanFactoryActivegetStaticMessageSourceregisterPrototyperegisterPrototyperegisterSingletonregisterSingleton

Field Detail

namespaceback to summary
private String namespace
Annotations
@Nullable
servletConfigback to summary
private ServletConfig servletConfig
Annotations
@Nullable
servletContextback to summary
private ServletContext servletContext
Annotations
@Nullable
themeSourceback to summary
private ThemeSource themeSource

Deprecated

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

Annotations
@Nullable

Constructor Detail

StaticWebApplicationContextback to summary
public StaticWebApplicationContext()

Method Detail

createEnvironmentback to summary
protected ConfigurableEnvironment createEnvironment()

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

Create and return a new StandardServletEnvironment.

Annotations
@Override
getConfigLocationsback to summary
public String[] 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.

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.

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
setConfigLocationback to summary
public void setConfigLocation(String configLocation)

Implements org.springframework.web.context.ConfigurableWebApplicationContext.setConfigLocation.

The StaticWebApplicationContext class does not support this method.

Annotations
@Override
Exceptions
UnsupportedOperationException:
always
setConfigLocationsback to summary
public void setConfigLocations(String... configLocations)

Implements org.springframework.web.context.ConfigurableWebApplicationContext.setConfigLocations.

The StaticWebApplicationContext class does not support this method.

Annotations
@Override
Exceptions
UnsupportedOperationException:
always
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.

Set the ServletContext that this WebApplicationContext runs in.

Annotations
@Override