Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
New in Spring 5: Functional Web Framework
Search
Arjen Poutsma
October 27, 2016
Programming
0
180
New in Spring 5: Functional Web Framework
Slides from Dutch Spring Meetup
Arjen Poutsma
October 27, 2016
Tweet
Share
More Decks by Arjen Poutsma
See All by Arjen Poutsma
Designing an API
poutsma
1
780
Other Decks in Programming
See All in Programming
メッセージングを利用して時間的結合を分離しよう #phperkaigi
kajitack
3
310
Agentic AI: Evolution oder Revolution
mobilelarson
PRO
0
190
クライアントワークでSREをするということ。あるいは事業会社におけるSREと同じこと・違うこと
nnaka2992
1
360
Claude Code Skill入門
mayahoney
0
420
存在論的プログラミング: 時間と存在を記述する
koriym
4
460
Fundamentals of Software Engineering In the Age of AI
therealdanvega
2
290
Codexに役割を持たせる 他のAIエージェントと組み合わせる実務Tips
o8n
4
1.4k
PHP でエミュレータを自作して Ubuntu を動かそう
m3m0r7
PRO
2
140
Laravel Nightwatchの裏側 - Laravel公式Observabilityツールを支える設計と実装
avosalmon
1
210
[PHPerKaigi 2026]PHPerKaigi2025の企画CodeGolfが最高すぎて社内で内製して半年運営して得た内製と運営の知見
ikezoemakoto
0
280
SourceGeneratorのマーカー属性問題について
htkym
0
210
「効かない!」依存性注入(DI)を活用したAPI Platformのエラーハンドリング奮闘記
mkmk884
0
170
Featured
See All Featured
Unlocking the hidden potential of vector embeddings in international SEO
frankvandijk
0
210
Navigating Algorithm Shifts & AI Overviews - #SMXNext
aleyda
1
1.2k
The Curse of the Amulet
leimatthew05
1
10k
Site-Speed That Sticks
csswizardry
13
1.1k
The Web Performance Landscape in 2024 [PerfNow 2024]
tammyeverts
12
1.1k
sira's awesome portfolio website redesign presentation
elsirapls
0
200
Raft: Consensus for Rubyists
vanstee
141
7.4k
Context Engineering - Making Every Token Count
addyosmani
9
770
Self-Hosted WebAssembly Runtime for Runtime-Neutral Checkpoint/Restore in Edge–Cloud Continuum
chikuwait
0
410
Leading Effective Engineering Teams in the AI Era
addyosmani
9
1.8k
Code Review Best Practice
trishagee
74
20k
Fashionably flexible responsive web design (full day workshop)
malarkey
408
66k
Transcript
New in Spring 5: Functional Web Framework Arjen Poutsma Pivotal
About Arjen • Twenty years of experience in Enterprise Software
Development • Joined SpringSource in 2005 • Development lead of Spring Web Services, Spring MVC, Spring Scala • Working on Spring 5
I do like annotations...
...but there are downsides • “Magic” • No clear link
between annotation and behavior • Runtime handling • Reflection
Design Goals • Functional Style • java.util.function • java.util.stream •
More library; less framework • Explicit • Customizable • No reflection
Functional Programming (in Java 8)
Immutability • No change after construction • Builders • Thread-safety
•e.g. String •toUpperCase() •StringBuilder
First-class Functions • Functions as first-class citizens • Functions as
arguments • Functions as return value • Reusability •e.g. String •indexOf(char) vs indexOf(Predicate<Char>)
Pure Functions • Same result given same arguments • No
Limit side effects • Application boundaries • Testability • Cacheability • Parallelization
Who likes this?
Function<ServerRequest, ServerResponse<T>> HandlerFunction h(Req) ! Res
ServerRequest • Similar to RequestEntity • Immutable • Headers •
Optional<MediaType> contentType() • List<String> header(String) • Body • Mono<T> bodyToMono(Class<T>)
ServerResponse • Similar to ResponseEntity • Immutable w/ Builder •
Headers • lastModified(ZonedDateTime) • header(String, String...) • Body • body(Publisher<T>, Class<T>)
Demo
Function<Request, Optional<HandlerFunction<T>> RouterFunction r(Req) ! ⇢ h(Req) ! Res ;
RequestPredicate Predicate<Request>
RequestPredicates • Common predicates • path • headers (Content-Type, Accept)
• Build (compose) your own!
Demo
BiFunction<Request,HandlerFunction<T>, Response<R>> HandlerFilterFunction f ( Req, h ( x ))
! Res
Demo
Running a Server • Convert RouterFunction to HttpHandler • HttpHandler
runs • Reactor Netty • RxNetty • Servlet 3.1 • Undertow
Demo
Summary • Handler functions handle request by returning a response
• Router functions route to handler functions • Router functions can be filtered by filter functions • Router functions can be run in a reactive web runtime
Who likes this?
Q & A