Application contexts provide a means for resolving text messages?
One of the main advatage stated for Application Context is below :-
Application contexts provide a means for resolving text messages
Could somebody explain with brief example what does that mean?
Second is there any overhead of开发者_开发知识库 using Application contexts over BeanFactory as i have seen most of the application using BeanFactory?
Here is the declaration of ApplicationContext
:
public interface ApplicationContext extends
ListableBeanFactory,
HierarchicalBeanFactory,
MessageSource,
ApplicationEventPublisher,
ResourcePatternResolver {
One of the interfaces it extends is MessageSource
:
Strategy interface for resolving messages, with support for the parameterization and internationalization of such messages.
From MessageSource Javadoc. This means you can use application context as a message source for your application with I18N support. Spring has a small framework for resolving messages, pattern replacement, etc.
With regards to your seconds question: you should always use the smallest possible interface you need. When you are injecting BeanFactory
, it is probably an ApplicationContext
, but there is no need to couple your class with such a huge abstraction. Just pick what you are going to use.
精彩评论