Introduction to Spring Framework

Sagar Kudu
3 min readMar 29, 2021
  • Spring is a Dependency Injection framework to make java applications loosely coupled.
  • Spring framework makes the development process easy for JavaEE applications.
  • Spring enables you to build applications from “plain old Java objects” (POJOs) and to apply enterprise services non-invasively to POJOs.
  • Spring was developed by Rod Johnson in 2003.

Introduction to Spring Framework

Spring Framework
Official — Spring Framework

I) Core Container

The Core Container consists of the Core, Beans, Context, and Expression Language modules.

→ It consists of 4 modules viz Core, beans, Context, spEL. These 4 modules provide the fundamentals of spring. It means on this module only the complete spring is based.

Core and beans provide the fundamental part of spring core.

Using these Core and beans modules we get basic fundamental things like all injections to say dependency injection, inversion of control(IOC). That is why all these 4 modules are kept into Spring Core.

Context — It inherits all features from the bean module.

  • It adds features like Internationalization(I18N), Event Propagation, resource loading, and the transparent creation of context. Creation of context in Servlet.
  • It provides EE features like EJB, JMS, and basic remoting.
  • The ApplicationContext interface is the focal point of the Context module.
  • spring-context-support provides support for integrating common third-party libraries into a Spring application context, in particular for caching (EhCache, JCache) and scheduling (CommonJ, Quartz).

spEL- Spring Regular Expression Language.

  • It is very popular to query expression language and manipulate an object graph at the runtime.
  • It manipulates query object graphs at runtime, which means we can put, remove the value of the object.
  • The language supports setting and getting property values, property assignment, method invocation, accessing the content of arrays, collections and indexers, logical and arithmetic operators, named variables, and retrieval of objects by name from Spring’s IoC container.
  • It also supports list projection and selection as well as common list aggregations.

AOP

AOP — Aspect-Oriented Programming.

→ Interceptors means suppose we want to do some tasks before or after methods, so we can use such interceptors as per need with the help of AOP.

→ AOP basically allows you to define Interceptors and pointcuts to cleanly decouple the code

Aspect

  • It basically allows or defines method interceptors.
  • we can define points cuts, so we can decouple our code
  • The separate spring-aspects module provides integration with AspectJ.

Instrumentation

→ It provides class implementation support and class loader implementation in the server. The spring-instrument-tomcat module contains Spring’s instrumentation agent for Tomcat.

Messaging

→ To serve messaging-based applications.

→ It has annotations so that we can map the messages with methods.

II) Data Integration

JDBC:

→ It provides a JDBC abstraction layer that removes tedious JDBC code and passing specific error code to the vendor.

Transaction — tx

The spring-tx module supports programmatic and declarative transaction management for classes that implement special interfaces and for all your POJOs (Plain Old Java Objects).

ORM:

To use ORM tool like Hibernate provides an integration layer

OXM:

It provides an abstraction layer that supports Object XML Mapping APIs, including JPA and Hibernate.

E.g caster, xStream, JAXB

JMS: Java Messaging Service

  • The spring-jms module (Java Messaging Service) contains features for producing and consuming messages.
  • we can produce and consume the message e.g Kafka
  • Since Spring Framework 4.1, it provides integration with the spring-messaging module

III) Web Module

  • It provides MVC features, helps to build REST API, it also contains HTTP client and web-related parts.
  • The spring-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.
  • It also contains an HTTP client and the web-related parts of Spring’s remoting support.

Web:

→ It provides web-oriented features.

E.g file uploading on the server, creation of REST APIs.

IV) Test

  • It provides support for testing applications using Unit and Integration testing.
  • e.g: We have JUnit and TestNG.
  • It provides consistent loading of Spring ApplicationContexts and caching of those contexts.
  • It also provides mock objects that you can use to test your code in isolation.

Check out my latest articles and please show some love if you like an article.❤

For queries reach out to me at sagar978@gmail.com.

--

--

Sagar Kudu

I am Full Stack Java Developer @ Tata Strive | Get blogs and tutorials related to the (React | Kafka | DevOps) | Connect https://www.linkedin.com/in/sagarkudu/