2015-08-13 23:54:40 +02:00
|
|
|
---
|
|
|
|
layout: pattern
|
|
|
|
title: Service Layer
|
|
|
|
folder: service-layer
|
2015-08-15 18:03:05 +02:00
|
|
|
permalink: /patterns/service-layer/
|
2015-08-20 21:40:07 +02:00
|
|
|
categories: Architectural
|
2015-12-28 15:52:44 +02:00
|
|
|
tags:
|
2019-12-13 21:09:28 +02:00
|
|
|
- Data access
|
2015-08-13 23:54:40 +02:00
|
|
|
---
|
|
|
|
|
2016-01-03 21:14:30 +01:00
|
|
|
## Intent
|
|
|
|
Service Layer is an abstraction over domain logic. Typically
|
2015-08-13 23:54:40 +02:00
|
|
|
applications require multiple kinds of interfaces to the data they store and
|
|
|
|
logic they implement: data loaders, user interfaces, integration gateways, and
|
|
|
|
others. Despite their different purposes, these interfaces often need common
|
|
|
|
interactions with the application to access and manipulate its data and invoke
|
|
|
|
its business logic. The Service Layer fulfills this role.
|
|
|
|
|
2019-12-07 20:01:13 +02:00
|
|
|
## Class diagram
|
2015-08-13 23:54:40 +02:00
|
|
|

|
|
|
|
|
2016-01-03 21:14:30 +01:00
|
|
|
## Applicability
|
|
|
|
Use the Service Layer pattern when
|
2015-08-13 23:54:40 +02:00
|
|
|
|
2019-12-13 21:09:28 +02:00
|
|
|
* You want to encapsulate domain logic under API
|
|
|
|
* You need to implement multiple interfaces with common logic and data
|
2015-09-03 18:17:07 +05:30
|
|
|
|
2016-01-03 21:14:30 +01:00
|
|
|
## Credits
|
2015-09-03 18:17:07 +05:30
|
|
|
|
|
|
|
* [Martin Fowler - Service Layer](http://martinfowler.com/eaaCatalog/serviceLayer.html)
|
2020-07-06 13:31:07 +03:00
|
|
|
* [Patterns of Enterprise Application Architecture](https://www.amazon.com/gp/product/0321127420/ref=as_li_tl?ie=UTF8&camp=1789&creative=9325&creativeASIN=0321127420&linkCode=as2&tag=javadesignpat-20&linkId=d9f7d37b032ca6e96253562d075fcc4a)
|