Hexagonal Architecture with Java Spring
Create an application to work without either a UI or a database so you can run automated regression-tests
Last updated
Was this helpful?
Create an application to work without either a UI or a database so you can run automated regression-tests
Last updated
Was this helpful?
Resources:
System's interfaces should be designed "by purpose" rather than technology.
Technology are substitute by adaptors.
Hexagonal Architecture reflects the use “primary actors” and “secondary actors”. A ‘’primary actor’’ is an actor that drives the application (e.g user interaction or an automated regression testing suite). A ‘’secondary actor’’ is one that the application drives, either to get answers from or to merely notify (e.g. database response).
The domain is the core of the hexagon, containing primary business logic, free of any infrastructure and framework boilerplate.
Ports are plain Java interfaces that allow adapters to plugging into the core domain (e.g. repositories interfaces)
Adapters are either external APIs of your application or clients to other systems. They translate the interfaces of external systems to interfaces exposed by the domain through ports.
Now we will try to map the Hexagonal Architecture concepts to a more developer friendly Spring naming covetous
service (rappresenting all the port)
Each adapter works on its data model, which can translate itself “from” or “to” the domain. The domain model on the other hand is adapter-model-agnostic. That’s why you should always favour
over