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
dbt民主化とLLMによる開発ブースト ~ AI Readyな分析サイクルを目指して ~
yoshyum
2
240
LINEヤフー データグループ紹介
lycorp_recruit_jp
0
1.7k
コードの90%をAIが書く世界で何が待っているのか / What awaits us in a world where 90% of the code is written by AI
rkaga
50
32k
AIプログラマーDevinは PHPerの夢を見るか?
shinyasaita
1
180
なぜ「共通化」を考え、失敗を繰り返すのか
rinchoku
1
620
Team operations that are not burdened by SRE
kazatohiei
1
290
20250628_非エンジニアがバイブコーディングしてみた
ponponmikankan
0
600
「Cursor/Devin全社導入の理想と現実」のその後
saitoryc
0
680
deno-redisの紹介とJSRパッケージの運用について (toranoana.deno #21)
uki00a
0
170
NPOでのDevinの活用
codeforeveryone
0
650
Goで作る、開発・CI環境
sin392
0
190
Result型で“失敗”を型にするPHPコードの書き方
kajitack
4
560
Featured
See All Featured
Easily Structure & Communicate Ideas using Wireframe
afnizarnur
194
16k
Automating Front-end Workflow
addyosmani
1370
200k
Sharpening the Axe: The Primacy of Toolmaking
bcantrill
44
2.4k
個人開発の失敗を避けるイケてる考え方 / tips for indie hackers
panda_program
107
19k
Rails Girls Zürich Keynote
gr2m
94
14k
What's in a price? How to price your products and services
michaelherold
246
12k
BBQ
matthewcrist
89
9.7k
Refactoring Trust on Your Teams (GOTO; Chicago 2020)
rmw
34
3.1k
"I'm Feeling Lucky" - Building Great Search Experiences for Today's Users (#IAC19)
danielanewman
229
22k
Speed Design
sergeychernyshev
32
1k
The Power of CSS Pseudo Elements
geoffreycrofte
77
5.8k
Product Roadmaps are Hard
iamctodd
PRO
54
11k
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