13 Dec 2017

What are the differences between BeanFactory and ApplicationContext IoC Container?



BeanFactory is also called basic IOC and ApplicationContext is called Advanced IOC. Although BeanFactory and ApplicationContext both are used to get the beans from IOC container by using method getBean(String beanName).

BeanFactory
ApplicationContext
BeanFactory is also called basic IOC.
ApplicationContext  is called  Advanced IOC.
BeanFactory uses lazy initialization approach means BeanFactory creates a singleton bean only when it is requested from it.
ApplicationContext uses eager initialization approach means ApplicationContext creates all singleton beans at the time of its own initialization.
BeanFactory creates and manages resources by  explicitly .
ApplicationContext creates and manages resources objects on its own.
BeanFactory do not supports internationalization.
ApplicationContext supports internationalization.
Annotation based dependency Injection is not supported by BeanFactory. 
ApplicationContext supports using annotation @PreDestroy, @Autowired.
One of the popular implementation of BeanFactory interface is XMLBeanFactory .
One of the popular implementation of ApplicationContext interface is ClassPathXmlApplicationContext
If you are using auto wiring and using BeanFactory than you need to register AutoWiredBeanPostProcessor .
 if you are using  ApplicationContext  you can configure in XML.