org.springframework.web.context.support
abstract public class: AbstractRefreshableWebApplicationContext [javadoc |
source]
java.lang.Object
org.springframework.core.io.DefaultResourceLoader
org.springframework.context.support.AbstractApplicationContext
org.springframework.context.support.AbstractRefreshableApplicationContext
org.springframework.context.support.AbstractRefreshableConfigApplicationContext
org.springframework.web.context.support.AbstractRefreshableWebApplicationContext
All Implemented Interfaces:
ThemeSource, ConfigurableWebApplicationContext, BeanNameAware, InitializingBean, ConfigurableApplicationContext, DisposableBean, ResourceLoader
Direct Known Subclasses:
XmlWebApplicationContext
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 implements 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".
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 ).
Method from org.springframework.web.context.support.AbstractRefreshableWebApplicationContext Summary: |
---|
getConfigLocations, getNamespace, getResourceByPath, getResourcePatternResolver, getServletConfig, getServletContext, getTheme, onRefresh, postProcessBeanFactory, setNamespace, setServletConfig, setServletContext |
Methods from org.springframework.context.support.AbstractApplicationContext: |
---|
addApplicationListener, addBeanFactoryPostProcessor, addListener, cancelRefresh, close, closeBeanFactory, containsBean, containsBeanDefinition, containsLocalBean, destroy, destroyBeans, doClose, finishBeanFactoryInitialization, finishRefresh, getAliases, getApplicationListeners, getAutowireCapableBeanFactory, getBean, getBean, getBean, getBeanDefinitionCount, getBeanDefinitionNames, getBeanFactory, getBeanFactoryPostProcessors, getBeanNamesForType, getBeanNamesForType, getBeansOfType, getBeansOfType, getDisplayName, getId, getInternalParentBeanFactory, getInternalParentMessageSource, getMessage, getMessage, getMessage, getParent, getParentBeanFactory, getResourcePatternResolver, getResources, getStartupDate, getType, initApplicationEventMulticaster, initMessageSource, invokeBeanFactoryPostProcessors, isActive, isPrototype, isRunning, isSingleton, isTypeMatch, obtainFreshBeanFactory, onClose, onRefresh, postProcessBeanFactory, prepareBeanFactory, prepareRefresh, publishEvent, refresh, refreshBeanFactory, registerBeanPostProcessors, registerListeners, registerShutdownHook, setDisplayName, setId, setParent, start, stop, toString |
Methods from java.lang.Object: |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method from org.springframework.web.context.support.AbstractRefreshableWebApplicationContext Detail: |
public String[] getConfigLocations() {
return super.getConfigLocations();
}
|
public String getNamespace() {
return this.namespace;
}
|
protected Resource getResourceByPath(String path) {
return new ServletContextResource(this.servletContext, path);
}
This implementation supports file paths beneath the root of the ServletContext. |
protected ResourcePatternResolver getResourcePatternResolver() {
return new ServletContextResourcePatternResolver(this);
}
This implementation supports pattern matching in unexpanded WARs too. |
public ServletConfig getServletConfig() {
return this.servletConfig;
}
|
public ServletContext getServletContext() {
return this.servletContext;
}
|
public Theme getTheme(String themeName) {
return this.themeSource.getTheme(themeName);
}
|
protected void onRefresh() {
this.themeSource = UiApplicationContextUtils.initThemeSource(this);
}
Initialize the theme capability. |
protected void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) {
beanFactory.addBeanPostProcessor(new ServletContextAwareProcessor(this.servletContext, this.servletConfig));
beanFactory.ignoreDependencyInterface(ServletContextAware.class);
beanFactory.ignoreDependencyInterface(ServletConfigAware.class);
beanFactory.registerResolvableDependency(ServletContext.class, this.servletContext);
beanFactory.registerResolvableDependency(ServletConfig.class, this.servletConfig);
WebApplicationContextUtils.registerWebApplicationScopes(beanFactory);
}
|
public void setNamespace(String namespace) {
this.namespace = namespace;
if (namespace != null) {
setDisplayName("WebApplicationContext for namespace '" + namespace + "'");
}
}
|
public void setServletConfig(ServletConfig servletConfig) {
this.servletConfig = servletConfig;
if (servletConfig != null && this.servletContext == null) {
this.servletContext = servletConfig.getServletContext();
}
}
|
public void setServletContext(ServletContext servletContext) {
this.servletContext = servletContext;
}
|