Sunday, August 23, 2020

Spring - The IoC Container

The Spring IoC Container creates the objects, wire them together, configure them and manage their complete lifecycle from creation till destruction.

There are two types of IoC containers:

1. Bean Factory Container
    - simplest container providing basic support for DI
    - proffered where resources are limited like mobile devices or applet based applications
    - e.g. XmlBeanFactory (this container reads the configuration metadata from an XML file)

2. Application Context Container
    - has more enterprise specific functionalities such as resolving textual messages from properties file and publishing application events to interested event listeners
    - e.g.
    - FileSystemXmlApplicationContext - load bean definition and configuration from an XML file. Need to provide full path of the xml file to the constructor.
    - ClassPathXmlApplicationContext - load bean definition and configuration from an XML file. The xml file should be present in the CLASSPATH
    - WebXmlApplicationContext - loads the XML file with definition of all beans from within a web application.

No comments:

Post a Comment

Spring - AutoWiring

Spring automatically resolves the dependencies between the collaborating beans by inspecting the contents of the BeanFactory. This is called...