
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Difference Between Application Context and BeanFactory in Spring Framework
Spring framework provides two IOC container for managing, configuring and manipulating beans. One is BeanFactory and the other is Application Context.
The application context interface extends BeanFactory to enhance the functionality of BeanFactory.
In new Spring versions, BeanFactory is replaced with ApplicationContext. But still, BeanFactory exists for backward compatibility.
Spring version 2.0 and above, is used BeanPostProcessor extension point(Interface which provides some callback methods that we can implement to customize the instantiation logic, dependency-resolution logic and etc ). So, if you are using BeanFactory then some of the functionality such as AOP and transaction will not work without doing some extra configuration.
Sr. No. | Key | Beanfactory | Application context |
---|---|---|---|
1 |
Implementation |
XMLBeanFactory implements BeanFactory |
FileSystemXmlApplicationContext, ClassPathXmlApplicationContext and AnnotationConfigWebApplicationContex implements ApplicationContext. Also, ApplicationContext extends Beanfactory |
2 |
Annotation |
No |
Yes |
3 |
instantiation |
Benafactory instantiate beans when getBean() method gets called. |
Application instainte bean at the time container start. |
4 |
Event Publication |
Bean factory does not have the ability to push events to the beans |
Application Context have ability to push to push events to the beans. |
5 |
Loading Mechanism |
Lazy loading |
Aggressive Loading |
Advertisements