17 Jan 2018

What is difference between BeanFactory and ApplicationContext in Spring framework?

Now a days the question "difference between BeanFactory and ApplicationContext in Spring framework? " has became most popular in most of the industry. mostly this question is asked to more than 2 years of experience people in Spring Framework .Today we are going to discuss this topic and going to understand the differences between BeanFactory and ApplicationContext .Here i have given some differences in tabular form so to make it clear.


BeanFactory
ApplicationContext
BaenFactory is also known as Basic IoC Container.
ApplicationContext is also known as Advanced IoC Conatiner.
Beanfactory uses the lazy Initialization means it will create Singlton Bean based on the demand.
ApplicationContext uses eager initialization means it will create all singleton Beans at the time of its own initialization.
BeanFactory creates and manages resources by explicitely.
ApplicationContext creates and manages resources by its own.
Internationalization is not supported by BeanFactory.
Internationalization is supported by ApplicationContext.
Annotation based dependency is not supported by BeanFactory.
ApplicationContext supports Annotation by using @PreDestroy @AutoWired.
One of the most popular implementation of BeanFactory interface is XmlBeanFactory.
One of the most popular implementation of ApplicationContext Interface is ClassPathXmlApplicationContext.
If you are using auto wiring and using BeanFactory then you need to register AutoWiredBeanPostProcessor.
If you are using ApplicationContext you can configure in Xml.