service layer
The layer of an application that holds use cases and business rules, sitting between controllers and repositories.
In more detail
Services know nothing about HTTP or JSON, which lets unit tests call them directly with fake repositories. They translate entities into response models and decide transaction boundaries.
Example
class OrderService { OrderView find(String id) { ... } }Related terms
- layered architecture — Organising a system into ranked layers where each layer may only use layers below it.
- controller (Spring) — A Spring class, usually marked @RestController, whose methods handle HTTP requests for particular paths and return response bodies.
- transaction — A group of database changes that succeed or fail together, so the data is never left half-updated.
- @Service — A Spring annotation that marks a class as a service bean so component scanning discovers and creates it.
Taught in
- Controllers And Routing — Modern Java: Virtual Threads & High-Throughput Services
- Validation — Modern Java: Virtual Threads & High-Throughput Services
- Tying It All Together — Modern Java: Virtual Threads & High-Throughput Services