The difference between spring's beanfactory and ApplicationContext

Source: Internet
Author: User

Beanfacotry is the more primitive factory in spring. such as Xmlbeanfactory is a typical beanfactory. The original beanfactory cannot support many of spring's plugins, such as AOP features, Web applications, and so on.
The ApplicationContext interface, which is derived from the Beanfactory interface, provides all beanfactory functionality. ApplicationContext works in a more framework-oriented manner and hierarchies and implements inheritance for contexts, the ApplicationContext package also provides the following features:
Messagesource, providing international message access
• Resource access, such as URLs and files (Uniform resource file read mode)

• Event propagation with powerful event mechanism
• Load Multiple (inherited relationships) contexts so that each context is focused on a specific level, such as the Web tier of the application

Beanfactroy uses lazy loading as a way to inject beans, that is, only when a bean is used (called Getbean ()), the bean is loaded instantiated, so that we cannot discover some of the existing spring configuration problems. ApplicationContext, on the other hand, creates all the beans at once when the container is started. This way, when the container starts, we can discover the configuration errors that exist in spring. The only disadvantage relative to the basic beanfactory,applicationcontext is the memory footprint. When the application configuration bean is large, the program starts slowly.

Beanfactory and ApplicationContext both support the use of beanpostprocessor, beanfactorypostprocessor, but the difference between the two is: Beanfactory need to register manually, The ApplicationContext is automatically registered. (ApplicationContext has added some better-used features than beanfactory.) And many functions of beanfactory need to be implemented programmatically and ApplicationContext can be implemented by configuration. such as post-processing beans, ApplicationContext directly configured in the configuration file can be beanfactory this to be displayed in the code to be written out to be recognized by the container. )

The difference between spring's beanfactory and ApplicationContext

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.