Service Layer Using Spring

veenit shukla
3 min readFeb 27, 2021

--

What is the service layer?

The service layer is the main layer that contains all the business logic and interacts with the persistence layer and processes the information.

What is the need for the spring framework?

  • Spring framework supports and promotes the loose coupling in the code because of which code can be updated and maintained easily.
  • Spring framework comes with prebuild features which make the life of java and programmer easy.
  • Testing an application written in the Spring framework is easy because of the support and library provided by the spring framework. Let us understand it better as the spring framework can easily interact and can work well with test frameworks such as Junit, Mockito, and so on. As a result, unit integration testing becomes easy with the spring framework.
  • Spring framework is light and easy to use and removes most of the code implementation.
  • Spring framework can be used both for developing desktop applications as well as web-based sites.

What are tightly and loosely coupled components?

  • In tightly coupled, the data or objects are hardcoded in the code because of which we can face many problems such as if we want to update the data then we have to update it at all the positions where it is been used in the code, keeping track of it and maintaining is troublesome.
  • In loosely coupled the data and objects are not hardcoded in the system because of which updating, changing stuff is much easier.

In the code, there is one example of tightly and loosely coupled components

Information on spring

Spring is designed in a modular fashion so users have to import only the desired library to use only.

  • Spring Data Access/Integration — is used for data manipulation and integration. It covers the following modules, Transaction, Object XML Mapping, Object Relationship Mapping (ORM), Java Database Connectivity (JDBC).
  • Spring WebSpring Web Services (Spring-WS) is a product of the Spring community focused on creating document-driven Web services.
  • Spring AOP — Aspects enable the modularization of concerns such as transaction management that cut across multiple types and objects
  • Spring Instrumentation — It is one of the key features from the spring framework to review the application performance.
  • Spring Core Container The container then injects those dependencies when it creates the bean. It has the following features Beans, Core, Context, Expression Language.
  • Spring Test — It is used for the testing of the application using JUnit or TestNG.
  • Spring Messaging — This module provides support for integrating Spring applications with messaging systems.

--

--