Service Layer Pattern
Sources:
- https://softwareengineering.stackexchange.com/questions/162399/how-essential-is-it-to-make-a-service-layer
- https://en.wikipedia.org/wiki/Service_layer_pattern
- Domain-Driven Design by Evans
Spring Boot
- Spring Boot
- Use the appropriate annotations
Presentation Layer : Controller (@Controller)
- Merely responsible to presenting a business function (provided in Application Service Layer). Hence mostly delegation to App Service, doing data massaging and presentation-related logic.
Application Service Layer : Application Service (@Service)
- High level speaking, it represents business use cases. Hence transaction boundary is set on the methods (as each method is a use-case, hence a unit of work). As I am against use of anemic model, real business logic should be in the domain model layer. This layer mostly make use of domain layer to compose of a meaningful use case. Mostly data transformations (depending on your design), and delegations to domain layer artifacts.
Domain Layer : Model, Domain Service (@Service), Repository (@Repository) etc
- Business logic are in domain models, or Domain Services. Repository are the artifacts to retrieve domain models.