0

I am new to Spring, I read BeanFactory is also called basic IOC and ApplicationContext is called Advanced IOC.

I read:

BeanFactory Container is the simplest container providing the basic support for DI and is defined by the org.springframework.beans.factory.BeanFactory interface. The BeanFactory and related interfaces, such as BeanFactoryAware, InitializingBean, DisposableBean, are still present in Spring for the purpose of backward compatibility with a large number of third-party frameworks that integrate with Spring.

ApplicationContext container adds more enterprise-specific functionality such as the ability to resolve textual messages from a properties file and the ability to publish application events to interested event listeners. This container is defined by the org.springframework.context.ApplicationContext interface.

I am little bit confused::

BeanFactory is Basic IOC container or BeanFactory container?

ApplicationContext is Advanced IOC container or ApplicationContext container?

Community
  • 1
  • 1
kavya
  • 182
  • 3
  • 15
  • Possible duplicate of [BeanFactory vs ApplicationContext](https://stackoverflow.com/questions/243385/beanfactory-vs-applicationcontext) – Suraj Rao Mar 04 '18 at 09:24
  • I am asking difference between IOC container and BeanFactory container AND IOC container and ApplicationContext container NOT Beanfactory and Applicationcontext – kavya Mar 04 '18 at 09:29
  • https://docs.spring.io/spring/docs/3.2.x/spring-framework-reference/html/beans.html#beans – Suraj Rao Mar 04 '18 at 10:11
  • It means BeanFactory and ApplicationContext is IOC container. Then can you tell me what is BeanFactory container and Application container? – kavya Mar 04 '18 at 10:53
  • you can read the dupe for the difference between those.. – Suraj Rao Mar 04 '18 at 10:55
  • If IOC container is there then what is the need of BeanFactory container? – kavya Mar 04 '18 at 10:56

2 Answers2

0

The BeanFactory interface

The root interface for accessing the Spring container. Spring’s Dependency Injection functionality using this BeanFactory interface and its subinterfaces.

Features:

  • Bean instantiation/wiring

Important to mention that it only supports XML-based bean configuration. Usually, the implementations use lazy loading, which means that Beans are only instantiating when we directly calling them through the getBean() method.

The most used API which implements BeanFactory is the XmlBeanFactory.

The ApplicationContext interface

The ApplicationContext is the central interface within a Spring application for providing configuration information to the application.

It implements the BeanFactory interface. Hence ApplicationContext includes all functionality of the BeanFactory and much more! Its main function is to support the creation of big business applications.

Features:

  • Bean instantiation/wiring
  • Automatic BeanPostProcessor registration
  • Automatic BeanFactoryPostProcessor registration Convenient
  • MessageSource access (for i18n)
  • ApplicationEvent publication

Supports both XML and annotation based bean configuration Uses eager loading, so every bean instantiate after the ApplicationContext started up.

For more, see my blog post:

Difference between BeanFactory and ApplicationContext in Spring – The java spring blog from the basics

Pang
  • 9,564
  • 146
  • 81
  • 122
Zoltán Raffai
  • 127
  • 1
  • 10
0

BeanFactory: is Lezy instantiation of a bean because After creating IOC Container and after calling factory.getbean method then BeanFactory request to IOC container for creating object of a bean.

ApplicationContext:is Eager instantiation of a bean It creates the object of a bean at the time creating IOC container.

BeanFactory:It does not support I18

ApplicationContext:It support.