Reactive programming

Use functional programming code in the frame - lambda expressions and stream flows.

Reactive programming support

Reactive programming is one of the most important features SpringFramework5.0. Reactive programming provides an alternative style of programming, focusing on building the application to respond to events. SpringFramework5 a response flow (defined response of the language-neutral API attempts) and Reactor (provided by Spring Pivotal team Reactive Stream Java implementation), for its own use as well as many of its core API.

Spring Web Reactive existing (and very popular) in spring-webmvc module in a new spring-web-reactive module next Spring Web MVC in. Note that in Spring5, the traditional support SpringMVC run on Servlet3.1, or support JavaEE7 server.

Functional web frame

In addition to the responsive function, Spring5 also provides a functional framework Web. It provides the use of functional programming style characteristics defined endpoint. The framework introduces two basic components: HandlerFunction and RouterFunction.

HandlerFunction represents the received request and generates a response function. RouterFunction replaced @RequestMapping comment. It is requested for the received route to the handler. E.g:

RouterFunction<String> route =  route(GET("/hello-world"),
request -> Response.ok().body(fromObject("Hello World")));

Guess you like

Origin blog.csdn.net/beyondxiaohu15/article/details/83114084