What’s New in Spring?

Dave Syer, 2017

Agenda

  • What’s happening in Spring?
  • How does it all fit together?

Spring Layer Diagram

spring-layers-4

Spring Layers Detail

spring-layers-io-4

Spring Today

May 2017:

  • Reactor: Aluminium-SR2 (3.0.7.RELEASE)
  • Framework: 4.3.8.RELEASE
  • Data: Ingalls-SR3
  • Boot: 1.5.3.RELEASE
  • Cloud: Dalston.RELEASE

Spring 5.0

  • Baseline: JDK 8, Servlet 3.1, JMS 2.0, JPA 2.1
  • Performance improvements
  • Functional bean configuration
  • Reactive: WebFlux, Router Functions
  • Support for JUnit 5, JDK 9 and HTTP/2
  • Kotlin

Spring Layers Detail

spring-layers-io

Imperative style (Blocking)

try {
    Person p = personRepository.findById(id);
    handle(p);
} catch	(IOException ex)	{
    error(ex);
}
interface PersonRepository {
     Person findById(String	id);
     List<Person> findAll();
     void save(Person	person);
}

Functional style (Non-blocking)

Mono<Person> p = personRepository.findById(id)
             .map(this::handle)
             .doOnError(this::error);
interface PersonRepository {
     Mono<Person> findById(String id);
     Flux<Person> findAll();
     Mono<Void> save(Person	person);
}

 
 

  • Neutral to Latency
  • Event based

Spring MVC

@GetMapping("/users/{id}")
User getById(@PathVariable String id)	{
    return this.userRepository.findOne(id);
}

Spring WebFlux

@GetMapping("/users/{id}")
Mono<User> getById(@PathVariable String id)	{
    return this.userRepository.findOne(id);
}

Router Function

@Bean
public RouterFunction<?> userEndpoints() {
    return route(GET("/users/{id}"), request ->
        ok().body(
            repository.findOne(request.pathVariable("id")),
            User.class
        ));
}

Spring WebClient

WebClient client = WebClient.create();

Mono<GithubUser> githubUser = client
    .get()
    .uri("https://api.github.com/users/{username}", username)
    .retrieve()
    .bodyToMono(GithubUser.class);

Spring WebClient Scatter Gather

Mono<TwitterUser> twitterUser = client
    .get()
    .uri("https://api.twitter.com/1.1/users/show.json?screen_name={username}", username)
    .retrieve()
    .bodyToMono(TwitterUser.class);

return githubUser.and(twitterUser,
    (github, twitter)-> new AppUser(github, twitter));

Reactive Spring

More for scalability and stability than for speed

Servlets and Web MVC are not going to go away.

Spring Releases

Project Release Timeline

Reactor

Bismuth

 

Framework

5.0.0.RELEASE

2017Q2

Data

Kay

 

Security

5.0.0.RELEASE

 

Integration

5.0.0.RELEASE

 

…​

 

 

Boot

2.0.0.RELEASE

2017Q4

Cloud

Finchley.RELEASE

 

Spring Cloud

  • Dalston: 2017Q1, Spring Boot 1.5.x
  • Edgware: 2017Q3, Spring Boot 1.5.x

    • Spring Cloud Dataflow

  • Finchley: 2017Q4: Spring Boot 2.0.x

    • Spring Cloud Function
    • Spring Cloud Gateway

Spring Cloud

  • Dalston: 2017Q1, Spring Boot 1.5.x
  • Edgware: 2017Q3, Spring Boot 1.5.x

    • Spring Cloud Dataflow
    • Spring Cloud Function

  • Finchley: 2017Q4: Spring Boot 2.0.x

    • Spring Cloud Gateway

/