Class AbstractApplicationContextFactory
java.lang.Object
org.springframework.batch.core.configuration.support.AbstractApplicationContextFactory
- All Implemented Interfaces:
ApplicationContextFactory
,org.springframework.beans.factory.Aware
,org.springframework.context.ApplicationContextAware
- Direct Known Subclasses:
GenericApplicationContextFactory
public abstract class AbstractApplicationContextFactory
extends Object
implements ApplicationContextFactory, org.springframework.context.ApplicationContextAware
ApplicationContextFactory
implementation that takes a parent context and a path
to the context to create. When the createApplicationContext
method is called,
the child ApplicationContext
is 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 is
always returned.-
Constructor Summary
ConstructorDescriptionAbstractApplicationContextFactory
(Object... resource) Create a factory instance with the resource specified. -
Method Summary
Modifier and TypeMethodDescriptionorg.springframework.context.ConfigurableApplicationContext
Creates anApplicationContext
from the provided path.protected abstract org.springframework.context.ConfigurableApplicationContext
createApplicationContext
(org.springframework.context.ConfigurableApplicationContext parent, Object... resources) boolean
protected final Collection<Class<? extends org.springframework.beans.factory.config.BeanFactoryPostProcessor>>
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 final boolean
Protected access for subclasses to the flag that determines whether configuration should be copied from the parent context.protected void
prepareBeanFactory
(org.springframework.beans.factory.config.ConfigurableListableBeanFactory parent, org.springframework.beans.factory.config.ConfigurableListableBeanFactory 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 (such as 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.toString()
-
Constructor Details
-
AbstractApplicationContextFactory
Create a factory instance with the resource specified. The resources are Spring configuration files or Java packages that contain configuration files.- Parameters:
resource
- resource to be used in the creation of the ApplicationContext.
-
-
Method Details
-
setCopyConfiguration
public void setCopyConfiguration(boolean copyConfiguration) Flag to indicate that configuration, such as bean post processors and custom editors, should be copied from the parent context. Defaults totrue
.- Parameters:
copyConfiguration
- the flag value to set
-
isCopyConfiguration
protected final boolean isCopyConfiguration()Protected access for subclasses to the flag that determines whether configuration should be copied from the parent context.- Returns:
- the flag value
-
setBeanFactoryPostProcessorClasses
public void setBeanFactoryPostProcessorClasses(Class<? extends org.springframework.beans.factory.config.BeanFactoryPostProcessor>[] beanFactoryPostProcessorClasses) Determines which bean factory post processors (such as property placeholders) should be copied from the parent context. Defaults toPropertySourcesPlaceholderConfigurer
andCustomEditorConfigurer
.- Parameters:
beanFactoryPostProcessorClasses
- array of post processor types to be copied
-
setBeanPostProcessorExcludeClasses
Determines, by exclusion, which bean post processors should be copied from the parent context. Defaults toBeanFactoryAware
(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 beBeanPostProcessor
implementations or sub-interfaces.- Parameters:
beanPostProcessorExcludeClasses
- the classes to set
-
getBeanFactoryPostProcessorClasses
protected final 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.- Returns:
- the classes for post processors that were nominated for copying
-
setApplicationContext
public void setApplicationContext(org.springframework.context.ApplicationContext applicationContext) throws org.springframework.beans.BeansException Setter for the parent application context.- Specified by:
setApplicationContext
in interfaceorg.springframework.context.ApplicationContextAware
- Throws:
org.springframework.beans.BeansException
- See Also:
-
ApplicationContextAware.setApplicationContext(org.springframework.context.ApplicationContext)
-
createApplicationContext
public org.springframework.context.ConfigurableApplicationContext createApplicationContext()Creates anApplicationContext
from the provided path.- Specified by:
createApplicationContext
in interfaceApplicationContextFactory
- See Also:
-
createApplicationContext
protected abstract org.springframework.context.ConfigurableApplicationContext createApplicationContext(org.springframework.context.ConfigurableApplicationContext parent, Object... resources) -
prepareContext
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. The default implementation does nothing.- Parameters:
parent
- the parent for the new application contextcontext
- the new application context before it is refreshed but after the bean factory is initialized- See Also:
-
prepareBeanFactory
protected void prepareBeanFactory(org.springframework.beans.factory.config.ConfigurableListableBeanFactory parent, org.springframework.beans.factory.config.ConfigurableListableBeanFactory beanFactory) Extension point for special subclasses that want to do more complex things with the bean factory prior to refresh. The default implementation copies all configuration from the parent according to theflag
set.- Parameters:
parent
- the parent bean factory for the new context (can never be null)beanFactory
- the new bean factory before bean definitions are loaded- See Also:
-
setCopyConfiguration(boolean)
DefaultListableBeanFactory.copyConfigurationFrom(ConfigurableBeanFactory)
-
toString
-
hashCode
public int hashCode() -
equals
-