1. In the previous section we learned about the basic steps of the IOC container setup . After understanding these steps, it is convenient to programmatically manually control the configuration and container creation process .
2. However, in spring, the system has provided a number of well-defined container implementations for the user without the need for developer hands .
3. Compared to the basic IOC containers that simply extend the beanfactory, the ApplicationContext common to developers provides the following additional services for users, in addition to being able to provide the basic functionality of the containers described earlier, which makes it easier for customers to use. So, ApplicationContext is an IOC container of advanced morphological significance .
The 4.ApplicationContext provides new features that are not available in the following beanfactory.
- support for different sources of information 。 We see applicationcontext expanded messagesource interfaces, these extension of the information source can support internationalization Implementation of the multilingual version of the app provides services.
- access resources 。 This feature is reflected in the resourceloader and resource Support so that we can from different places get . This abstraction allows the user program to define the bean definition information flexibly, especially from different I/O paths. , but in general, specific applicationcontext are inherit defaultresourceloader subclass. Because defaultresourceloader Yes abstractapplicationcontext The base class for the use of resource in the IOC container, which is explained in detail later.
- support app events 。 Inherited interface applicationeventpublisher , which in context The event mechanism is introduced. These event and bean life cycle The combination of facilitates the management of the bean.
- Additional services available in the ApplicationContext . These services make the basic IOC container more versatile. With these rich additions, the use of ApplicationContext is a framework-oriented style of use compared to a simple beanfactory, so it is generally recommended to use it when developing an application. ApplicationContext as the basic form of the IOC container .
ApplicationContext's application Scenario