SlideShare a Scribd company logo
Java Development
HEXAGONAL
ARCHITECTURE
for Java Applications
01 Concepts
Software Architecture
01 What drives the software architecture?
• High Maintainability
• Low Technical Debt: The cost payed by bad decisions
• Lack of understanding
• Lack of tests
• Lack of documentation
• Lack of collaboration
• Lack of process
01 Common multi-layer architecture
!
"
#
"
! UI Layer
" Application Layer
# Data
" Crosscutting
Dependency
01 Multi-tier architecture
Web Application Tier
! !
" "
"
# # #
" "
"
!
"
Client Tier
Browsers, Frontend App
Mobile devices, PC$Q
%
!
+
Data / Integration Tier
Database, File Storage,
External Systems, Cloud
&

ERP
CRM
DOCs
Dependency
01 Dependency inversion principle
Reference: http://blog.ploeh.dk/2013/12/03/layers-onions-ports-adapters-its-all-the-same
Dependency
DANGER -
Possible business
logic leaks
02 Hexagonal
Architecture
The Pattern
02 Intent
• Alternative names
• Ports & Adapters
• Onion Architecture / Onion Layers
“Allow an application to equally be driven by users,
programs, automated test or batch scripts, and to be
developed and tested in isolation from its eventual run-
time devices and databases.”
Alistair Cockburn
02 Key Concepts
Ports are interfaces
Adapters are implementations
The big picture: Ports & Adapters02
"Application
Port Port
Port
Mock
DB
DB
Integration
Test
Agent
UI
Adapter
Adapter
Adapter
Adapter
Use Case
Boundary
‘’driven’’ adapters
‘’driver’’ adapters
Overview02

In-Memory
"Application
# Database
( Web Services
)
) Enterprise Integration
*

