Spring Framework

Sachith Ariyathilaka
3 min readFeb 5, 2024

Spring is a Java-based, open-source, lightweight framework that allows us to develop Java applications. Before we discuss the architecture of the Spring Framework, we need to know the basic features of this framework: Inversion of Control (IOC) and Dependency Injection (DI).

There are many design patterns to remove dependencies from the programming code. It helps to maintain the bigger code easier. This is called the Inversion of Control. Dependancy Injection is a design pattern that is used to implement the IOC. Let’s discuss IOC and DI with the following example.

public class Main() {
Friend friend;

public Main() {
this.friend = new Friend();

In the above example, we can see class Friend tightly coupling with class Main. So there are dependencies between these two classes. But the IOC code should be loosely coupled. By using dependancy injection, we can modify the code as follows.

public class Main {
Friend friend;

public Main(Friend friend) {
this.friend = friend;

Now let’s discuss the modules of the Spring Framework. Spring modules are mainly classified as Spring Core Container, Test, AOP, Aspects, Instrumentation, Data Access/Integration, and Web (MVC/Remoting).

01. Spring Core Container: This container mainly consists of the Core, Beans, Context, and Expression Language submodules.

=> Core: This module provides the basic fundamental parts of the framework, including the IOC and DI.

=> Beans: This module provides the BeanFactory, which is a complex implementation of the factory design pattern.

=> Context: This module is built on the core and bean modules. This module is the medium for accessing any object defined and configured. The ApplicationContext Interface is the main component of this module.

=> Expression Language: This module provides a powerful expression language for querying and manipulating an object graph at runtime.

02. Data Access/Integration: This module mainly consists of the JDBC, ORM, OXM, JMS, and Transactions.

=> JDBC: This module provides an abstract JDBC layer, which helps to avoid complex JDBC-related codes.

=> ORM: This module provides the integration layer for popular ORMs like JPA, JDO, Hibernate, and iBatis.

=> OXM: This module provides the abstract layer that supports object/XML mapping implementations for JAXB, Castor, XMLBeans, JiBX, and XStream.

=> JMS: The Java Messaging Service module contains features for producing and consuming messages.

=> Transaction: This module uses transaction management in the framework.

03. Web (MVC/Remoting): This module mainly consists of Web, Web-MVC, Web-Socket, and Web-Portlet modules.

=> Web: This module mainly provided the basic web-oriented features, such as multipart file upload functionality, initialization of the IOC container using servlet listeners, and web-oriented application context.

=> Web-MVC: This module contains the Spring MVC implementation for web applications.

=> Web-Socket: This module provides web socket-based, two-way communication between the server and client in web applications.

=> Web-Portlet: This module provides the MVC implementation to be used in a portlet environment or other pluggable web components.

04. AOP: This module allows us to implement aspect-oriented programming. AOP is an approach to programming that allows global properties of a program to determine how it is compiled into an executable program.

05. Aspects: This module uses the integration of AspectJ, which is a powerful AOP framework.

06. Instrumentation: This module provides the class instrumentation support and class loader implementations to be used in application servers.

07. Test: This module supports the testing of Spring components by using the JUnit or TestNG framework.