In the previous article, we have seen the overview of Spring Framework with its features and advantages(you can check it here Introduction to Spring Framework.). In this article, we will see the Architecture of Spring Framework.
Spring is a popular framework because it has multiple modules that are grouped and well organized into different components which are loosely coupled. for eg, If we want to use the Spring Web module we don’t need to add the Spring JMS module. Every module is independent of each other.
Modules of Spring Framework
Spring has a layered architecture that consists of 20 modules that are grouped and organized into the following components.
- Core Container
- Data Acces/Integration
- Aspect-Oriented Programming
Core Container Module
The core container provides the implementation of Inversion of Control (IOC) also known as Dependency Injection (DI) which is a basic feature of Spring Framework (we will learn in detail about DI in the next tutorial). It consists of the following modules
- Expression Language
The Core is an important part of the Framework. It provides the feature of IOC which is Dependency Injection.
Dependency Injection or Inversion of control is a process through which the Spring container injects objects into other objects or dependencies. It is basically done to allow loose coupling and moves the responsibility of creating objects to the Spring Container.
The Bean module provides the implementation of a factory pattern called BeanFactory. BeanFactory is an interface that provides a configuration mechanism capable of handling any type of Object. A bean in Spring is a Java class that is registered with spring.
The context module provides the ApplicationContext Interface. It provides enterprise-specific functionality. In Spring every Object is a bean. So all the constructor, factory methods are defined in the context.
The Expression Language module is an important part of the Spring Framework. It has additional feature along with those defined in JSP(If you want to know what is the Expression language in JSP you can check it here Expression Language in JSP )
The Core Container is the base of the entire Spring Framework.
This module provides the support for testing of Spring components with JUnit or TestNG.
Aspect-Oriented Programming Module
It is one of the key features of the Spring Framework. The breaking down of programing logic into different parts are called concerns. It allows us to include new functionality into an existing code without modifying its design.
Spring Aspects provide us a way to integrate other Aspect-oriented Programming implementation like AspectJ.
It provides support for class loader implementation. It is used to monitor the performance of the application.
While creating any application, we need to access the data from the database, XML and, etc. So spring provides us a set of modules called Spring Data Access. The following are the list of components
- Spring JDBC
- Spring ORM
- Spring JMS
- Spring OXM
Spring JDBC provides us the JDBCTemplate to access data from the database. It helps us to remove the complexity of writing too many queries for CRUD and helps us to save our time.
ORM is an Object Relational Mapping tool that maps the Object to the relation (Table) of the database. Spring ORM provides support for Hibernate ORM, JPA, and etc.
Spring JMS acronyms to Java Messaging Service that provides features for coveying and consuming messages.
Spring OXM acronyms to Object XML Marshalling and it provides an abstraction over Java OXM implementations. It provides a way of transferring and accessing data in the form of XML.
The transaction provides an abstraction mechanism to support transactions in an application.
From the name itself, we can understand this module will help us to build a web-based application. It consists of the following component.
- Web & Servlet
- Web Socket
- Web Portlet
Spring Web & Servlet module provides a web-based integration feature such as a multipart feature. It provides a Web Application Context.
Web Socket is used as two-way communication between the client and server in web applications. Spring provides us the support of Web Socket using this component.
Spring Web Portlet is nothing but the pluggable user interface that is managed in a web portal. This module called web portlet provides support for building web portlets.
Thus, this was all about the Architecture of Spring Framework which consists of multiple modules each being independent of each other.
In the next article of this tutorial, we will see the Environment Set Up of Spring Framework.