References Deprecated
AbstractRefreshableWebApplicationContext is deprecated or references (maybe indirectly) at least one deprecated element.
See corresponding docs for further information.
org.springframework.web.context.WebApplicationContext implementation which takes
its configuration from Groovy bean definition scripts and/or XML files, as understood by
a org.springframework.beans.factory.groovy.GroovyBeanDefinitionReader .
This is essentially the equivalent of
org.springframework.context.support.GenericGroovyApplicationContext
for a web environment.
By default, the configuration will be taken from "/WEB-INF/applicationContext.groovy" for the root context, and "/WEB-INF/test-servlet.groovy" 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 org. and servlet
init-param of org.. Config locations
can either denote concrete files like "/WEB-INF/context.groovy" or Ant-style patterns
like "/WEB-INF/*-context.groovy" (see org.
javadoc for pattern details). Note that ".xml" files will be parsed as XML content;
all other kinds of resources will be parsed as Groovy scripts.
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 Groovy script.
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.
setNamespace, setConfigLocations, org.springframework.beans.factory.groovy.GroovyBeanDefinitionReader , org.springframework.web.context.ContextLoader#initWebApplicationContext , org.springframework.web.servlet.FrameworkServlet#initWebApplicationContext
| Modifier and Type | Field and Description |
|---|---|
| private final BeanWrapper | |
| public static final String | DEFAULT_CONFIG_LOCATION
Default config location for the root context. |
| public static final String | DEFAULT_CONFIG_LOCATION_PREFIX
Default prefix for building a config location for a namespace. |
| public static final String | DEFAULT_CONFIG_LOCATION_SUFFIX
Default suffix for building a config location for a namespace. |
| private MetaClass |
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| protected String[] | getDefaultConfigLocations()
The default location for the root context is "/WEB-INF/applicationContext.groovy", and "/WEB-INF/test-servlet.groovy" for a context with the namespace "test-servlet" (like for a DispatcherServlet instance with the servlet-name "test"). |
| public MetaClass | getMetaClass()
Implements groovy. Returns the metaclass for a given class. |
| public Object | getProperty(String
the name of the property of interest property)Overrides default groovy. Retrieves a property value. |
| protected void | initBeanDefinitionReader(GroovyBeanDefinitionReader
the bean definition reader used by this context beanDefinitionReader)Initialize the bean definition reader used for loading the bean definitions of this context. |
| public Object | invokeMethod(String
the name of the method to call name, Object the arguments to use for the method call args)Overrides default groovy. Invokes the given method. |
| protected void | loadBeanDefinitions(DefaultListableBeanFactory
the bean factory to load bean definitions into beanFactory)Implements abstract org. Loads the bean definitions via an GroovyBeanDefinitionReader. |
| protected void | loadBeanDefinitions(GroovyBeanDefinitionReader reader)
Load the bean definitions with the given GroovyBeanDefinitionReader. |
| public void | setMetaClass(MetaClass
the new metaclass metaClass)Implements groovy. Allows the MetaClass to be replaced with a derived implementation. |
| public void | setProperty(String
the name of the property of interest property, Object the new value for the property newValue)Overrides default groovy. Sets the given property to the new value. |
| contextWrapper | back to summary |
|---|---|
| private final BeanWrapper contextWrapper | |
| DEFAULT_CONFIG_LOCATION | back to summary |
|---|---|
| public static final String DEFAULT_CONFIG_LOCATION Default config location for the root context. | |
| DEFAULT_CONFIG_LOCATION_PREFIX | back to summary |
|---|---|
| public static final String DEFAULT_CONFIG_LOCATION_PREFIX Default prefix for building a config location for a namespace. | |
| DEFAULT_CONFIG_LOCATION_SUFFIX | back to summary |
|---|---|
| public static final String DEFAULT_CONFIG_LOCATION_SUFFIX Default suffix for building a config location for a namespace. | |
| metaClass | back to summary |
|---|---|
| private MetaClass metaClass | |
| GroovyWebApplicationContext | back to summary |
|---|---|
| public GroovyWebApplicationContext() | |
| getDefaultConfigLocations | back to summary |
|---|---|
| protected String[] getDefaultConfigLocations() The default location for the root context is "/WEB-INF/applicationContext.groovy", and "/WEB-INF/test-servlet.groovy" for a context with the namespace "test-servlet" (like for a DispatcherServlet instance with the servlet-name "test").
| |
| getMetaClass | back to summary |
|---|---|
| public MetaClass getMetaClass() Implements groovy. Doc from groovy. Returns the metaclass for a given class. | |
| getProperty | back to summary |
|---|---|
| public Object getProperty(String property) Overrides default groovy. Doc from groovy. Retrieves a property value. | |
| initBeanDefinitionReader | back to summary |
|---|---|
| protected void initBeanDefinitionReader(GroovyBeanDefinitionReader beanDefinitionReader) Initialize the bean definition reader used for loading the bean definitions of this context. Default implementation is empty. Can be overridden in subclasses.
| |
| invokeMethod | back to summary |
|---|---|
| public Object invokeMethod(String name, Object args) Overrides default groovy. Doc from groovy. Invokes the given method. | |
| loadBeanDefinitions | back to summary |
|---|---|
| protected void loadBeanDefinitions(DefaultListableBeanFactory beanFactory) throws BeansException, IOException Implements abstract org. Loads the bean definitions via an GroovyBeanDefinitionReader.
| |
| loadBeanDefinitions | back to summary |
|---|---|
| protected void loadBeanDefinitions(GroovyBeanDefinitionReader reader) throws IOException Load the bean definitions with the given GroovyBeanDefinitionReader. 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.
| |
| setMetaClass | back to summary |
|---|---|
| public void setMetaClass(MetaClass metaClass) Implements groovy. Doc from groovy. Allows the MetaClass to be replaced with a derived implementation. | |
| setProperty | back to summary |
|---|---|
| public void setProperty(String property, Object newValue) Overrides default groovy. Doc from groovy. Sets the given property to the new value. | |