Commit Graph

594 Commits

Author SHA1 Message Date
Sam Brannen
a04b6c5142 Clean up warnings in Gradle build 2016-10-28 16:25:29 +02:00
Juergen Hoeller
1b0b269370 DefaultServerResponseBuilder uses Reactor's new thenEmpty method (fixing deprecation error) 2016-10-27 17:41:33 +02:00
Sebastien Deleuze
2075932780 Add support for RxJava 2 Maybe type
Issue: SPR-14843
2016-10-25 16:49:22 +02:00
Arjen Poutsma
20dec61d04 Refactored BodyInserters
This commit introduces a couple of changes to BodyInserters:

- Refactored writeWithMessageWriters into BiFunction
- BodyInserters.fromResource now uses ResourceMessagewriter from context
- BodyInserters.fromServerSentEvents now uses SseHttpMessageWriter from context
2016-10-25 11:11:58 +02:00
Brian Clozel
99a3210859 Refactor tests with ScriptedSubscriber
Reactor recently added the `ScriptedSubscriber` in its new
`reactor-addons` module. This `Subscriber` revissits the previous
`TestSubscriber` with many improvements, including:

* scripting each expectation
* builder API that guides you until the final verification step
* virtual time support

This commit refactor all existing tests to use this new
infrastructure and removed the `TestSubscriber` implementation.

Issue: SPR-14800
2016-10-25 10:44:44 +02:00
Brian Clozel
61cf9fdda5 Remove factory methods from WebReactiveConfigurer
This commit removes factory methods for `RequestMappingHandlerMapping`
and `RequestMappingHandlerAdapter` from `WebReactiveConfigurer`.
`WebReactiveConfigurer` should promote only common customizations;
those factory methods should be overridden when extending
`WebReactiveConfigurationSupport`, in advanced configuration scenarios.
2016-10-21 21:19:32 +02:00
Arjen Poutsma
08931950f4 Add byte[] encoder and decoder
This commit adds a ByteArrayDecoder and ByteArrayEncoder.
2016-10-21 12:34:06 +02:00
Juergen Hoeller
3726c6f18d Polishing 2016-10-21 12:26:27 +02:00
Rossen Stoyanchev
b92d541ba0 Add contextPath support for reactive web applications
This commit introduces support for running multiple HttpHandler's under
distinct context paths which effectively allows running multiple
applications on the same server. ContextPathIntegrationTests contains
an example of two applications with different context paths.

In order to support this the HttpHandler adapters for all supported
runtimes now have a common base class HttpHandlerAdapterSupport
which has two constructor choices -- one with a single HttpHandler and
another with a Map<String, HttpHandler>.

Note that in addition to the contextPath under which an HttpHandler is
configured there may also be a "native" contextPath under which the
native runtime adapter is configured (e.g. Servlet containers). In such
cases the contextPath is a combination of the native contextPath and
the contextPath assigned to the HttpHandler. See for example
HttpHandlerAdapterSupportTests.

Issue: SPR-14726
2016-10-20 17:42:38 -04:00
Arjen Poutsma
fa9cc1eb1a Add bodyToMono/bodyToFlux convenience methods
This commit adds a bodyToMono and bodyToFlux convenience method to
ClientResponse/ServerRequest, similar to the body(Publisher) method that
is on ClientRequest/ServerResponse.
2016-10-20 16:58:30 +02:00
Arjen Poutsma
59e4326989 Various improvements to web.reactive.function
This commit introduces the following changes to web.reactive.function:

- Added RouterFunction.andRoute(), a combination of RouterFunction.and()
with RouterFunctions.route()
- ServerRequest.pathVariable() returns String instead of
Optional<String>. An exception is thrown if the variable is not present.
- Added HandlerFilterFunction.andThen and HandlerFilterFunction.apply()
2016-10-20 15:11:16 +02:00
Sebastien Deleuze
921bf5fb70 Use the official RxJava to Reactive Streams adapter
This commit removes the usage of Reactor adapters (about to
be moved from Reactor Core to a new Reactor Adapter module).
Instead, RxReactiveStreams is now used for adapting RxJava
1 and Flowable methods are used for RxJava 2.

Issue: SPR-14824
2016-10-20 15:08:05 +02:00
Arjen Poutsma
7e907c1e83 Align web.reactive.function with WebClient
This commit changes web.reactive.function to reflect the introduction of
the new WebClient. Changes include:

