16-Spring MVC - Project Work - Service Interface for Business Logic (Contact App)- By eZeon

Опубликовано: 18 Март 2026
на канале: Vikram Thakur
7,309
62

This Project Work(Contact App) video is based on Business Logic(Service Interface) and testing it independently(out of MVC and Without Web Server).

WHAT IS BUSINESS LOGIC OR DOMAIN LOGIC OR SERVICE?
Business Logic is a most important part of the project(backbone) where customer requirement is development along with workflow.

According to wikipedia (https://en.wikipedia.org/wiki/Busines...) :
In computer software, business logic or domain logic is the part of the program that encodes the real-world business rules that determine how data can be created, stored, and changed.

WHAT IS BUSINESS LAYER OR SERVICE LAYER?
Service layer contains business logic of the project. There can be multiple service class and interfaces involved to meet the business requirement. It should be independent, portable and loosely coupled with another layer of the project/application.

HOW SERVICE CLASS IS DIFFERENT FROM DAO CLASS?
Service Class contains business logic where different operations can be executed together in a proper order to meet business-requirement. The logic in service class can communicate with other systems like Email Server, FTP Server, SMS API. The logic in service layer can join multiple tables to fetch records or prepare the reports.

DAO Class contains operations/methods to handle CRUD operations for SINGLE ENTITY/TABLE. In practices DAO does not contains table-join operation. But DAO can be reused in Service Layer.

HOW TO DEVELOP BUSINESS LOGIC or SERVICES?
1.Create SERVICE INTERFACE which contains different business methods prototypes with proper documentation.

2.Provide Service Implementation class. This class contains the definition of business methods. The Service Class can reuse DAO classes.It also contains Database Operation, Transaction Handing, Business Flow, Email/SMTP Operations, SMS Operations or anything which is required to client(client-requirement).

3. Finally test the Service independently(out of MVC layer). JUnit can also be used.

COVERAGE IN THIS VIDEO:
1. Service Interface - UserService
2. Documentation of Interface
3. Revise business requirement and plan interface operation for User Entity

CODE REFERENCE:

//UserService.java
package in.ezeon.capp.service;
import in.ezeon.capp.domain.User;
import in.ezeon.capp.exception.UserBlockedException;
import java.util.List;
/**
*
@author Vikram
*/
public interface UserService {

public static final Integer LOGIN_STATUS_ACTIVE=1;
public static final Integer LOGIN_STATUS_BLOCKED=2;

public static final Integer ROLE_ADMIN=1;
public static final Integer ROLE_USER=2;


/**
The method handle the user registration task.
@param u the new user detail as User Object.
*/
public void register(User u);

/**
The method handles login operation(authentication) using given credentials,
it returns User object when success and null when failed.
When user account is blocked an exception will be thrown by this method.
@param loginName
@param password
@return
@throws in.ezeon.capp.exception.UserBlockedException When user account is blocked.
*/
public User login(String loginName, String password) throws UserBlockedException;

/**
Call this method to get list of registered users.
@return
*/
public List getUserList();

/**
This method change the user login status for details passed as argument.
@param userId
@param loginStatus
*/
public void changeLoginStatus(Integer userId, Integer loginStatus);
}

Don't skip or miss any video, just follow step by step video series.
Also check the source code listing in our
blog http://ezeon.in/blog

Don't forget to subscribe my channel.