Beanfactory and ApplicationContext (Bean Factory and application context)

Source: Internet
Author: User

The Bean Factory (Beanfactory interface) provides the underlying dependency injection support.

The application context (ApplicationContext interface), built on the bean Factory basis, provides system architecture services.

The ApplicationContext offers more features:

1. Provide text information parsing tools, including support for internationalization (i18n).

2. Provides a common method for loading file resources, such as loading pictures.

3. You can send an event to a bean registered as a listener.

ApplicationContext and Beanfacotry provide more extended functionality, but the main difference is that the latter is deferred loading,
If one of the bean's properties is not injected, the beanfacotry is loaded until the first use of the call Getbean method throws an exception;
ApplicationContext in the initialization itself is a test, so it is helpful to check whether the dependency property is injected;
So we usually choose to use ApplicationContext.

Beanfactory the Basic Factory
Parse, manage, instantiate the interface of all the beans within the container, and all the classes in spring that parse the configuration file implement the interface directly or indirectly
ApplicationContext interface Implements Beanfactory
Features for creating objects:
Beanfactory does not initialize the object when parsing the configuration file, and the object is initialized only when the object is used (Getbean ()).
ApplicationContext initializes all objects in the configuration file when the configuration file is parsed, and the Getbean () method is just the process of getting the object



Beanfactory and ApplicationContext (Bean Factory and application context)

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.