Understanding Spring IoC Container

Before we delve into the Spring IoC Container, let us first try to understand a “Bean”.

So what is a Bean?

The objects that form the backbone of your application and that are managed by the Spring IoC container are called beans.

Spring IoC container is responsible for instantiating, configuring, and assembling the beans. The container gets its instructions on what objects to instantiate, configure, and assemble by reading configuration metadata. The configuration metadata is represented in XML, Java annotations, or Java code.

Spring IoC Container

Spring container classes: These classes create and manage the life cycle of the beans defined in the Spring bean configuration file.

Spring provides two kinds of IoC container, one is BeanFactory and other is ApplicationContext.

  • BeanFactory
  • ApplicationContext

BeanFactory vs ApplicationContext

Spring IoC Container

The ApplicationContext is generally recommended over BeanFactory. BeanFactory can still be used for lightweight applications like mobile devices or applet-based applications where data volume and speed is significant.

One comment

Leave a Reply

Your email address will not be published. Required fields are marked *