The Core module provides the fundamental parts of the framework, including the IoC and Dependency Injection features.
The Bean module provides BeanFactory, which is a sophisticated implementation of the factory pattern.
The Context module builds on the solid base provided by the Core and Beans modules and it is a medium to access any objects defined and configured. The ApplicationContext interface is the focal point of the Context module.
The SpEL module provides a powerful expression language for querying and manipulating an object graph at runtime.
Data Access/Integration
The JDBC module provides a JDBC-abstraction layer that removes the need for tedious JDBC related coding.
The ORM module provides integration layers for popular object-relational mapping APIs, including JPA, JDO, Hibernate, and iBatis.
The OXM module provides an abstraction layer that supports Object/XML mapping implementations for JAXB, Castor, XMLBeans, JiBX and XStream.
Web
The Web module provides basic web-oriented integration features such as multipart file-upload functionality and the initialization of the IoC container using servlet listeners and a web-oriented application context.
The Web-MVC module contains Spring's Model-View-Controller (MVC) implementation for web applications.
The Web-Socket module provides support for WebSocket-based, two-way communication between the client and the server in web applications.
The Web-Portlet module provides the MVC implementation to be used in a portlet environment and mirrors the functionality of Web-Servlet module.
Spring Framework
IoC (Inversion of Control) Container
The Spring container is at the core of the Spring Framework.
The container will create the objects, wire them together, configure them, and manage their complete life cycle from creation till destruction.
The objects controlled by IoC container are called beans
Container or framework control the objects or some portion of the program
Two types of containers in Spring:
Spring BeanFactory Container
This is the simplest container providing the basic support for DI and is defined by the org.springframework.beans.factory.BeanFactory interface.
Spring ApplicationContext Container
This container adds more enterprise-specific functionality such as the ability to resolve textual messages from a properties file and the ability to publish application events to interested event listeners.
The ApplicationContext container includes all functionality of the BeanFactorycontainer, so it 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.
Container Overview
org.springframework.context.ApplicationContext interface represents the Spring IoC container and 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 which is represented in XML, Java Annotations, or Java code
Dependency Injection
What is dependency: java class (A.java) may depend on one or more other java classes. These other java classes are known as dependencies of the java class A.
Ways to achieve DI:
constructor based
setter method based
Bean
The objects that form the backbone of your application and that are managed by the Spring IoC container are called beans.
These beans are created with the configuration metadata that you supply to the container.
Annotations
@Autowired
applied on fields, setter methods, and constructors
Flow of an HTTP request
Client sends an HTTP request to a specific URL
DispatcherServlet of Spring MVC receives the request
It passes the request to a specific controller depending on the URL requested using @Controller and @RequestMapping annotations.
Spring MVC Controller then returns a logical view name and model to DispatcherServlet.
DispatcherServlet consults view resolvers until actual View is determined to render the output
DispatcherServlet contacts the chosen view (e.g. Thymeleaf, Freemarker, JSP) with model data and it renders the output depending on the model data
The rendered output is returned to the client as response