SQL Server
REST
Adapter
* Configuration
+
Test Agent
!
HTML5 App
Environment
Adapter
File Source
Adapter
,
SQL
Adapter
#
NoSQL
Adapter
- MQ Service
MQ
Adapter
.
. Messaging Queue
&ERP
CRM
DOCs
EI
Adapter
(SOAP
Adapter
TEST
Adapter
03 Application
Keeping it simple
03
• Organizing Concerns and Code with Domains
• Well defined boundaries between domains
• Simple event-driven components
• Life Preserver diagram
Life preserver approach by Russ Miles
Life Preserver diagram03
Integration
Core
Domain Event
Service
Domain
Boundary
Notes03
• Core
• Single purpose
• Focus on unit testing
• No side-effects
• Integration
• Side effects
04 Practice
Ticket System
Kick-off04
github.com/fabricioepa/lab-
springboot-rest-sample
Lets start from the sample project and
then create the ports and adapters
05 Core
Use Case as service
Implementing the Use Case as Service05
• Domain model
• Entities
• Repositories
• Well defined interface
• Input/Output Events
• Event Handlers & Translators
• Service composition
• Unit Testing
Life Preserver
Services
Domain
Event
Repository
D
atabase
Test
UnitTest
Framework
0405
06 Controllers
Implementing passive controllers
• Dummy service invokers
• Do not perform multiple service calls
• It does not make any workflow decision
• REST Domain translator
0305
• UC
• Service
• Services
• Domain
• Controller
REST
Domain
06
Life Preserver
Services
Domain
Event
Repository
D
atabase
Test
UnitTest
Framework
Domain
Controller
R
EST
030506
07
Configuration
Externalized configuration
• External files
• Environment variables
• Configuration profiles
• Services
030507
MySQL
Life Preserver
Services
Domain
Event
Repository
D
atabase
Test
UnitTest
Framework
Domain
Controller
R
EST
C
onfiguration
App
Settings
Test
Client
H2
in-memory
Environment
030507
Comments
• How many ports?
• The hexagon is a metaphor
• Abstractions
• Use Case as port
• Module as port: Notification, Administration,
Public API, Database
0303
• Services
See more…
• RESTful API with Spring Boot
• Securing REST APIs
• References:
[1] alistair.cockburn.us/Hexagonal+architecture
[2] www.infoq.com/news/2013/08/hexagonal-lifepreserver-spring
[3] github.com/russmiles/life-preserver-introductory-article-developer-magazine/
blob/master/README.md
[4] github.com/spring-guides/deprecate-tut-rest
[5] blog.ploeh.dk/2013/12/03/layers-onions-ports-adapters-its-all-the-same
/ fabricioepa.wordpress.com
Contact
FABRICIO EPAMINONDAS
0 linkedin.com/in/fabricioepa
/ fabricioepa.wordpress.com
1 @fabricioepa

More Related Content

What's hot (20)

PPTX
Spring Security 5
Jesus Perez Franco
 
PPTX
Angular tutorial
Rohit Gupta
 
PPTX
REST & RESTful Web Services
Halil Burak Cetinkaya
 
PDF
Angular
Lilia Sfaxi
 
PDF
The New JavaScript: ES6
Rob Eisenberg
 
PPTX
Spring boot Introduction
Jeevesh Pandey
 
PDF
Microservice With Spring Boot and Spring Cloud
Eberhard Wolff
 
PPTX
SOLID principles
Jonathan Holloway
 
PPTX
Hexagonal Architecture
Marcelo Cure
 
PPTX
Domain driven design
Amit Mukherjee
 
PPTX
Angular 5 presentation for beginners
Imran Qasim
 
PPSX
SOLID Principles and The Clean Architecture
Mohamed Galal
 
PPTX
Introduction to spring boot
Santosh Kumar Kar
 
PDF
NestJS
Wilson Su
 
PDF
Hexagonal architecture - message-oriented software design
Matthias Noback
 
PPTX
React JS - A quick introduction tutorial
Mohammed Fazuluddin
 
PPTX
Intro to React
Justin Reock
 
PDF
Spring boot introduction
Rasheed Waraich
 
PPTX
Spring Boot
Jiayun Zhou
 
PPTX
Introduction to angular with a simple but complete project
Jadson Santos
 
Spring Security 5
Jesus Perez Franco
 
Angular tutorial
Rohit Gupta
 
REST & RESTful Web Services
Halil Burak Cetinkaya
 
Angular
Lilia Sfaxi
 
The New JavaScript: ES6
Rob Eisenberg
 
Spring boot Introduction
Jeevesh Pandey
 
Microservice With Spring Boot and Spring Cloud
Eberhard Wolff
 
SOLID principles
Jonathan Holloway
 
Hexagonal Architecture
Marcelo Cure
 
Domain driven design
Amit Mukherjee
 
Angular 5 presentation for beginners
Imran Qasim
 
SOLID Principles and The Clean Architecture
Mohamed Galal
 
Introduction to spring boot
Santosh Kumar Kar
 
NestJS
Wilson Su
 
Hexagonal architecture - message-oriented software design
Matthias Noback
 
React JS - A quick introduction tutorial
Mohammed Fazuluddin
 
Intro to React
Justin Reock
 
Spring boot introduction
Rasheed Waraich
 
Spring Boot
Jiayun Zhou
 
Introduction to angular with a simple but complete project
Jadson Santos
 

Similar to Hexagonal architecture for java applications (20)

PDF
Hexagonal Architecture using Grails
David Dawson
 
PDF
Dependency inversion using ports and adapters
Mahfuzul Haque
 
PDF
Hexagonal Architecture.pdf
VladimirRadzivil
 
PDF
A CQRS Journey
Chrysovalantis Koutsoumpos
 
PDF
DDD - 4 - Domain Driven Design_ Architectural patterns.pdf
Eleonora Ciceri
 
PDF
Ports & Adapters Architecture - XP Days 2017
Nathan Johnstone
 
PDF
Explicit architecture
Herberto Graça
 
PDF
Hexagonal
jglobal
 
PDF
Hexagonal architecture for the web
Jesús Espejo
 
PDF
ljug-meetup-2023-03-hexagonal-architecture.pdf
Comsysto Reply GmbH
 
PDF
Layers, ports and adapters
Matthias Noback
 
PDF
A very simple hexagonal architecture.pdf
Dan MAGIER
 
PPTX
Microservices - why's and how's
Anindya Bhattacharya
 
PDF
Hexagonal Symfony - SymfonyCon Amsterdam 2019
Matthias Noback
 
PDF
Hexagonal Architecture - message-oriented software design (PHPCon Poland 2015)
Matthias Noback
 
PDF
Hexagonal architecture message-oriented software design
Matthias Noback
 
PPTX
Hexagonal_Architecture_DDD_Presentation.pptx
AslanAs2
 
PDF
Composable Software Architecture with Spring
Sam Brannen
 
PPTX
Onion Architecture / Clean Architecture
Attila Bertók
 
PDF
Hpc lunch and learn
John D Almon
 
Hexagonal Architecture using Grails
David Dawson
 
Dependency inversion using ports and adapters
Mahfuzul Haque
 
Hexagonal Architecture.pdf
VladimirRadzivil
 
DDD - 4 - Domain Driven Design_ Architectural patterns.pdf
Eleonora Ciceri
 
Ports & Adapters Architecture - XP Days 2017
Nathan Johnstone
 
Explicit architecture
Herberto Graça
 
Hexagonal
jglobal
 
Hexagonal architecture for the web
Jesús Espejo
 
ljug-meetup-2023-03-hexagonal-architecture.pdf
Comsysto Reply GmbH
 
Layers, ports and adapters
Matthias Noback
 
A very simple hexagonal architecture.pdf
Dan MAGIER
 
Microservices - why's and how's
Anindya Bhattacharya
 
Hexagonal Symfony - SymfonyCon Amsterdam 2019
Matthias Noback
 
Hexagonal Architecture - message-oriented software design (PHPCon Poland 2015)
Matthias Noback
 
Hexagonal architecture message-oriented software design
Matthias Noback
 
Hexagonal_Architecture_DDD_Presentation.pptx
AslanAs2
 
Composable Software Architecture with Spring
Sam Brannen
 
Onion Architecture / Clean Architecture
Attila Bertók
 
Hpc lunch and learn
John D Almon
 
Ad

More from Fabricio Epaminondas (10)

PDF
Understanding Web services
Fabricio Epaminondas
 
PDF
Designing Scalable Applications
Fabricio Epaminondas
 
PDF
Continuous testing in agile projects 2015
Fabricio Epaminondas
 
PDF
Info Card - Techical Debt Management
Fabricio Epaminondas
 
PDF
Software quality - Round table discussion
Fabricio Epaminondas
 
PDF
Continuous integration practices to improve the software quality
Fabricio Epaminondas
 
PPTX
Protocol buffers
Fabricio Epaminondas
 
PDF
Quickstart for continuous integration
Fabricio Epaminondas
 
PDF
Workshop Guide: RESTful Java Web Application with Spring Boot
Fabricio Epaminondas
 
PDF
Introduction to developing modern web apps
Fabricio Epaminondas
 
Understanding Web services
Fabricio Epaminondas
 
Designing Scalable Applications
Fabricio Epaminondas
 
Continuous testing in agile projects 2015
Fabricio Epaminondas
 
Info Card - Techical Debt Management
Fabricio Epaminondas
 
Software quality - Round table discussion
Fabricio Epaminondas
 
Continuous integration practices to improve the software quality
Fabricio Epaminondas
 
Protocol buffers
Fabricio Epaminondas
 
Quickstart for continuous integration
Fabricio Epaminondas
 
Workshop Guide: RESTful Java Web Application with Spring Boot
Fabricio Epaminondas
 
Introduction to developing modern web apps
Fabricio Epaminondas
 
Ad

Recently uploaded (20)

PPTX
In From the Cold: Open Source as Part of Mainstream Software Asset Management
Shane Coughlan
 
PDF
Online Queue Management System for Public Service Offices in Nepal [Focused i...
Rishab Acharya
 
PDF
SAP Firmaya İade ABAB Kodları - ABAB ile yazılmıl hazır kod örneği
Salih Küçük
 
PPTX
ChiSquare Procedure in IBM SPSS Statistics Version 31.pptx
Version 1 Analytics
 
PPTX
Hardware(Central Processing Unit ) CU and ALU
RizwanaKalsoom2
 
PPTX
Tally software_Introduction_Presentation
AditiBansal54083
 
PDF
Top Agile Project Management Tools for Teams in 2025
Orangescrum
 
PPTX
Home Care Tools: Benefits, features and more
Third Rock Techkno
 
PDF
Thread In Android-Mastering Concurrency for Responsive Apps.pdf
Nabin Dhakal
 
PDF
Odoo CRM vs Zoho CRM: Honest Comparison 2025
Odiware Technologies Private Limited
 
PDF
Why Businesses Are Switching to Open Source Alternatives to Crystal Reports.pdf
Varsha Nayak
 
PDF
Unlock Efficiency with Insurance Policy Administration Systems
Insurance Tech Services
 
PDF
Alarm in Android-Scheduling Timed Tasks Using AlarmManager in Android.pdf
Nabin Dhakal
 
PDF
유니티에서 Burst Compiler+ThreadedJobs+SIMD 적용사례
Seongdae Kim
 
PDF
Wondershare PDFelement Pro Crack for MacOS New Version Latest 2025
bashirkhan333g
 
PDF
Driver Easy Pro 6.1.1 Crack Licensce key 2025 FREE
utfefguu
 
PDF
SciPy 2025 - Packaging a Scientific Python Project
Henry Schreiner
 
PPTX
Agentic Automation Journey Series Day 2 – Prompt Engineering for UiPath Agents
klpathrudu
 
PDF
4K Video Downloader Plus Pro Crack for MacOS New Download 2025
bashirkhan333g
 
PDF
MiniTool Partition Wizard 12.8 Crack License Key LATEST
hashhshs786
 
In From the Cold: Open Source as Part of Mainstream Software Asset Management
Shane Coughlan
 
Online Queue Management System for Public Service Offices in Nepal [Focused i...
Rishab Acharya
 
SAP Firmaya İade ABAB Kodları - ABAB ile yazılmıl hazır kod örneği
Salih Küçük
 
ChiSquare Procedure in IBM SPSS Statistics Version 31.pptx
Version 1 Analytics
 
Hardware(Central Processing Unit ) CU and ALU
RizwanaKalsoom2
 
Tally software_Introduction_Presentation
AditiBansal54083
 
Top Agile Project Management Tools for Teams in 2025
Orangescrum
 
Home Care Tools: Benefits, features and more
Third Rock Techkno
 
Thread In Android-Mastering Concurrency for Responsive Apps.pdf
Nabin Dhakal
 
Odoo CRM vs Zoho CRM: Honest Comparison 2025
Odiware Technologies Private Limited
 
Why Businesses Are Switching to Open Source Alternatives to Crystal Reports.pdf
Varsha Nayak
 
Unlock Efficiency with Insurance Policy Administration Systems
Insurance Tech Services
 
Alarm in Android-Scheduling Timed Tasks Using AlarmManager in Android.pdf
Nabin Dhakal
 
유니티에서 Burst Compiler+ThreadedJobs+SIMD 적용사례
Seongdae Kim
 
Wondershare PDFelement Pro Crack for MacOS New Version Latest 2025
bashirkhan333g
 
Driver Easy Pro 6.1.1 Crack Licensce key 2025 FREE
utfefguu
 
SciPy 2025 - Packaging a Scientific Python Project
Henry Schreiner
 
Agentic Automation Journey Series Day 2 – Prompt Engineering for UiPath Agents
klpathrudu
 
4K Video Downloader Plus Pro Crack for MacOS New Download 2025
bashirkhan333g
 
MiniTool Partition Wizard 12.8 Crack License Key LATEST
hashhshs786
 

Hexagonal architecture for java applications