Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

The usage of ApplicationContext Interface in Spring Framework

Shulou Source: shulou.com Published: 2022-06-02 04:14:41 10月02日 Update

This article mainly introduces "the usage of ApplicationContext interface in Spring framework". In daily operation, I believe many people have doubts about the usage of ApplicationContext interface in Spring framework. Xiaobian consulted all kinds of materials and sorted out simple and easy to use operation methods. I hope to help you answer the doubts about "the usage of ApplicationContext interface in Spring framework"! Next, please follow the small series to learn together!

We know that the BeanFactory interface is for Spring frameworks, and the ApplicationContext interface is for us developers. So the ApplicationContext interface provides a lot of functionality that we need in our day-to-day development. Let's take a look at what the ApplicationContext interface mainly includes.

ApplicationEventPublisher

Gives IOC containers the ability to publish application context events. You can mainly listen to container startup events, shutdown events, etc.

MessageSource

i18n provides international message access for applications.

ResourcePatternResolver

The ApplicationContext interface implements the functionality of ResourcePatternResolver, enabling subclasses of the ApplicationContext interface to load spring configuration files in an Ant-like manner.

The two main implementation classes of ApplicationContext interface are ClassPathXmlApplicationContext and FileSystemXmlApplicationContext. The use of these two implementation classes has been introduced in other articles, so I will not explain them in detail here.

Difference between ApplicationContext interface and BeanFactory interface

The BeanFactory interface does not instantiate objects when initializing IOC containers, but instantiates specific objects the first time an object is invoked. The ApplicationContext interface initializes all single-instance objects directly when initializing the IOC container. This is one of the main differences between the two interfaces. Because of this, the initialization time of the ApplicationContext interface is longer than that of the BeanFactory interface.

This article is shared from Weixin Official Accounts-jilinwulacom.

If there is infringement, please contact support@oschina.cn to delete it.

This article participates in the "OSC Source Creation Plan." Welcome you who are reading to join and share it together.

At this point, the study of "Usage of ApplicationContext Interface in Spring Framework" is over, hoping to solve everyone's doubts. Theory and practice can better match to help everyone learn, go and try it! If you want to continue learning more relevant knowledge, please continue to pay attention to the website, Xiaobian will continue to strive to bring more practical articles for everyone!

Tags: Interface framework function container object learning two event instance article time more help application development utility next up and down context public Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno MariaDB Redmi Shulou Tech Info Microsoft vpn