abstract class WebApplicationContextUtils
Convenience methods for retrieving the root WebApplicationContext for a given ServletContext. This is useful for programmatically accessing a Spring application context from within custom web views or MVC actions.
Note that there are more convenient ways of accessing the root context for many web frameworks, either part of Spring or available as an external library. This helper class is just the most generic way to access the root context.
Author
Juergen Hoeller
See Also
org.springframework.web.context.ContextLoaderorg.springframework.web.servlet.FrameworkServletorg.springframework.web.servlet.DispatcherServletorg.springframework.web.jsf.FacesContextUtilsorg.springframework.web.jsf.el.SpringBeanFacesELResolver
WebApplicationContextUtils()
Convenience methods for retrieving the root WebApplicationContext for a given ServletContext. This is useful for programmatically accessing a Spring application context from within custom web views or MVC actions. Note that there are more convenient ways of accessing the root context for many web frameworks, either part of Spring or available as an external library. This helper class is just the most generic way to access the root context. |
open static fun findWebApplicationContext(sc: ServletContext): WebApplicationContext
Find a unique Note that |
|
open static fun getRequiredWebApplicationContext(sc: ServletContext): WebApplicationContext
Find the root Will rethrow an exception that happened on root context startup, to differentiate between a failed context startup and no context at all. |
|
open static fun getWebApplicationContext(sc: ServletContext): WebApplicationContext
Find the root Will rethrow an exception that happened on root context startup, to differentiate between a failed context startup and no context at all. open static fun getWebApplicationContext(sc: ServletContext, attrName: String): WebApplicationContext
Find a custom |
|
open static fun initServletPropertySources(propertySources: MutablePropertySources, servletContext: ServletContext): Unit
Convenient variant of open static fun initServletPropertySources(sources: MutablePropertySources, servletContext: ServletContext, servletConfig: ServletConfig): Unit
Replace This method is idempotent with respect to the fact it may be called any number of times but will perform replacement of stub property sources with their corresponding actual property sources once and only once. |
|
open static fun registerEnvironmentBeans(bf: ConfigurableListableBeanFactory, sc: ServletContext): Unitopen static fun registerEnvironmentBeans(bf: ConfigurableListableBeanFactory, servletContext: ServletContext, servletConfig: ServletConfig): Unit
Register web-specific environment beans ("contextParameters", "contextAttributes") with the given BeanFactory, as used by the WebApplicationContext. |
|
open static fun registerWebApplicationScopes(beanFactory: ConfigurableListableBeanFactory): Unit
Register web-specific scopes ("request", "session", "globalSession") with the given BeanFactory, as used by the WebApplicationContext. open static fun registerWebApplicationScopes(beanFactory: ConfigurableListableBeanFactory, sc: ServletContext): Unit
Register web-specific scopes ("request", "session", "globalSession", "application") with the given BeanFactory, as used by the WebApplicationContext. |