Followers

springIOC: Containers



Spring provides the following containers.
1. Spring BeanFactory Container
This is the simplest container providing basic support for DI and defined by the org.springframework.beans.factory.BeanFactory interface
Resource res= new ClassPathResource(“Beans.xml”);
BeanFactory factory = new XmlBeanFactory(res);

2. Spring Application Container
This container is defined by the org.springframework.context.ApplicationContext. The container adds some enterprise specific functionality.
ApplicationContext is more preferable. BeanFactory is used in mobile based application where data volume is significant.
ApplicationContext interface builds on top of the BeanFactory and adds other functionalities such as easier integration with Spring AOP features, message event propagation and resource handling.
 
ApplicationContext context = new ClasspathXmlApplicationContext(“Beans.xml”);

The Spring container is the core Spring framework.
The container will create the objects, wire them together, and configure to till destruction. The Spring framework uses DI to manage the components that make up an application. These objects are called as Spring Beans.
The container get its instructions on what objects to instantiate, configure and assemble by reading the configuration metadata provided. The configuration metadata can represented in different forms like XML, Java Annotations and Java code. The Spring IOC makes use of Java POJO classes and metadata to produce a fully configured application.
The basic idea of Inversion of Control (IOC) pattern or DI is that you no need to create your objects but describe how they should be created.
The IOC pattern provides better software designing that facilitates loose coupling, re-use and easy testing of software components.


No comments:

Post a Comment