Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
New in Spring 5: Functional Web Framework
Search
Sponsored
·
SiteGround - Reliable hosting with speed, security, and support you can count on.
→
Arjen Poutsma
October 27, 2016
Programming
190
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
New in Spring 5: Functional Web Framework
Slides from Dutch Spring Meetup
Arjen Poutsma
October 27, 2016
More Decks by Arjen Poutsma
See All by Arjen Poutsma
Designing an API
poutsma
1
790
Other Decks in Programming
See All in Programming
GKE で Pod の見方を変えたら、スケールアウト時の挙動を真に捉えられた話
stkk
0
130
SREの越境 / SRE Collaboration
y0hgi
2
260
JPUG勉強会 OSSデータベースの内部構造を理解しよう(第2回)
oga5
0
260
更なる可用性を求めて、5年間運用したKotlinのアプリケーションをGoでリプレイスする話
ken_tunc
0
300
巨大モノリシックアプリ モダン化大作戦
ktcryomm
1
1.1k
What We Talk About When We Talk About XP
m_seki
2
660
新卒PdEのリアル
ryu1013
1
510
XHTMLが残したもの
yosuke_furukawa
PRO
2
830
Snowflakeで業務アプリを作ろう。 Snowflakeのアプリ機能解説&実践ガイド
ayumu_yamaguchi
1
280
すこし踏み込む CancellationToken
htkym
2
620
Starting & Sustaining Code-Based E2E Testing for Non-Coding QA Teams( #jasstniigata )
teyamagu
PRO
1
450
標準パッケージに uuid が追加された 背景から見る Go らしい意思決定 / go_127_uuid_decision
convto
5
7.6k
Featured
See All Featured
Chrome DevTools: State of the Union 2024 - Debugging React & Beyond
addyosmani
10
1.3k
The Invisible Side of Design
smashingmag
301
52k
Done Done
chrislema
186
16k
The Success of Rails: Ensuring Growth for the Next 100 Years
eileencodes
47
8.3k
Leveraging Curiosity to Care for An Aging Population
cassininazir
1
500
The Cult of Friendly URLs
andyhume
79
7k
SEOcharity - Dark patterns in SEO and UX: How to avoid them and build a more ethical web
sarafernandez
0
280
Leveraging LLMs for student feedback in introductory data science courses - posit::conf(2025)
minecr
1
400
Code Review Best Practice
trishagee
74
20k
We Have a Design System, Now What?
morganepeng
55
8.3k
Fight the Zombie Pattern Library - RWD Summit 2016
marcelosomers
234
18k
世界の人気アプリ100個を分析して見えたペイウォール設計の心得
akihiro_kokubo
PRO
74
42k
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