- Request -> ServerRequest
- Response -> ServerResponse
- FilterFunction -> HandlerFilterFunction
- StrategiesSupplier -> HandlerStrategies
2016-10-20 12:35:52 +02:00
Arjen Poutsma
0cfb6b37f2 Align Reactive WebClient with web.reactive.function
This commit refactors the web client to be more similar to
web.reactive.function. Changes include:

- Refactor ClientWebRequest to immutable ClientRequest with builder and
   support for BodyInserters.
- Introduce ClientResponse which exposes headers, status, and support
   for reading from the body with BodyExtractors.
- Removed ResponseErrorHandler, in favor of having a ClientResponse
   with "error" status code (i.e. 4xx or 5xx). Also removed
   WebClientException and subclasses.
- Refactored WebClientConfig to WebClientStrategies.
- Refactored ClientHttpRequestInterceptor to ExchangeFilterFunction.
- Removed ClientWebRequestPostProcessor in favor of
   ExchangeFilterFunction, which allows for asynchronous execution.

Issue: SPR-14827
2016-10-20 12:35:23 +02:00
Arjen Poutsma
dc1926a861 Moved BodyExtractor and BodyInserter to http.codec
This commit moves the web.reactive.function.[BodyInserter|BodyExtractor]
to http.codec, so that they can be used from the client as well.

Furthermore, it parameterized both inserter and extractor over
ReactiveHttpOutputMessage and ReactiveHttpInputMessage respectively, so
that they can be limited to only be used on the client or server.
2016-10-20 11:44:01 +02:00
Rossen Stoyanchev
72397e3505 Polish
Issue: SPR-14798
2016-10-19 16:30:52 -04:00
Sebastien Deleuze
50f2cda009 Better encapsulation for CORS default permit configuration
This commit also improves CorsRegistration Javadoc.

Issue: SPR-14798
2016-10-19 15:31:22 -04:00
Rossen Stoyanchev
8619ad9d9a Add tests to DelegatingWebReactiveConfigurationTests 2016-10-14 21:06:42 -04:00
Rossen Stoyanchev
c7fb851e5a Polish 2016-10-14 18:11:16 -04:00
Rossen Stoyanchev
44717af0e5 Update order of method in WebReactiveConfigurer 2016-10-14 18:02:00 -04:00
Rossen Stoyanchev
7f6eaef305 Improve WebReactiveConfigurerComposite 2016-10-14 17:55:40 -04:00
Brian Clozel
3533024ab8 Add EnableWebReactive + WebReactiveConfigurer
This commit improves the existing web reactive configuration
infrastructure with the following changes:

* renamed `WebReactiveConfiguration` to
`WebReactiveConfigurationSupport` and is is no longer a Configuration
class
* created the `WebReactiveConfigurer` interface; Configuration classes
implementing it will augment the web reactive configuration support
* created the `DelegatingWebReactiveConfiguration` and
`WebReactiveConfigurerComposite` to effectively tie those custom-defined
configurers to the main configuration support
* created the `@EnableWebReactive` to active that support in
configuration classes

Issue: SPR-14754
2016-10-14 17:23:37 -04:00
Brian Clozel
336b4d2fb8 Polish 2016-10-13 20:57:15 +02:00
Rossen Stoyanchev
aff43c29fd BindingContext implements TypeConverter 2016-10-12 09:01:15 -04:00
Rossen Stoyanchev
8a043ae9aa Replace direct use of Validator and ConversionService
This commit replaces direct use of Validator and ConversionService in
the reactive @RequestMapping infrustructure in favor of using the
BindingContext.

Issue: SPR-14541
2016-10-11 20:53:52 -04:00
Rossen Stoyanchev
d87aa40efe Add BindingContext
This commit adds a BindingContext to be used in spring-web-reactive
@RequestMapping infrastructure (comparable to WebDataBinderFactory in
spring-web-mvc) for access to the default model, data binding,
validation, and type conversion purposes.

Issue: SPR-14541
2016-10-11 20:50:59 -04:00
Rossen Stoyanchev
cabb253269 Replace "mvc" in web rective config bean names 2016-10-11 20:20:40 -04:00
Rossen Stoyanchev
1de73b9b4f Polish 2016-10-11 20:20:40 -04:00
Rossen Stoyanchev
b28b3e8877 Add WebExchangeDataBinder
Issue: SPR-14541
2016-10-11 20:20:40 -04:00
Brian Clozel
7ae729480e Resolve absolute resource links in ResourceTransformers
This commit adapts the fix for SPR-14597 commited to spring-webmvc to
the spring-web-reactive module.

