|
The Spring Framework | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.springframework.core.io.DefaultResourceLoader org.springframework.context.support.AbstractApplicationContext
public abstract class AbstractApplicationContext
Abstract implementation of the 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"; else, 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; else, 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
Field Summary | |
---|---|
static String |
APPLICATION_EVENT_MULTICASTER_BEAN_NAME
Name of the ApplicationEventMulticaster 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. |
Fields inherited from interface org.springframework.beans.factory.BeanFactory |
---|
FACTORY_BEAN_PREFIX |
Fields inherited from interface org.springframework.beans.factory.BeanFactory |
---|
FACTORY_BEAN_PREFIX |
Fields inherited from interface org.springframework.core.io.support.ResourcePatternResolver |
---|
CLASSPATH_ALL_URL_PREFIX |
Fields inherited from interface org.springframework.core.io.ResourceLoader |
---|
CLASSPATH_URL_PREFIX |
Constructor Summary | |
---|---|
AbstractApplicationContext()
Create a new AbstractApplicationContext with no parent. |
|
AbstractApplicationContext(ApplicationContext parent)
Create a new AbstractApplicationContext with the given parent context. |
Method Summary | |
---|---|
void |
addBeanFactoryPostProcessor(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 |
addListener(ApplicationListener listener)
Subclasses can invoke this method to register a listener. |
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)
Does this bean factory contain a bean with the given name? |
boolean |
containsBeanDefinition(String name)
Check if this bean factory contains a bean definition with the given name. |
boolean |
containsLocalBean(String name)
Return whether the local bean factory contains a bean of the given name, ignoring beans defined in ancestor contexts. |
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. |
String[] |
getAliases(String name)
Return the aliases for the given bean name, if defined. |
AutowireCapableBeanFactory |
getAutowireCapableBeanFactory()
Return this context's internal bean factory as AutowireCapableBeanFactory, if already available. |
Object |
getBean(String name)
Return an instance, which may be shared or independent, of the specified bean. |
Object |
getBean(String name,
Class requiredType)
Return an instance, which may be shared or independent, of the specified bean. |
int |
getBeanDefinitionCount()
Return the number of beans defined in the factory. |
String[] |
getBeanDefinitionNames()
Return the names of all beans defined in this factory. |
abstract ConfigurableListableBeanFactory |
getBeanFactory()
Subclasses must return their internal bean factory here. |
List |
getBeanFactoryPostProcessors()
Return the list of BeanFactoryPostProcessors that will get applied to the internal BeanFactory. |
String[] |
getBeanNamesForType(Class type)
Return the names of beans matching the given type (including subclasses), judging from either bean definitions or the value of getObjectType
in the case of FactoryBeans. |
String[] |
getBeanNamesForType(Class type,
boolean includePrototypes,
boolean allowEagerInit)
Return the names of beans matching the given type (including subclasses), judging from either bean definitions or the value of getObjectType
in the case of FactoryBeans. |
Map |
getBeansOfType(Class type)
Return the bean instances that match the given object type (including subclasses), judging from either bean definitions or the value of getObjectType in the case of FactoryBeans. |
Map |
getBeansOfType(Class type,
boolean includePrototypes,
boolean allowEagerInit)
Return the bean instances that match the given object type (including subclasses), judging from either bean definitions or the value of getObjectType in the case of FactoryBeans. |
String |
getDisplayName()
Return a friendly name for this context. |
protected 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. |
protected Collection |
getLifecycleBeans()
Return a Collection of all singleton beans that implement the Lifecycle interface in this context. |
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). |
BeanFactory |
getParentBeanFactory()
Return the parent bean factory, or null if there is none. |
protected ResourcePatternResolver |
getResourcePatternResolver()
Return the ResourcePatternResolver to use for resolving location patterns into Resource instances. |
Resource[] |
getResources(String locationPattern)
Resolve the given location pattern into Resource objects. |
long |
getStartupDate()
Return the timestamp (ms) when this context was first loaded. |
Class |
getType(String name)
Determine the type of the bean with the given name. |
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)
Is this bean a prototype? |
boolean |
isRunning()
Check whether this component is currently running. |
boolean |
isSingleton(String name)
Is this bean a shared singleton? |
boolean |
isTypeMatch(String name,
Class targetType)
Check whether the bean with the given name matches the specified type. |
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(ConfigurableListableBeanFactory beanFactory)
Modify the application context's internal bean factory after its standard initialization. |
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. |
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 |
setParent(ApplicationContext parent)
Set the parent of this application context. |
void |
start()
Start this component. |
void |
stop()
Stop this component. |
String |
toString()
Return information about this context. |
Methods inherited from class org.springframework.core.io.DefaultResourceLoader |
---|
getClassLoader, getResource, getResourceByPath, setClassLoader |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Methods inherited from interface org.springframework.core.io.ResourceLoader |
---|
getClassLoader, getResource |
Field Detail |
---|
public static final String MESSAGE_SOURCE_BEAN_NAME
MessageSource
,
Constant Field Valuespublic static final String APPLICATION_EVENT_MULTICASTER_BEAN_NAME
ApplicationEventMulticaster
,
SimpleApplicationEventMulticaster
,
Constant Field Valuesprotected final Log logger
Constructor Detail |
---|
public AbstractApplicationContext()
public AbstractApplicationContext(ApplicationContext parent)
parent
- the parent contextMethod Detail |
---|
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 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 void setDisplayName(String displayName)
public String getDisplayName()
getDisplayName
in interface ApplicationContext
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)RequestHandledEvent
public void setParent(ApplicationContext parent)
ConfigurableApplicationContext
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.
setParent
in interface ConfigurableApplicationContext
parent
- the parent contextConfigurableWebApplicationContext
public void addBeanFactoryPostProcessor(BeanFactoryPostProcessor beanFactoryPostProcessor)
ConfigurableApplicationContext
addBeanFactoryPostProcessor
in interface ConfigurableApplicationContext
beanFactoryPostProcessor
- the factory processor to registerpublic List getBeanFactoryPostProcessors()
BeanFactoryPostProcessor
public void refresh() throws 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
BeansException
- if the bean factory could not be initialized
IllegalStateException
- if already initialized and multiple refresh
attempts are not supportedprotected 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
protected void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException
beanFactory
- the bean factory used by the application context
BeansException
- in case of errorsprotected void onRefresh() throws BeansException
BeansException
- in case of errors during refreshrefresh()
protected void addListener(ApplicationListener listener)
listener
- the listener to registerpublic 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 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 ConfigurableApplicationContext
doClose()
,
registerShutdownHook()
protected void doClose()
Called by both close()
and a JVM shutdown hook, if any.
ContextClosedEvent
,
ConfigurableBeanFactory.destroySingletons()
,
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()
public Object getBean(String name) throws BeansException
BeanFactory
This method allows a Spring BeanFactory to be used as a replacement for the Singleton or Prototype design pattern. Callers may retain references to returned objects in the case of Singleton beans.
Translates aliases back to the corresponding canonical bean name. Will ask the parent factory if the bean cannot be found in this factory instance.
getBean
in interface BeanFactory
name
- the name of the bean to retrieve
NoSuchBeanDefinitionException
- if there is no bean definition
with the specified name
BeansException
- if the bean could not be obtainedpublic Object getBean(String name, Class requiredType) throws BeansException
BeanFactory
Behaves the same as BeanFactory.getBean(String)
, but provides a measure of type
safety by throwing a BeanNotOfRequiredTypeException if the bean is not of the
required type. This means that ClassCastException can't be thrown on casting
the result correctly, as can happen with BeanFactory.getBean(String)
.
Translates aliases back to the corresponding canonical bean name. Will ask the parent factory if the bean cannot be found in this factory instance.
getBean
in interface BeanFactory
name
- the name of the bean to retrieverequiredType
- type the bean must match. Can be an interface or superclass
of the actual class, or null
for any match. For example, if the value
is Object.class
, this method will succeed whatever the class of the
returned instance.
BeanNotOfRequiredTypeException
- if the bean is not of the required type
NoSuchBeanDefinitionException
- if there's no such bean definition
BeansException
- if the bean could not be createdpublic boolean containsBean(String name)
BeanFactory
Will ask the parent factory if the bean cannot be found in this factory instance.
containsBean
in interface BeanFactory
name
- the name of the bean to query
public boolean isSingleton(String name) throws NoSuchBeanDefinitionException
BeanFactory
BeanFactory.getBean(java.lang.String)
always
return the same instance?
Note: This method returning false
does not clearly indicate
independent instances. It indicates non-singleton instances, which may correspond
to a scoped bean as well. Use the BeanFactory.isPrototype(java.lang.String)
operation to explicitly
check for independent instances.
Will ask the parent factory if the bean cannot be found in this factory instance.
isSingleton
in interface BeanFactory
name
- the name of the bean to query
NoSuchBeanDefinitionException
- if there is no bean with the given nameBeanFactory.getBean(java.lang.String)
,
BeanFactory.isPrototype(java.lang.String)
public boolean isPrototype(String name) throws NoSuchBeanDefinitionException
BeanFactory
BeanFactory.getBean(java.lang.String)
always return
independent instances?
Note: This method returning false
does not clearly indicate
a singleton object. It indicates non-independent instances, which may correspond
to a scoped bean as well. Use the BeanFactory.isSingleton(java.lang.String)
operation to explicitly
check for a shared singleton instance.
Will ask the parent factory if the bean cannot be found in this factory instance.
isPrototype
in interface BeanFactory
name
- the name of the bean to query
NoSuchBeanDefinitionException
- if there is no bean with the given nameBeanFactory.getBean(java.lang.String)
,
BeanFactory.isSingleton(java.lang.String)
public boolean isTypeMatch(String name, Class targetType) throws NoSuchBeanDefinitionException
BeanFactory
isTypeMatch
in interface BeanFactory
name
- the name of the bean to querytargetType
- the type to match against
true
if the bean type matches,
false
if it doesn't match or cannot be determined yet
NoSuchBeanDefinitionException
- if there is no bean with the given nameBeanFactory.getBean(java.lang.String)
,
BeanFactory.getType(java.lang.String)
public Class getType(String name) throws NoSuchBeanDefinitionException
BeanFactory
BeanFactory.getBean(java.lang.String)
would return.
For a FactoryBean, return the type of object that the FactoryBean creates.
getType
in interface BeanFactory
name
- the name of the bean to query
null
if not determinable
NoSuchBeanDefinitionException
- if there is no bean with the given nameBeanFactory.getBean(java.lang.String)
,
FactoryBean.getObjectType()
public String[] getAliases(String name)
BeanFactory
If the given name is an alias, the corresponding original bean name and other aliases (if any) will be returned, with the original bean name being the first element in the array.
Will ask the parent factory if the bean cannot be found in this factory instance.
getAliases
in interface BeanFactory
name
- the bean name to check for aliases
public boolean containsBeanDefinition(String name)
ListableBeanFactory
Does not consider any hierarchy this factory may participate in, and ignores any singleton beans that have been registered by other means than bean definitions.
containsBeanDefinition
in interface ListableBeanFactory
name
- the name of the bean to look for
BeanFactory.containsBean(java.lang.String)
public int getBeanDefinitionCount()
ListableBeanFactory
Does not consider any hierarchy this factory may participate in, and ignores any singleton beans that have been registered by other means than bean definitions.
getBeanDefinitionCount
in interface ListableBeanFactory
public String[] getBeanDefinitionNames()
ListableBeanFactory
Does not consider any hierarchy this factory may participate in, and ignores any singleton beans that have been registered by other means than bean definitions.
getBeanDefinitionNames
in interface ListableBeanFactory
public String[] getBeanNamesForType(Class type)
ListableBeanFactory
getObjectType
in the case of FactoryBeans.
Does consider objects created by FactoryBeans, which means that FactoryBeans will get initialized. If the object created by the FactoryBean doesn't match, the raw FactoryBean itself will be matched against the type.
Does not consider any hierarchy this factory may participate in.
Use BeanFactoryUtils' beanNamesForTypeIncludingAncestors
to include beans in ancestor factories too.
Note: Does not ignore singleton beans that have been registered by other means than bean definitions.
This version of getBeanNamesForType matches all kinds of beans, be it
singletons, prototypes, or FactoryBeans. In most implementations, the
result will be the same as for getBeanNamesOfType(type, true, true)
.
Bean names returned by this method should always return bean names in the order of definition in the backend configuration, as far as possible.
getBeanNamesForType
in interface ListableBeanFactory
type
- the class or interface to match, or null
for all bean names
FactoryBean.getObjectType()
,
BeanFactoryUtils.beanNamesForTypeIncludingAncestors(ListableBeanFactory, Class)
public String[] getBeanNamesForType(Class type, boolean includePrototypes, boolean allowEagerInit)
ListableBeanFactory
getObjectType
in the case of FactoryBeans.
Does consider objects created by FactoryBeans if the "allowEagerInit" flag is set, which means that FactoryBeans will get initialized. If the object created by the FactoryBean doesn't match, the raw FactoryBean itself will be matched against the type. If "allowEagerInit" is not set, only raw FactoryBeans will be checked (which doesn't require initialization of each FactoryBean). $ *
Does not consider any hierarchy this factory may participate in.
Use BeanFactoryUtils' beanNamesForTypeIncludingAncestors
to include beans in ancestor factories too.
Note: Does not ignore singleton beans that have been registered by other means than bean definitions.
Bean names returned by this method should always return bean names in the order of definition in the backend configuration, as far as possible.
getBeanNamesForType
in interface ListableBeanFactory
type
- the class or interface to match, or null
for all bean namesincludePrototypes
- whether to include prototype beans too
or just singletons (also applies to FactoryBeans)allowEagerInit
- whether to initialize lazy-init singletons and
objects created by FactoryBeans (or by factory methods with a
"factory-bean" reference) for the type check. Note that FactoryBeans need to be
eagerly initialized to determine their type: So be aware that passing in "true"
for this flag will initialize FactoryBeans and "factory-bean" references.
FactoryBean.getObjectType()
,
BeanFactoryUtils.beanNamesForTypeIncludingAncestors(ListableBeanFactory, Class, boolean, boolean)
public Map getBeansOfType(Class type) throws BeansException
ListableBeanFactory
getObjectType
in the case of FactoryBeans.
Does consider objects created by FactoryBeans, which means that FactoryBeans will get initialized. If the object created by the FactoryBean doesn't match, the raw FactoryBean itself will be matched against the type.
Does not consider any hierarchy this factory may participate in.
Use BeanFactoryUtils' beansOfTypeIncludingAncestors
to include beans in ancestor factories too.
Note: Does not ignore singleton beans that have been registered by other means than bean definitions.
This version of getBeansOfType matches all kinds of beans, be it
singletons, prototypes, or FactoryBeans. In most implementations, the
result will be the same as for getBeansOfType(type, true, true)
.
The Map returned by this method should always return bean names and corresponding bean instances in the order of definition in the backend configuration, as far as possible. This will usually mean that either JDK 1.4 or Commons Collections needs to be available.
getBeansOfType
in interface ListableBeanFactory
type
- the class or interface to match, or null
for all concrete beans
BeansException
- if a bean could not be createdFactoryBean.getObjectType()
,
BeanFactoryUtils.beansOfTypeIncludingAncestors(ListableBeanFactory, Class)
public Map getBeansOfType(Class type, boolean includePrototypes, boolean allowEagerInit) throws BeansException
ListableBeanFactory
getObjectType
in the case of FactoryBeans.
Does consider objects created by FactoryBeans if the "allowEagerInit" flag is set, which means that FactoryBeans will get initialized. If the object created by the FactoryBean doesn't match, the raw FactoryBean itself will be matched against the type. If "allowEagerInit" is not set, only raw FactoryBeans will be checked (which doesn't require initialization of each FactoryBean).
Does not consider any hierarchy this factory may participate in.
Use BeanFactoryUtils' beansOfTypeIncludingAncestors
to include beans in ancestor factories too.
Note: Does not ignore singleton beans that have been registered by other means than bean definitions.
The Map returned by this method should always return bean names and corresponding bean instances in the order of definition in the backend configuration, as far as possible. This will usually mean that either JDK 1.4 or Commons Collections needs to be available.
getBeansOfType
in interface ListableBeanFactory
type
- the class or interface to match, or null
for all concrete beansincludePrototypes
- whether to include prototype beans too
or just singletons (also applies to FactoryBeans)allowEagerInit
- whether to initialize lazy-init singletons and
objects created by FactoryBeans (or by factory methods with a
"factory-bean" reference) for the type check. Note that FactoryBeans need to be
eagerly initialized to determine their type: So be aware that passing in "true"
for this flag will initialize FactoryBeans and "factory-bean" references.
BeansException
- if a bean could not be createdFactoryBean.getObjectType()
,
BeanFactoryUtils.beansOfTypeIncludingAncestors(ListableBeanFactory, Class, boolean, boolean)
public BeanFactory getParentBeanFactory()
HierarchicalBeanFactory
null
if there is none.
getParentBeanFactory
in interface HierarchicalBeanFactory
public boolean containsLocalBean(String name)
HierarchicalBeanFactory
This is an alternative to containsBean
, ignoring a bean
of the given name from an ancestor bean factory.
containsLocalBean
in interface HierarchicalBeanFactory
name
- the name of the bean to query
BeanFactory.containsBean(java.lang.String)
protected BeanFactory getInternalParentBeanFactory()
ConfigurableApplicationContext.getBeanFactory()
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 lookup
MessageFormat
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 lookup
NoSuchMessageException
- 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 lookup
NoSuchMessageException
- if the message wasn't foundMessageFormat
protected MessageSource getInternalParentMessageSource()
public Resource[] getResources(String locationPattern) throws IOException
ResourcePatternResolver
Overlapping resource entries that point to the same physical resource should be avoided, as far as possible. The result should have set semantics.
getResources
in interface ResourcePatternResolver
locationPattern
- the location pattern to resolve
IOException
- in case of I/O errorspublic void start()
Lifecycle
In the case of a container, this will propagate the start signal to all components that apply.
start
in interface Lifecycle
public void stop()
Lifecycle
In the case of a container, this will propagate the stop signal to all components that apply.
stop
in interface Lifecycle
public boolean isRunning()
Lifecycle
In the case of a container, this will return true
only if all components that apply are currently running.
isRunning
in interface Lifecycle
protected Collection getLifecycleBeans()
protected abstract void refreshBeanFactory() throws 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.
BeansException
- if initialization of the bean factory failed
IllegalStateException
- 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 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()
public String toString()
toString
in class Object
|
The Spring Framework | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |