The Spring IoC Container
An IoC container is a common characteristic of frameworks that implement IoC.
In the Spring framework, the IoC container is represented by the interface ApplicationContext. The Spring container is responsible for instantiating, configuring and assembling objects known as beans, as well as managing their lifecycle.
The Spring framework provides several implementations of the ApplicationContext interface
- — ClassPathXmlApplicationContext and FileSystemXmlApplicationContext for standalone applications,
- — WebApplicationContext for web applications.
In order to assemble beans, the container uses configuration metadata, which can be in the form of XML configuration or annotations.
Here’s one way to manually instantiate a container:
ApplicationContext context = new ClassPathXmlApplicationContext("applicationContext.xml");