Issue: SPR-14597
2016-10-11 17:45:34 +02:00
Rossen Stoyanchev
1f6f0dc101 Add getHandler in reactive AbstractHandlerMapping 2016-10-10 18:00:11 -04:00
Rossen Stoyanchev
33c48e7a17 Polish reactive CORS support 2016-10-10 18:00:11 -04:00
Sebastien Deleuze
e31a2f778b Add Reactive CORS support
This is a port of Spring MVC CORS support for Spring Web Reactive:
 - CORS classes keep the same name but are in the
   web.cors.reactive package
 - CorsConfiguration is reused because not tied to Servlet API
 - CORS HandlerMapping integration is done at
   AbstractHandlerMapping level
 - AbstractUrlHandlerMapping and AbstractHandlerMethodMapping
   have been slightly modified to call
   AbstractHandlerMapping#processCorsRequest()
 - Both global CORS configuration + @CrossOrigin support have
   been implemented

Issue: SPR-14545
2016-10-10 18:00:05 -04:00
Juergen Hoeller
2fea1f7da3 Upgrade to RxJava 2.0 RC3 (as well as EhCache 3.1.3 and Hibernate ORM 5.2.3) 2016-10-05 00:04:51 +02:00
Juergen Hoeller
cfa0f6c84b Consistent final logger fields 2016-10-04 23:00:36 +02:00
Sebastien Deleuze
b91c0b3a1a Fix JSON and SSE writer registration
Issue: SPR-14748
2016-09-27 21:56:21 +02:00
Sebastien Deleuze
44ceecc8b3 Imply text/event-stream when serializing ServerSentEvent
Issue: SPR-14748
2016-09-27 09:27:33 +02:00
Juergen Hoeller
89717e1783 Reactive setup refinements 2016-09-21 11:24:20 +02:00
Brian Clozel
578af59f0c Polish byte-range resource handling 2016-09-20 23:46:21 +02:00
Juergen Hoeller
129d7bef6e Polishing 2016-09-20 22:41:20 +02:00
Juergen Hoeller
d94ce0a1b2 Avoid package dependency cycles 2016-09-20 22:41:11 +02:00
Juergen Hoeller
65e01eabf0 DispatcherHandler.toWebHandler/toHttpHandler convenience methods 2016-09-20 22:40:43 +02:00
Brian Clozel
3596e72050 Add range requests support in ResourceWebHandler
This commit handles range requests in `ResourceWebHandler`, using the
`ResourceHttpMessageWriter` configured within the handler.

This `WebHandler` will add a `HTTP_RANGE_REQUEST_HINT` writer hint
containing all the HTTP Range information of the request.

Issue: SPR-14664
2016-09-20 16:46:03 +02:00
Sebastien Deleuze
857e77eec2 Make ServerHttpMessageReader/Writer more powerful and flexible
This commit makes it possible, in addition to provide hints, to
perform additional operations with the request and the response
at ServerHttpMessageReader/Writer level.

AbstractServerHttpMessageReader/Writer now provide
convenient beforeRead/beforeWrite abstract methods for such need.

Issue: SPR-14557
2016-09-20 11:55:51 +02:00
Sebastien Deleuze
38f3d12e45 Do not provide hints for can*() methods anymore
Issue: SPR-14557
2016-09-20 11:55:51 +02:00
Arjen Poutsma
b83a6daf4b Javadoc 2016-09-20 11:19:40 +02:00
Rossen Stoyanchev
adc69097fa Fix startup exception related to ResourceWebHandler
Issue: SPR-14735
2016-09-19 21:15:42 -04:00
Arjen Poutsma
753bb854aa Rename Configuration to StrategiesSupplier 2016-09-19 12:09:19 +02:00
Arjen Poutsma
778ef02680 Rename BodyInsertor to BodyInserter 2016-09-17 16:07:00 +02:00
Arjen Poutsma
b6035ce9ae Refactor BodyInsertor
Refactor BodyInsertor to expose insertion logic directly, rather than
exposing a writer function and supplier.
2016-09-17 11:48:53 +02:00