public class ClassPathXmlApplicationContextFactory extends Object implements ApplicationContextFactory, org.springframework.context.ApplicationContextAware
ApplicationContextFactory implementation that takes a parent context
and a path to the context to create. When createApplicationContext method is
called, the child ApplicationContext will be returned. The child
context is not re-created every time it is requested, it is lazily
initialized and cached. Clients should ensure that it is closed when it is no
longer needed. If a path is not set, the parent will always be returned.| Constructor and Description |
|---|
ClassPathXmlApplicationContextFactory()
Convenient constructor for configuration purposes.
|
ClassPathXmlApplicationContextFactory(org.springframework.core.io.Resource resource)
Create a factory instance with the resource specified.
|
| Modifier and Type | Method and Description |
|---|---|
org.springframework.context.ConfigurableApplicationContext |
createApplicationContext()
Creates an
ApplicationContext from the provided path. |
boolean |
equals(Object obj) |
protected Collection<Class<? extends org.springframework.beans.factory.config.BeanFactoryPostProcessor>> |
getBeanFactoryPostProcessorClasses()
Protected access to the list of bean factory post processor classes that
should be copied over to the context from the parent.
|
int |
hashCode() |
protected boolean |
isCopyConfiguration()
Protected access for subclasses to the flag determining whether
configuration should be copied from parent context.
|
protected void |
prepareBeanFactory(org.springframework.beans.factory.support.DefaultListableBeanFactory parent,
org.springframework.beans.factory.support.DefaultListableBeanFactory beanFactory)
Extension point for special subclasses that want to do more complex
things with the bean factory prior to refresh.
|
protected void |
prepareContext(org.springframework.context.ConfigurableApplicationContext parent,
org.springframework.context.ConfigurableApplicationContext context)
Extension point for special subclasses that want to do more complex
things with the context prior to refresh.
|
void |
setApplicationContext(org.springframework.context.ApplicationContext applicationContext)
Setter for the parent application context.
|
void |
setBeanFactoryPostProcessorClasses(Class<? extends org.springframework.beans.factory.config.BeanFactoryPostProcessor>[] beanFactoryPostProcessorClasses)
Determines which bean factory post processors (like property
placeholders) should be copied from the parent context.
|
void |
setBeanPostProcessorExcludeClasses(Class<?>[] beanPostProcessorExcludeClasses)
Determines by exclusion which bean post processors should be copied from
the parent context.
|
void |
setCopyConfiguration(boolean copyConfiguration)
Flag to indicate that configuration such as bean post processors and
custom editors should be copied from the parent context.
|
void |
setResource(org.springframework.core.io.Resource resource)
Setter for the path to the xml to load to create an
ApplicationContext. |
String |
toString() |
public ClassPathXmlApplicationContextFactory()
public ClassPathXmlApplicationContextFactory(org.springframework.core.io.Resource resource)
public void setResource(org.springframework.core.io.Resource resource)
ApplicationContext. Use imports to centralise the configuration
in one file.resource - the resource path to the xml to load for the child
context.public void setCopyConfiguration(boolean copyConfiguration)
copyConfiguration - the flag value to setprotected final boolean isCopyConfiguration()
public void setBeanFactoryPostProcessorClasses(Class<? extends org.springframework.beans.factory.config.BeanFactoryPostProcessor>[] beanFactoryPostProcessorClasses)
PropertyPlaceholderConfigurer and CustomEditorConfigurer.copyBeanFactoryPostProcessors - the flag value to setpublic void setBeanPostProcessorExcludeClasses(Class<?>[] beanPostProcessorExcludeClasses)
BeanFactoryAware (so any post
processors that have a reference to the parent bean factory are not
copied into the child). Note that these classes do not themselves have to
be BeanPostProcessor implementations or sub-interfaces.beanPostProcessorExcludeClasses - the classes to setprotected final Collection<Class<? extends org.springframework.beans.factory.config.BeanFactoryPostProcessor>> getBeanFactoryPostProcessorClasses()
public void setApplicationContext(org.springframework.context.ApplicationContext applicationContext)
throws org.springframework.beans.BeansException
setApplicationContext in interface org.springframework.context.ApplicationContextAwareorg.springframework.beans.BeansExceptionApplicationContextAware.setApplicationContext(org.springframework.context.ApplicationContext)public org.springframework.context.ConfigurableApplicationContext createApplicationContext()
ApplicationContext from the provided path.createApplicationContext in interface ApplicationContextFactoryApplicationContextFactory.createApplicationContext()protected void prepareContext(org.springframework.context.ConfigurableApplicationContext parent,
org.springframework.context.ConfigurableApplicationContext context)
parent - the parent for the new application contextcontext - the new application context before it is refreshed, but
after bean factory is initializedsetBeanFactoryPostProcessorClasses(Class[])protected void prepareBeanFactory(org.springframework.beans.factory.support.DefaultListableBeanFactory parent,
org.springframework.beans.factory.support.DefaultListableBeanFactory beanFactory)
flag set.parent - the parent bean factory for the new context (will never be
null)beanFactory - the new bean factory before bean definitions are
loadedsetCopyConfiguration(boolean),
DefaultListableBeanFactory.copyConfigurationFrom(ConfigurableBeanFactory)Copyright © 2014 SpringSource. All rights reserved.