English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

La differenza tra l'ambiente applicativo e Beanfactory nel framework Spring

Il framework Spring fornisce due contenitori IOC, utilizzati per gestire, configurare e operare i Bean. Uno è BeanFactory, l'altro è il contesto dell'applicazione. 

The application context interface extends BeanFactory to enhance the functionality of BeanFactory. 

In the new Spring version, BeanFactory is replaced with ApplicationContext. However, the existence of BeanFactory is for backward compatibility. 

Spring 2.0 and higher versions use the BeanPostProcessor extension point (the interface provides some callback methods, which we can implement to customize instantiation logic, dependency resolution logic, etc.). Therefore, if you use BeanFactory, some additional configuration is required to use certain features (such as AOP and transaction processing).

Serial numberKeyBean factoryApplication environment
1 piece
Implementation 
XMLBeanFactory implements BeanFactory 
FileSystemXmlApplicationContext, ClassPathXmlApplicationContext and AnnotationConfigWebApplicationContex implement ApplicationContext. 

In addition, ApplicationContext extends Beanfactory 
2
Annotation 
No
Yes
3
Instantiation
Bean factory instantiates beans when the getBean() method is called.
The application context applies instainte bean when the container starts.
4
Activity publishing 
Bean factory does not have the ability to push events to the beans 
The application context has the ability to push events to beans.
5
Loading mechanism
Lazy loading 
Aggressive loading 
Ti potrebbe piacere