public abstract class AbstractApplicationContext extends org.springframework.core.io.DefaultResourceLoader implements ConfigurableApplicationContext, org.springframework.beans.factory.DisposableBean
ApplicationContext
interface. Doesn't mandate the type of storage used for configuration; simply
implements common context functionality. Uses the Template Method design pattern,
requiring concrete subclasses to implement abstract methods.
In contrast to a plain BeanFactory, an ApplicationContext is supposed
to detect special beans defined in its internal bean factory:
Therefore, this class automatically registers
BeanFactoryPostProcessors
,
BeanPostProcessors
and ApplicationListeners
which are defined as beans in the context.
A MessageSource
may also be supplied
as a bean in the context, with the name "messageSource"; otherwise, message
resolution is delegated to the parent context. Furthermore, a multicaster
for application events can be supplied as "applicationEventMulticaster" bean
of type ApplicationEventMulticaster
in the context; otherwise, a default multicaster of type
SimpleApplicationEventMulticaster
will be used.
Implements resource loading through extending
DefaultResourceLoader
.
Consequently treats non-URL resource paths as class path resources
(supporting full class path resource names that include the package path,
e.g. "mypackage/myresource.dat"), unless the DefaultResourceLoader.getResourceByPath(java.lang.String)
method is overwritten in a subclass.
refreshBeanFactory()
,
getBeanFactory()
,
BeanFactoryPostProcessor
,
BeanPostProcessor
,
ApplicationEventMulticaster
,
ApplicationListener
,
MessageSource
Modifier and Type | Field and Description |
---|---|
static String |
APPLICATION_EVENT_MULTICASTER_BEAN_NAME
Name of the ApplicationEventMulticaster bean in the factory.
|
static String |
LIFECYCLE_PROCESSOR_BEAN_NAME
Name of the LifecycleProcessor bean in the factory.
|
protected Log |
logger
Logger used by this class.
|
static String |
MESSAGE_SOURCE_BEAN_NAME
Name of the MessageSource bean in the factory.
|
CONFIG_LOCATION_DELIMITERS, CONVERSION_SERVICE_BEAN_NAME, ENVIRONMENT_BEAN_NAME, LOAD_TIME_WEAVER_BEAN_NAME, SYSTEM_ENVIRONMENT_BEAN_NAME, SYSTEM_PROPERTIES_BEAN_NAME
Constructor and Description |
---|
AbstractApplicationContext()
Create a new AbstractApplicationContext with no parent.
|
AbstractApplicationContext(ApplicationContext parent)
Create a new AbstractApplicationContext with the given parent context.
|
Modifier and Type | Method and Description |
---|---|
void |
addApplicationListener(ApplicationListener<?> listener)
Add a new ApplicationListener that will be notified on context events
such as context refresh and context shutdown.
|
void |
addBeanFactoryPostProcessor(org.springframework.beans.factory.config.BeanFactoryPostProcessor beanFactoryPostProcessor)
Add a new BeanFactoryPostProcessor that will get applied to the internal
bean factory of this application context on refresh, before any of the
bean definitions get evaluated.
|
protected void |
assertBeanFactoryActive()
Assert that this context's BeanFactory is currently active,
throwing an
IllegalStateException if it isn't. |
protected void |
cancelRefresh(org.springframework.beans.BeansException ex)
Cancel this context's refresh attempt, resetting the
active flag
after an exception got thrown. |
void |
close()
Close this application context, destroying all beans in its bean factory.
|
protected abstract void |
closeBeanFactory()
Subclasses must implement this method to release their internal bean factory.
|
boolean |
containsBean(String name) |
boolean |
containsBeanDefinition(String beanName) |
boolean |
containsLocalBean(String name) |
protected org.springframework.core.env.ConfigurableEnvironment |
createEnvironment()
Create and return a new
StandardEnvironment . |
void |
destroy()
DisposableBean callback for destruction of this instance.
|
protected void |
destroyBeans()
Template method for destroying all beans that this context manages.
|
protected void |
doClose()
Actually performs context closing: publishes a ContextClosedEvent and
destroys the singletons in the bean factory of this application context.
|
<A extends Annotation> |
findAnnotationOnBean(String beanName,
Class<A> annotationType) |
protected void |
finishBeanFactoryInitialization(org.springframework.beans.factory.config.ConfigurableListableBeanFactory beanFactory)
Finish the initialization of this context's bean factory,
initializing all remaining singleton beans.
|
protected void |
finishRefresh()
Finish the refresh of this context, invoking the LifecycleProcessor's
onRefresh() method and publishing the
ContextRefreshedEvent . |
String[] |
getAliases(String name) |
Collection<ApplicationListener<?>> |
getApplicationListeners()
Return the list of statically specified ApplicationListeners.
|
String |
getApplicationName()
Return a name for the deployed application that this context belongs to.
|
org.springframework.beans.factory.config.AutowireCapableBeanFactory |
getAutowireCapableBeanFactory()
Return this context's internal bean factory as AutowireCapableBeanFactory,
if already available.
|
<T> T |
getBean(Class<T> requiredType) |
<T> T |
getBean(Class<T> requiredType,
Object... args) |
Object |
getBean(String name) |
<T> T |
getBean(String name,
Class<T> requiredType) |
Object |
getBean(String name,
Object... args) |
int |
getBeanDefinitionCount() |
String[] |
getBeanDefinitionNames() |
abstract org.springframework.beans.factory.config.ConfigurableListableBeanFactory |
getBeanFactory()
Subclasses must return their internal bean factory here.
|
List<org.springframework.beans.factory.config.BeanFactoryPostProcessor> |
getBeanFactoryPostProcessors()
Return the list of BeanFactoryPostProcessors that will get applied
to the internal BeanFactory.
|
String[] |
getBeanNamesForAnnotation(Class<? extends Annotation> annotationType) |
String[] |
getBeanNamesForType(Class<?> type) |
String[] |
getBeanNamesForType(Class<?> type,
boolean includeNonSingletons,
boolean allowEagerInit) |
<T> Map<String,T> |
getBeansOfType(Class<T> type) |
<T> Map<String,T> |
getBeansOfType(Class<T> type,
boolean includeNonSingletons,
boolean allowEagerInit) |
Map<String,Object> |
getBeansWithAnnotation(Class<? extends Annotation> annotationType) |
String |
getDisplayName()
Return a friendly name for this context.
|
org.springframework.core.env.ConfigurableEnvironment |
getEnvironment()
Return the Environment for this application context in configurable form.
|
String |
getId()
Return the unique id of this application context.
|
protected org.springframework.beans.factory.BeanFactory |
getInternalParentBeanFactory()
Return the internal bean factory of the parent context if it implements
ConfigurableApplicationContext; else, return the parent context itself.
|
protected MessageSource |
getInternalParentMessageSource()
Return the internal message source of the parent context if it is an
AbstractApplicationContext too; else, return the parent context itself.
|
String |
getMessage(MessageSourceResolvable resolvable,
Locale locale)
Try to resolve the message using all the attributes contained within the
MessageSourceResolvable argument that was passed in. |
String |
getMessage(String code,
Object[] args,
Locale locale)
Try to resolve the message.
|
String |
getMessage(String code,
Object[] args,
String defaultMessage,
Locale locale)
Try to resolve the message.
|
ApplicationContext |
getParent()
Return the parent context, or
null if there is no parent
(that is, this context is the root of the context hierarchy). |
org.springframework.beans.factory.BeanFactory |
getParentBeanFactory() |
protected org.springframework.core.io.support.ResourcePatternResolver |
getResourcePatternResolver()
Return the ResourcePatternResolver to use for resolving location patterns
into Resource instances.
|
org.springframework.core.io.Resource[] |
getResources(String locationPattern) |
long |
getStartupDate()
Return the timestamp (ms) when this context was first loaded.
|
Class<?> |
getType(String name) |
protected void |
initApplicationEventMulticaster()
Initialize the ApplicationEventMulticaster.
|
protected void |
initLifecycleProcessor()
Initialize the LifecycleProcessor.
|
protected void |
initMessageSource()
Initialize the MessageSource.
|
protected void |
initPropertySources()
Replace any stub property sources with actual instances.
|
protected void |
invokeBeanFactoryPostProcessors(org.springframework.beans.factory.config.ConfigurableListableBeanFactory beanFactory)
Instantiate and invoke all registered BeanFactoryPostProcessor beans,
respecting explicit order if given.
|
boolean |
isActive()
Determine whether this application context is active, that is,
whether it has been refreshed at least once and has not been closed yet.
|
boolean |
isPrototype(String name) |
boolean |
isRunning()
Check whether this component is currently running.
|
boolean |
isSingleton(String name) |
boolean |
isTypeMatch(String name,
Class<?> targetType) |
protected org.springframework.beans.factory.config.ConfigurableListableBeanFactory |
obtainFreshBeanFactory()
Tell the subclass to refresh the internal bean factory.
|
protected void |
onClose()
Template method which can be overridden to add context-specific shutdown work.
|
protected void |
onRefresh()
Template method which can be overridden to add context-specific refresh work.
|
protected void |
postProcessBeanFactory(org.springframework.beans.factory.config.ConfigurableListableBeanFactory beanFactory)
Modify the application context's internal bean factory after its standard
initialization.
|
protected void |
prepareBeanFactory(org.springframework.beans.factory.config.ConfigurableListableBeanFactory beanFactory)
Configure the factory's standard context characteristics,
such as the context's ClassLoader and post-processors.
|
protected void |
prepareRefresh()
Prepare this context for refreshing, setting its startup date and
active flag as well as performing any initialization of property sources.
|
void |
publishEvent(ApplicationEvent event)
Publish the given event to all listeners.
|
void |
refresh()
Load or refresh the persistent representation of the configuration,
which might an XML file, properties file, or relational database schema.
|
protected abstract void |
refreshBeanFactory()
Subclasses must implement this method to perform the actual configuration load.
|
protected void |
registerBeanPostProcessors(org.springframework.beans.factory.config.ConfigurableListableBeanFactory beanFactory)
Instantiate and invoke all registered BeanPostProcessor beans,
respecting explicit order if given.
|
protected void |
registerListeners()
Add beans that implement ApplicationListener as listeners.
|
void |
registerShutdownHook()
Register a shutdown hook with the JVM runtime, closing this context
on JVM shutdown unless it has already been closed at that time.
|
void |
setDisplayName(String displayName)
Set a friendly name for this context.
|
void |
setEnvironment(org.springframework.core.env.ConfigurableEnvironment environment)
Set the
Environment for this application context. |
void |
setId(String id)
Set the unique id of this application context.
|
void |
setParent(ApplicationContext parent)
Set the parent of this application context.
|
void |
start()
Start this component.
|
void |
stop()
Stop this component, typically in a synchronous fashion, such that
the component is fully stopped upon return of this method.
|
String |
toString()
Return information about this context.
|
getClassLoader, getResource, getResourceByPath, setClassLoader
public static final String MESSAGE_SOURCE_BEAN_NAME
MessageSource
,
Constant Field Valuespublic static final String LIFECYCLE_PROCESSOR_BEAN_NAME
public static final String APPLICATION_EVENT_MULTICASTER_BEAN_NAME
protected final Log logger
public AbstractApplicationContext()
public AbstractApplicationContext(ApplicationContext parent)
parent
- the parent contextpublic void setId(String id)
Default is the object id of the context instance, or the name of the context bean if the context is itself defined as a bean.
setId
in interface ConfigurableApplicationContext
id
- the unique id of the contextpublic String getId()
ApplicationContext
getId
in interface ApplicationContext
null
if nonepublic String getApplicationName()
ApplicationContext
getApplicationName
in interface ApplicationContext
public void setDisplayName(String displayName)
Default is the object id of the context instance.
public String getDisplayName()
getDisplayName
in interface ApplicationContext
null
)public ApplicationContext getParent()
null
if there is no parent
(that is, this context is the root of the context hierarchy).getParent
in interface ApplicationContext
null
if there is no parentpublic org.springframework.core.env.ConfigurableEnvironment getEnvironment()
If null
, a new environment will be initialized via
createEnvironment()
.
getEnvironment
in interface ConfigurableApplicationContext
getEnvironment
in interface org.springframework.core.env.EnvironmentCapable
public void setEnvironment(org.springframework.core.env.ConfigurableEnvironment environment)
Environment
for this application context.
Default value is determined by createEnvironment()
. Replacing the
default with this method is one option but configuration through getEnvironment()
should also be considered. In either case, such modifications
should be performed before refresh()
.
setEnvironment
in interface ConfigurableApplicationContext
environment
- the new environmentcreateEnvironment()
public org.springframework.beans.factory.config.AutowireCapableBeanFactory getAutowireCapableBeanFactory() throws IllegalStateException
getAutowireCapableBeanFactory
in interface ApplicationContext
IllegalStateException
- if the context does not support
the AutowireCapableBeanFactory interface or does not hold an autowire-capable
bean factory yet (usually if refresh()
has never been called)getBeanFactory()
public long getStartupDate()
getStartupDate
in interface ApplicationContext
public void publishEvent(ApplicationEvent event)
Note: Listeners get initialized after the MessageSource, to be able to access it within listener implementations. Thus, MessageSource implementations cannot publish events.
publishEvent
in interface ApplicationEventPublisher
event
- the event to publish (may be application-specific or a
standard framework event)org.springframework.web.context.support.RequestHandledEvent
protected org.springframework.core.io.support.ResourcePatternResolver getResourcePatternResolver()
PathMatchingResourcePatternResolver
,
supporting Ant-style location patterns.
Can be overridden in subclasses, for extended resolution strategies, for example in a web environment.
Do not call this when needing to resolve a location pattern.
Call the context's getResources
method instead, which
will delegate to the ResourcePatternResolver.
getResources(java.lang.String)
,
PathMatchingResourcePatternResolver
public void setParent(ApplicationContext parent)
Note that the parent shouldn't be changed: It should only be set outside a constructor if it isn't available when an object of this class is created, for example in case of WebApplicationContext setup.
The parent environment is
merged with
this (child) application context environment if the parent is non-null
and
its environment is an instance of ConfigurableEnvironment
.
setParent
in interface ConfigurableApplicationContext
parent
- the parent contextConfigurableEnvironment.merge(ConfigurableEnvironment)
public void addBeanFactoryPostProcessor(org.springframework.beans.factory.config.BeanFactoryPostProcessor beanFactoryPostProcessor)
ConfigurableApplicationContext
addBeanFactoryPostProcessor
in interface ConfigurableApplicationContext
beanFactoryPostProcessor
- the factory processor to registerpublic List<org.springframework.beans.factory.config.BeanFactoryPostProcessor> getBeanFactoryPostProcessors()
public void addApplicationListener(ApplicationListener<?> listener)
ConfigurableApplicationContext
Note that any ApplicationListener registered here will be applied on refresh if the context is not active yet, or on the fly with the current event multicaster in case of a context that is already active.
addApplicationListener
in interface ConfigurableApplicationContext
listener
- the ApplicationListener to registerContextRefreshedEvent
,
ContextClosedEvent
public Collection<ApplicationListener<?>> getApplicationListeners()
protected org.springframework.core.env.ConfigurableEnvironment createEnvironment()
StandardEnvironment
.
Subclasses may override this method in order to supply
a custom ConfigurableEnvironment
implementation.
public void refresh() throws org.springframework.beans.BeansException, IllegalStateException
ConfigurableApplicationContext
As this is a startup method, it should destroy already created singletons if it fails, to avoid dangling resources. In other words, after invocation of that method, either all or no singletons at all should be instantiated.
refresh
in interface ConfigurableApplicationContext
org.springframework.beans.BeansException
- if the bean factory could not be initializedIllegalStateException
- if already initialized and multiple refresh
attempts are not supportedprotected void prepareRefresh()
protected void initPropertySources()
Replace any stub property sources with actual instances.
PropertySource.StubPropertySource
,
org.springframework.web.context.support.WebApplicationContextUtils#initServletPropertySources
protected org.springframework.beans.factory.config.ConfigurableListableBeanFactory obtainFreshBeanFactory()
refreshBeanFactory()
,
getBeanFactory()
protected void prepareBeanFactory(org.springframework.beans.factory.config.ConfigurableListableBeanFactory beanFactory)
beanFactory
- the BeanFactory to configureprotected void postProcessBeanFactory(org.springframework.beans.factory.config.ConfigurableListableBeanFactory beanFactory)
beanFactory
- the bean factory used by the application contextprotected void invokeBeanFactoryPostProcessors(org.springframework.beans.factory.config.ConfigurableListableBeanFactory beanFactory)
Must be called before singleton instantiation.
protected void registerBeanPostProcessors(org.springframework.beans.factory.config.ConfigurableListableBeanFactory beanFactory)
Must be called before any instantiation of application beans.
protected void initMessageSource()
protected void initApplicationEventMulticaster()
SimpleApplicationEventMulticaster
protected void initLifecycleProcessor()
DefaultLifecycleProcessor
protected void onRefresh() throws org.springframework.beans.BeansException
This implementation is empty.
org.springframework.beans.BeansException
- in case of errorsrefresh()
protected void registerListeners()
protected void finishBeanFactoryInitialization(org.springframework.beans.factory.config.ConfigurableListableBeanFactory beanFactory)
protected void finishRefresh()
ContextRefreshedEvent
.protected void cancelRefresh(org.springframework.beans.BeansException ex)
active
flag
after an exception got thrown.ex
- the exception that led to the cancellationpublic void registerShutdownHook()
Delegates to doClose()
for the actual closing procedure.
registerShutdownHook
in interface ConfigurableApplicationContext
Runtime.addShutdownHook(java.lang.Thread)
,
close()
,
doClose()
public void destroy()
The close
method is the native way to
shut down an ApplicationContext.
destroy
in interface org.springframework.beans.factory.DisposableBean
close()
,
SingletonBeanFactoryLocator
public void close()
Delegates to doClose()
for the actual closing procedure.
Also removes a JVM shutdown hook, if registered, as it's not needed anymore.
close
in interface Closeable
close
in interface AutoCloseable
close
in interface ConfigurableApplicationContext
doClose()
,
registerShutdownHook()
protected void doClose()
Called by both close()
and a JVM shutdown hook, if any.
ContextClosedEvent
,
destroyBeans()
,
close()
,
registerShutdownHook()
protected void destroyBeans()
DisposableBean.destroy()
and/or the specified
"destroy-method".
Can be overridden to add context-specific bean destruction steps right before or right after standard singleton destruction, while the context's BeanFactory is still active.
getBeanFactory()
,
ConfigurableBeanFactory.destroySingletons()
protected void onClose()
Called at the end of doClose()
's shutdown procedure, after
this context's BeanFactory has been closed. If custom shutdown logic
needs to execute while the BeanFactory is still active, override
the destroyBeans()
method instead.
public boolean isActive()
ConfigurableApplicationContext
isActive
in interface ConfigurableApplicationContext
ConfigurableApplicationContext.refresh()
,
ConfigurableApplicationContext.close()
,
ConfigurableApplicationContext.getBeanFactory()
protected void assertBeanFactoryActive()
IllegalStateException
if it isn't.
Invoked by all BeanFactory
delegation methods that depend
on an active context, i.e. in particular all bean accessor methods.
The default implementation checks the 'active'
status
of this context overall. May be overridden for more specific checks, or for a
no-op if getBeanFactory()
itself throws an exception in such a case.
public Object getBean(String name) throws org.springframework.beans.BeansException
getBean
in interface org.springframework.beans.factory.BeanFactory
org.springframework.beans.BeansException
public <T> T getBean(String name, Class<T> requiredType) throws org.springframework.beans.BeansException
getBean
in interface org.springframework.beans.factory.BeanFactory
org.springframework.beans.BeansException
public <T> T getBean(Class<T> requiredType) throws org.springframework.beans.BeansException
getBean
in interface org.springframework.beans.factory.BeanFactory
org.springframework.beans.BeansException
public Object getBean(String name, Object... args) throws org.springframework.beans.BeansException
getBean
in interface org.springframework.beans.factory.BeanFactory
org.springframework.beans.BeansException
public <T> T getBean(Class<T> requiredType, Object... args) throws org.springframework.beans.BeansException
getBean
in interface org.springframework.beans.factory.BeanFactory
org.springframework.beans.BeansException
public boolean containsBean(String name)
containsBean
in interface org.springframework.beans.factory.BeanFactory
public boolean isSingleton(String name) throws org.springframework.beans.factory.NoSuchBeanDefinitionException
isSingleton
in interface org.springframework.beans.factory.BeanFactory
org.springframework.beans.factory.NoSuchBeanDefinitionException
public boolean isPrototype(String name) throws org.springframework.beans.factory.NoSuchBeanDefinitionException
isPrototype
in interface org.springframework.beans.factory.BeanFactory
org.springframework.beans.factory.NoSuchBeanDefinitionException
public boolean isTypeMatch(String name, Class<?> targetType) throws org.springframework.beans.factory.NoSuchBeanDefinitionException
isTypeMatch
in interface org.springframework.beans.factory.BeanFactory
org.springframework.beans.factory.NoSuchBeanDefinitionException
public Class<?> getType(String name) throws org.springframework.beans.factory.NoSuchBeanDefinitionException
getType
in interface org.springframework.beans.factory.BeanFactory
org.springframework.beans.factory.NoSuchBeanDefinitionException
public String[] getAliases(String name)
getAliases
in interface org.springframework.beans.factory.BeanFactory
public boolean containsBeanDefinition(String beanName)
containsBeanDefinition
in interface org.springframework.beans.factory.ListableBeanFactory
public int getBeanDefinitionCount()
getBeanDefinitionCount
in interface org.springframework.beans.factory.ListableBeanFactory
public String[] getBeanDefinitionNames()
getBeanDefinitionNames
in interface org.springframework.beans.factory.ListableBeanFactory
public String[] getBeanNamesForType(Class<?> type)
getBeanNamesForType
in interface org.springframework.beans.factory.ListableBeanFactory
public String[] getBeanNamesForType(Class<?> type, boolean includeNonSingletons, boolean allowEagerInit)
getBeanNamesForType
in interface org.springframework.beans.factory.ListableBeanFactory
public <T> Map<String,T> getBeansOfType(Class<T> type) throws org.springframework.beans.BeansException
getBeansOfType
in interface org.springframework.beans.factory.ListableBeanFactory
org.springframework.beans.BeansException
public <T> Map<String,T> getBeansOfType(Class<T> type, boolean includeNonSingletons, boolean allowEagerInit) throws org.springframework.beans.BeansException
getBeansOfType
in interface org.springframework.beans.factory.ListableBeanFactory
org.springframework.beans.BeansException
public String[] getBeanNamesForAnnotation(Class<? extends Annotation> annotationType)
getBeanNamesForAnnotation
in interface org.springframework.beans.factory.ListableBeanFactory
public Map<String,Object> getBeansWithAnnotation(Class<? extends Annotation> annotationType) throws org.springframework.beans.BeansException
getBeansWithAnnotation
in interface org.springframework.beans.factory.ListableBeanFactory
org.springframework.beans.BeansException
public <A extends Annotation> A findAnnotationOnBean(String beanName, Class<A> annotationType) throws org.springframework.beans.factory.NoSuchBeanDefinitionException
findAnnotationOnBean
in interface org.springframework.beans.factory.ListableBeanFactory
org.springframework.beans.factory.NoSuchBeanDefinitionException
public org.springframework.beans.factory.BeanFactory getParentBeanFactory()
getParentBeanFactory
in interface org.springframework.beans.factory.HierarchicalBeanFactory
public boolean containsLocalBean(String name)
containsLocalBean
in interface org.springframework.beans.factory.HierarchicalBeanFactory
protected org.springframework.beans.factory.BeanFactory getInternalParentBeanFactory()
public String getMessage(String code, Object[] args, String defaultMessage, Locale locale)
MessageSource
getMessage
in interface MessageSource
code
- the code to lookup up, such as 'calculator.noRateSet'. Users of
this class are encouraged to base message names on the relevant fully
qualified class name, thus avoiding conflict and ensuring maximum clarity.args
- array of arguments that will be filled in for params within
the message (params look like "{0}", "{1,date}", "{2,time}" within a message),
or null
if none.defaultMessage
- String to return if the lookup failslocale
- the Locale in which to do the lookupMessageFormat
public String getMessage(String code, Object[] args, Locale locale) throws NoSuchMessageException
MessageSource
getMessage
in interface MessageSource
code
- the code to lookup up, such as 'calculator.noRateSet'args
- Array of arguments that will be filled in for params within
the message (params look like "{0}", "{1,date}", "{2,time}" within a message),
or null
if none.locale
- the Locale in which to do the lookupNoSuchMessageException
- if the message wasn't foundMessageFormat
public String getMessage(MessageSourceResolvable resolvable, Locale locale) throws NoSuchMessageException
MessageSource
MessageSourceResolvable
argument that was passed in.
NOTE: We must throw a NoSuchMessageException
on this method
since at the time of calling this method we aren't able to determine if the
defaultMessage
property of the resolvable is null or not.
getMessage
in interface MessageSource
resolvable
- value object storing attributes required to properly resolve a messagelocale
- the Locale in which to do the lookupNoSuchMessageException
- if the message wasn't foundMessageFormat
protected MessageSource getInternalParentMessageSource()
public org.springframework.core.io.Resource[] getResources(String locationPattern) throws IOException
getResources
in interface org.springframework.core.io.support.ResourcePatternResolver
IOException
public void start()
Lifecycle
In the case of a container, this will propagate the start signal to all components that apply.
public void stop()
Lifecycle
SmartLifecycle
and its stop(Runnable)
variant in cases where asynchronous stop behavior is necessary.
Should not throw an exception if the component isn't started yet.
In the case of a container, this will propagate the stop signal to all components that apply.
stop
in interface Lifecycle
SmartLifecycle.stop(Runnable)
public boolean isRunning()
Lifecycle
In the case of a container, this will return true
only if all components that apply are currently running.
protected abstract void refreshBeanFactory() throws org.springframework.beans.BeansException, IllegalStateException
refresh()
before any other initialization work.
A subclass will either create a new bean factory and hold a reference to it, or return a single BeanFactory instance that it holds. In the latter case, it will usually throw an IllegalStateException if refreshing the context more than once.
org.springframework.beans.BeansException
- if initialization of the bean factory failedIllegalStateException
- if already initialized and multiple refresh
attempts are not supportedprotected abstract void closeBeanFactory()
close()
after all other shutdown work.
Should never throw an exception but rather log shutdown failures.
public abstract org.springframework.beans.factory.config.ConfigurableListableBeanFactory getBeanFactory() throws IllegalStateException
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.
getBeanFactory
in interface ConfigurableApplicationContext
null
)IllegalStateException
- if the context does not hold an internal bean factory yet
(usually if refresh()
has never been called) or if the context has been
closed alreadyrefreshBeanFactory()
,
closeBeanFactory()