Spring Framework 5.0 Preview & Roadmap: Juergen Hoeller
Spring Framework 5.0 Preview & Roadmap: Juergen Hoeller
0
Preview & Roadmap
Juergen Hoeller
Spring Framework Lead
Pivotal
Unless otherwise indicated, these slides are 2013-2016 Pivotal Software, Inc. and licensed under a
1 Unless otherwise indicated, these slides are 2013-2016 Pivotal Software, Inc. and licensed under a
Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
On our way to 5.0
First up: 4.3
Unless otherwise indicated, these slides are 2013-2016 Pivotal Software, Inc. and licensed under a
2 Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
Spring Framework 4.3
Unless otherwise indicated, these slides are 2013-2016 Pivotal Software, Inc. and licensed under a
3 Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
The State of the Art: Component Classes
@Service
@Lazy
public class MyBookAdminService implements BookAdminService {
// @Autowired
public MyBookAdminService(AccountRepository repo) {
...
}
@Transactional
public BookUpdate updateBook(Addendum addendum) {
...
}
}
Unless otherwise indicated, these slides are 2013-2016 Pivotal Software, Inc. and licensed under a
4 Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
Configuration Classes with Autowired Constructors
@Configuration
public class MyBookAdminConfig {
// @Autowired
public MyBookAdminService(DataSource bookAdminDataSource) {
this.bookAdminDataSource = bookAdminDataSource;
}
@Bean
public BookAdminService myBookAdminService() {
MyBookAdminService service = new MyBookAdminService();
service.setDataSource(this.bookAdminDataSource);
return service;
}
}
Unless otherwise indicated, these slides are 2013-2016 Pivotal Software, Inc. and licensed under a
5 Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
Refined MVC Controller Declarations
@Controller
@CrossOrigin
public class MyRestController {
@RequestMapping(path="/books/{id}", method=GET)
public Book findBook(@PathVariable long id) {
return this.bookAdminService.findBook(id);
}
@RequestMapping(path="/books/new", method=POST)
public void newBook(@Valid Book book) {
this.bookAdminService.storeBook(book);
}
}
Unless otherwise indicated, these slides are 2013-2016 Pivotal Software, Inc. and licensed under a
6 Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
Precomposed Annotations for MVC Controllers
@RestController
@CrossOrigin
public class MyRestController {
@GetMapping("/books/{id}")
public Book findBook(@PathVariable long id) {
return this.bookAdminService.findBook(id);
}
@PostMapping("/books/new")
public void newBook(@Valid Book book) {
this.bookAdminService.storeBook(book);
}
}
Unless otherwise indicated, these slides are 2013-2016 Pivotal Software, Inc. and licensed under a
7 Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
Themes for 5.0:
JDK 9, HTTP/2, Reactive
Unless otherwise indicated, these slides are 2013-2016 Pivotal Software, Inc. and licensed under a
8 Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
Spring Framework 5.0
Unless otherwise indicated, these slides are 2013-2016 Pivotal Software, Inc. and licensed under a
9 Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
JDK 8+ Baseline
Spring 5.x: use of Java 8 features in the framework's own core codebase
lambdas, method references, default methods in interfaces
able to expose JDK 8 API types in core interfaces and classes:
java.util.Optional, java.util.function, java.util.stream
Unless otherwise indicated, these slides are 2013-2016 Pivotal Software, Inc. and licensed under a
10 Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
Comprehensive JDK 9 Support
Unless otherwise indicated, these slides are 2013-2016 Pivotal Software, Inc. and licensed under a
11 Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
Using Jigsaw with Spring
Spring Framework jars coming with Jigsaw metadata out of the box
internally declaring module-info for each jar
module my.app.db {
requires java.sql;
requires spring.jdbc;
}
Unless otherwise indicated, these slides are 2013-2016 Pivotal Software, Inc. and licensed under a
12 Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
The Importance of HTTP/2 (RFC 7540)
Unless otherwise indicated, these slides are 2013-2016 Pivotal Software, Inc. and licensed under a
13 Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
Spring 5 and HTTP/2
Unless otherwise indicated, these slides are 2013-2016 Pivotal Software, Inc. and licensed under a
14 Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
The Importance of Reactive Architectures
Unless otherwise indicated, these slides are 2013-2016 Pivotal Software, Inc. and licensed under a
15 Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
Reactive Streams Specification
Minimal API
Publisher + Subscriber/Subscription for backpressure support
repackaged into JDK 9 as java.util.concurrent.Flow
Unless otherwise indicated, these slides are 2013-2016 Pivotal Software, Inc. and licensed under a
16 Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
Reactive Web Endpoints in Spring
Unless otherwise indicated, these slides are 2013-2016 Pivotal Software, Inc. and licensed under a
17 Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
Reactive Web Controller with RxJava Observable
@Controller
public class MyReactiveWebController {
@RequestMapping("/capitalize")
public Observable<Person> capitalize(Observable<Person> persons) {
return persons.map(person -> {
person.setName(person.getName().toUpperCase());
return person;
}
}
}
Unless otherwise indicated, these slides are 2013-2016 Pivotal Software, Inc. and licensed under a
18 Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
Reactive Web Controller with Reactor Flux
@Controller
public class MyReactiveWebController {
@RequestMapping("/capitalize")
public Flux<Person> capitalize(Flux<Person> persons) {
return persons.map(person -> {
person.setName(person.getName().toUpperCase());
return person;
}
}
}
Unless otherwise indicated, these slides are 2013-2016 Pivotal Software, Inc. and licensed under a
19 Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
Reactive Web Controller with Repository Interop
@Controller
public class MyReactiveWebController {
@Autowired
private MyRepository<Person> repository;
@RequestMapping("/insert")
public Mono<Void> insert(Flux<Person> persons) {
return this.repository.insert(persons);
}
}
Unless otherwise indicated, these slides are 2013-2016 Pivotal Software, Inc. and licensed under a
20 Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
Reactive Infrastructure All Around
Unless otherwise indicated, these slides are 2013-2016 Pivotal Software, Inc. and licensed under a
21 Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
Summary
Spring Framework 4.3 (May 2016)
Programming model refinements on JDK 6/7/8
Unless otherwise indicated, these slides are 2013-2016 Pivotal Software, Inc. and licensed under a
22 Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/