org.springframework.context.ApplicationContext
implementations which are supposed to support multiple calls to refresh(),
creating a new internal bean factory instance every time.
Typically (but not necessarily), such a context will be driven by
a set of config locations to load bean definitions from.
The only method to be implemented by subclasses is loadBeanDefinitions,
which gets invoked on each refresh. A concrete implementation is supposed to load
bean definitions into the given
org.,
typically delegating to one or more specific bean definition readers.
Note that there is a similar base class for WebApplicationContexts.
org.
provides the same subclassing strategy, but additionally pre-implements
all context functionality for web environments. There is also a
pre-defined way to receive config locations for a web context.
Concrete standalone subclasses of this base class, reading in a
specific bean definition format, are ClassPathXmlApplicationContext
and FileSystemXmlApplicationContext, which both derive from the
common AbstractXmlApplicationContext base class;
org.
supports @Configuration-annotated classes as a source of bean definitions.
loadBeanDefinitions, org.springframework.beans.factory.support.DefaultListableBeanFactory , org.springframework.web.context.support.AbstractRefreshableWebApplicationContext , AbstractXmlApplicationContext, ClassPathXmlApplicationContext, FileSystemXmlApplicationContext, org.springframework.context.annotation.AnnotationConfigApplicationContext
| Modifier and Type | Field and Description |
|---|---|
| private Boolean | |
| private Boolean | |
| private volatile DefaultListableBeanFactory | beanFactory
Bean factory for this context. |
| Access | Constructor and Description |
|---|---|
| public | AbstractRefreshableApplicationContext()
Create a new AbstractRefreshableApplicationContext with no parent. |
| public | AbstractRefreshableApplicationContext(ApplicationContext
the parent context parent)Create a new AbstractRefreshableApplicationContext with the given parent context. |
| Modifier and Type | Method and Description |
|---|---|
| protected void | assertBeanFactoryActive()
Overrides org. getBeanFactory() serves a strong assertion for an active context anyway.
|
| protected void | cancelRefresh(Throwable
the exception that led to the cancellation ex)Overrides org. active flag
after an exception got thrown.
|
| protected final void | closeBeanFactory()
Implements abstract org. |
| protected DefaultListableBeanFactory | Returns: the bean factory for this contextCreate an internal bean factory for this context. |
| protected void | customizeBeanFactory(DefaultListableBeanFactory
the newly created bean factory for this context beanFactory)Customize the internal bean factory used by this context. |
| public final ConfigurableListableBeanFactory | getBeanFactory()
Implements abstract org. Implements org. |
| protected final boolean | hasBeanFactory()
Determine whether this context currently holds a bean factory, i.e. has been refreshed at least once and not been closed yet. |
| protected abstract void | loadBeanDefinitions(DefaultListableBeanFactory
the bean factory to load bean definitions into beanFactory)Load bean definitions into the given bean factory, typically through delegating to one or more bean definition readers. |
| protected final void | refreshBeanFactory()
Implements abstract org. |
| public void | setAllowBeanDefinitionOverriding(boolean allowBeanDefinitionOverriding)
Set whether it should be allowed to override bean definitions by registering a different definition with the same name, automatically replacing the former. |
| public void | setAllowCircularReferences(boolean allowCircularReferences)
Set whether to allow circular references between beans - and automatically try to resolve them. |
| allowBeanDefinitionOverriding | back to summary |
|---|---|
| private Boolean allowBeanDefinitionOverriding
| |
| allowCircularReferences | back to summary |
|---|---|
| private Boolean allowCircularReferences
| |
| beanFactory | back to summary |
|---|---|
| private volatile DefaultListableBeanFactory beanFactory Bean factory for this context. | |
| AbstractRefreshableApplicationContext | back to summary |
|---|---|
| public AbstractRefreshableApplicationContext() Create a new AbstractRefreshableApplicationContext with no parent. | |
| AbstractRefreshableApplicationContext | back to summary |
|---|---|
| public AbstractRefreshableApplicationContext(ApplicationContext parent) Create a new AbstractRefreshableApplicationContext with the given parent context.
| |
| assertBeanFactoryActive | back to summary |
|---|---|
| protected void assertBeanFactoryActive() Overrides org. Overridden to turn it into a no-op: With AbstractRefreshableApplicationContext,
| |
| cancelRefresh | back to summary |
|---|---|
| protected void cancelRefresh(Throwable ex) Overrides org. Doc from org. Cancel this context's refresh attempt, resetting the | |
| closeBeanFactory | back to summary |
|---|---|
| protected final void closeBeanFactory() Implements abstract org. Doc from org. Subclasses must implement this method to release their internal bean factory.
This method gets invoked by Should never throw an exception but rather log shutdown failures.
| |
| createBeanFactory | back to summary |
|---|---|
| protected DefaultListableBeanFactory createBeanFactory() Create an internal bean factory for this context.
Called for each The default implementation creates a
| |
| customizeBeanFactory | back to summary |
|---|---|
| protected void customizeBeanFactory(DefaultListableBeanFactory beanFactory) Customize the internal bean factory used by this context.
Called for each The default implementation applies this context's
"allowBeanDefinitionOverriding"
and "allowCircularReferences" settings,
if specified. Can be overridden in subclasses to customize any of
| |
| getBeanFactory | back to summary |
|---|---|
| public final ConfigurableListableBeanFactory getBeanFactory() Implements abstract org. Implements org. Doc from org. Subclasses must return their internal bean factory here. They should implement the lookup efficiently, so that it can be called repeatedly without a performance penalty. Note Subclasses should check whether the context is still active before returning the internal bean factory. The internal factory should generally be considered unavailable once the context has been closed.
| |
| hasBeanFactory | back to summary |
|---|---|
| protected final boolean hasBeanFactory() Determine whether this context currently holds a bean factory, i.e. has been refreshed at least once and not been closed yet. | |
| loadBeanDefinitions | back to summary |
|---|---|
| protected abstract void loadBeanDefinitions(DefaultListableBeanFactory beanFactory) throws BeansException, IOException Load bean definitions into the given bean factory, typically through delegating to one or more bean definition readers.
| |
| refreshBeanFactory | back to summary |
|---|---|
| protected final void refreshBeanFactory() throws BeansException Implements abstract org. This implementation performs an actual refresh of this context's underlying bean factory, shutting down the previous bean factory (if any) and initializing a fresh bean factory for the next phase of the context's lifecycle.
| |
| setAllowBeanDefinitionOverriding | back to summary |
|---|---|
| public void setAllowBeanDefinitionOverriding(boolean allowBeanDefinitionOverriding) Set whether it should be allowed to override bean definitions by registering a different definition with the same name, automatically replacing the former. If not, an exception will be thrown. Default is "true". | |
| setAllowCircularReferences | back to summary |
|---|---|
| public void setAllowCircularReferences(boolean allowCircularReferences) Set whether to allow circular references between beans - and automatically try to resolve them. Default is "true". Turn this off to throw an exception when encountering a circular reference, disallowing them completely. | |