New in Spring Framework 5.0: Functional Web Framework
- 2. © 2017 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
- 4. © 2017 Pivotal
...but there are downsides
•“Magic”
•No link between data and behavior
•Reflection
•Performance
•Type Erasure
- 5. © 2017 Pivotal
Design Goals
•Functional Style
•java.util.function
•java.util.stream
•More library; less framework
•Explicit
•Customizable
•No reflection
- 8. © 2017 Pivotal
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>)
- 9. © 2017 Pivotal
Pure Functions
•Same result given same arguments
•No Limit side effects
•Application boundaries
•Testability
•Cacheability
•Parallelization
- 20. © 2017 Pivotal
Running Router Functions
• RouterFunction as @Bean in @EnableWebFlux class
•Convert RouterFunction to HttpHandler
•Reactor Netty
•Tomcat
•Servlet 3.1+
•Undertow
- 22. © 2017 Pivotal
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
- 23. © 2017 Pivotal
Q & A
Resources
•Sample: https://github.com/poutsma/web-function-sample
•Blog post: https://spring.io/blog/2016/09/22/new-in-spring-5-
functional-web-framework
•Kotlin: https://speakerdeck.com/sdeleuze/functional-web-
applications-with-spring-and-kotlin
•Reactor: http://projectreactor.io/learn