Base class for ApplicationContext
implementations which are supposed to support multiple calls to AbstractApplicationContext.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.
Note that there is a similar base class for WebApplicationContexts.AbstractRefreshableWebApplicationContext
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.
Overridden to turn it into a no-op: With AbstractRefreshableApplicationContext,
getBeanFactory() serves a strong assertion for an active context anyway.
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.
Set whether it should be allowed to override bean definitions by registering
a different definition with the same name, automatically replacing the former.
Create a new AbstractRefreshableApplicationContext with the given parent context.
Parameters:
parent - the parent context
Method Detail
setAllowBeanDefinitionOverriding
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".
protected final void refreshBeanFactory()
throws BeansException
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.
Subclasses must implement this method to release their internal bean factory.
This method gets invoked by AbstractApplicationContext.close() after all other shutdown work.
Should never throw an exception but rather log shutdown failures.
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.
Overridden to turn it into a no-op: With AbstractRefreshableApplicationContext,
getBeanFactory() serves a strong assertion for an active context anyway.
The default implementation creates a
DefaultListableBeanFactory
with the internal bean factory of this
context's parent as parent bean factory. Can be overridden in subclasses,
for example to customize DefaultListableBeanFactory's settings.