ApplicationContext

Let’s look at different terms used to refer to application context :

  • IoC Container
  • ApplicationContext
  • BeanFactory

The control of creating an object is moved from application code to an external framework is called Inversion of Control. The framework uses Dependency Injection to inject the dependencies.

The Framework needs to know what are all the dependencies are, make sure they are available and wire them in. The program which provides this is IoC Container. The Container is the one which manages the beans.

IoC Container is kind of a generic concept, is not really framework specific.

In Spring, there are two implementations of the IoC Container :

  • ApplicationContext – Spring recommends using this.
  • BeanFactory

BeanFactory – provides very basic management for beans and wiring of the dependencies. (spring-core)

ApplicationContext is nothing but BeanFactory++.

  • Spring’s AOP Features
  • I18N capabilities
  • WebApplicationContext for web applications, etc

In situations where memory is constraint, use BeanFactory. But in most of all other cases, use ApplicationContext.