Commit Graph

671 Commits

Author SHA1 Message Date
Sebastien Deleuze
300f2cd2dd Polish RedirectView
Issue: SPR-14534
2016-12-01 17:27:29 +01:00
Juergen Hoeller
8cb7e026e2 HttpRequestPathHelper in new web.server.support package
In general, web.util is supposed to remain lowest-level, not depending on any other web.* package. Since web.client also has a support package, a corresponding web.server.support package seemed appropriate for a helper class depending on ServerWebExchange in web.server itself.
2016-11-30 11:12:06 +01:00
Rossen Stoyanchev
122334c37a RxNettyWebSocketSession creates PONG frame correctly 2016-11-28 16:48:31 -05:00
Sebastien Deleuze
2e994f7dc3 Add RedirectView to Spring Web Reactive
Main differences with the Spring MVC original implementation:
 - Default redirect HTTP code is 303 See Other since we can assume
   all HTTP clients support HTTP 1.1 in 2016
 - No more http10Compatible property, use statusCode instead
 - By default the redirect is relative to the context path
 - A builder allow to set various properties if needed
 - In UrlBasedViewResolver, a Function<String, RedirectView>
   redirectViewProvider property allows to customize RedirectView
   instances in a flexible way

Issue: SPR-14534
2016-11-28 19:23:42 +01:00
Rossen Stoyanchev
25b95efad9 Shared ReactiveAdapterRegistry in web reactive config 2016-11-28 12:54:48 -05:00
Rossen Stoyanchev
5651c2180e Further refactoring of ReactiveAdapter/Registry
Simplify getAdapterFrom/To into a single getAdapter method that looks
for an exact match by type first and then isAssignableFrom.

Also expose shortcut methods in ReactiveAdapter to minimize the need
for access to the ReactiveTypeDescriptor.

Issue: SPR-14902
2016-11-28 12:43:22 -05:00
Rossen Stoyanchev
52096ab8b9 Refactor ReactiveAdapter hierarchy
Collapse ReactiveAdapter hierarchy into a single class that simply
delegates to functions for converting to/from a Publisher.

A private ReactorAdapter extension automaticlaly wraps adapted,  "raw"
Publisher's as Flux or Mono depending on the semantics of the target
reactive type.

Issue: SPR-14902
2016-11-27 21:41:07 -05:00
Rossen Stoyanchev
2e7d16df04 Improved reactive type descriptor support
ReactiveTypeDescriptor is now a top-level type with named constructors.
It also contains and provides a getter for the actual type.

Issue: SPR-14902
2016-11-27 21:41:07 -05:00
Sebastien Deleuze
a143b57d4b Polish Kotlin nullable support
This commit polishes Kotlin nullable support by reusing
MethodParameter#isOptional() instead of adding a new
MethodParameter#isNullable() method, adds
Kotlin tests and introduces Spring Web Reactive
support.

Issue: SPR-14165
2016-11-24 18:28:50 +01:00
Stephane Maldini
85a4e5065d Add log4j2 config to spring-web-reactiv 2016-11-23 13:16:54 -05:00
Rossen Stoyanchev
637b6387ea Starting point for reactive WebSocket support
Includes basic abstractions and an RxNetty support to start.

Issue: SPR-14527
2016-11-22 16:24:02 -05:00
Rossen Stoyanchev
a224874b43 Improve resolution of multi-value async model attrs
Multi-value async attributes like Flux and Observable in the model
are treated with Collection semantics and resolved to Mono<List<?>>
prior to rendering.
2016-11-16 14:18:09 -05:00
Brian Clozel
cb44f2746e Prevent resource transformation of gzipped CSS files
When resolved through the `GzipResourceResolver`, CSS files can be
resolved as their pre-gzipped variant, if a ".gz" file is present in the
configured resource locations.

Such resources are gzipped and thus should not be transformed by
`CssLinkResourceTransformer`s, since rewriting those would need to
uncompress/transform/recompress. This would lead to poorer performances
than resolving plain resources and delegating compression to the
container.

This commit checks for `GzippedResource` instances in
`CssLinkResourceTransformer` and avoids processing them.

Issue: SPR-14773
2016-11-16 10:26:09 +01:00
Arjen Poutsma
6de062d198 Fix RouterFunction.andRoute()
Fixed RouterFunction.andRoute signature.

Issue: SPR-14904
2016-11-14 17:17:05 +01:00
Juergen Hoeller
dda9762072 Moved WebExchangeDataBinder to web.bind.support (alongside WebRequestDataBinder)
Issue: SPR-14542
2016-11-08 11:01:58 +01:00
Juergen Hoeller
f0be79e0a1 Promoted BindingContext to web.reactive root (since HandlerResult requires it there)
Issue: SPR-14542
2016-11-08 09:33:49 +01:00
Rossen Stoyanchev
6b73700f74 Reactive support for @ModelAttribute methods
Issue: SPR-14542
2016-11-07 15:03:15 +02:00
Rossen Stoyanchev
e59dcedfee BindingResult inserted before rendering
Issue: SPR-14542
2016-11-07 15:03:15 +02:00
Rossen Stoyanchev
ae003e89c1 HandlerResult provides access to BindingContext
Issue: SPR-14542
2016-11-07 15:03:15 +02:00
Rossen Stoyanchev
6abd4d5ff5 Async model attributes resolved before rendering
Issue: SPR-14542
2016-11-07 15:03:15 +02:00
Rossen Stoyanchev
d163240ed4 Reactive support for Errors argument
Issue: SPR-14542
2016-11-07 15:02:13 +02:00
Rossen Stoyanchev
816e32872a Reactive support for @ModelAttribute argument
Issue: SPR-14542
2016-11-07 15:02:13 +02:00
Rossen Stoyanchev
3230ca6d39 Add ConcurrentModel
This commit adds a Model implementation based on ConcurrentHashMap for
use in Spring Web Reactive.

Issue: SPR-14542
2016-11-07 15:02:13 +02:00
Sebastien Deleuze
b447d7dbe6 Rename expectErrorMatch() to expectErrorMatches() 2016-11-04 17:15:03 +01:00
Sebastien Deleuze
b338e6d7aa Rename expectErrorWith() to expectErrorMatch() 2016-11-04 16:14:09 +01:00
Rossen Stoyanchev
475b876f08 Add ResponseEntity test 2016-11-04 13:18:53 +02:00
Rossen Stoyanchev
c430402872 Improve support for Mono<ResponseEntity<?>>
If the body class is not resolvable from the return type and there is
a body instance we now fall back on the class of the body instance.

Issue: SPR-14877
2016-11-04 12:51:00 +02:00
Juergen Hoeller
84d3808b3b Upgrade to Mockito 2.2
Issue: SPR-14880
2016-11-03 22:53:35 +01:00
Brian Clozel
95abd18fea Fix Exception Handling result handler resolution
Prior to this commit, the wrong `HandlerResultHandler` could be
resolved when handling exceptions; this could happen only if the
original handler and exception handler had different signatures:

```
Publisher<String> originalHandler() { ... }

@ExceptionHandler(MyCustomException.class)
ResponseEntity<Mono<String>> handleException() { ... }
```

In that case, the `ResponseBodyResultHandler` would be used when
handling exceptions instead of the `ResponseEntityResultHandler`.

This commit ensures that the `HandlerResult` returned by the exception
handler is used to resolve the `HandlerResultHandler`. The latter will
process the result and use it to write to the HTTP response.

Issue: SPR-14876
2016-11-03 17:13:54 +01:00
Brian Clozel
0006957274 Support ResponseStatus on reactive controllers
This commit adds support for `@ResponseStatus` annotations on reactive
controller methods. `HandlerResultHandler`s implementations now
set the status on the `ServerWebExchange`, if and only if the
invocation of the controller method succeeded.

Issue: SPR-14830
2016-11-03 12:00:30 +01:00
Sebastien Deleuze
8705df502d Rename Verifier to StepVerifier
Issue: SPR-14800
2016-11-02 19:01:40 +01:00
Rossen Stoyanchev
388e173ba3 Fix NPE in custom @InitBinder resolver initialization
Issue: SPR-14869
2016-11-02 10:00:19 +02:00
Rossen Stoyanchev
6c098b3301 Polish 2016-11-02 09:53:27 +02:00
Sebastien Deleuze
b4b7c278df Update tests according to latest reactor-test changes
- ScriptedSubscriber has been renamed to Verifier
 - The Publisher is passed to create() instead of verify()
 - No more need to specify the generic type explicitly
 - Version is now sync with reactor-core

Issue: SPR-14800
2016-11-01 22:28:50 +01:00
Rossen Stoyanchev
99cacaa72d Improve reactive support for access to Principal
The method to access the Principal from the ServerWebExchange is now
a Mono<Principal> (rather than Optional<Principal>).

There is also support for Principal as a controller method argument.

Issue: SPR-14680, SPR-14865
2016-11-01 18:44:14 +02:00
Rossen Stoyanchev
e1a382b61f Polish 2016-11-01 18:15:11 +02:00
Rossen Stoyanchev
33dbbce182 ApplicationContext-based HttpHandler setup
This commit adds support for detecting the target WebHandler along with
WebFilters, WebExceptionHandlers, and other spring-web reactive
strategies in an ApplicationContext.

WebReactiveConfigurationSupport has @Bean factory methods for
DispatcherHandler and ResponseStatusExceptionHandler.

WebHttpHandlerBuilder has a static factory method that initializes the
builder from an ApplicationContext. This method is also used in the
DispatcherHandler#toHttpHandler(ApplicationContext) shortcut method.

Issue: SPR-14837
2016-10-31 20:45:26 +02:00
Rossen Stoyanchev
3da0295c12 Support for reactive controller @InitBinder methods
Issue: SPR-14543
2016-10-31 16:11:44 +02:00
Rossen Stoyanchev
0b76b6d7e9 Sync semantics for WebExchangeDataBinder factory
The createBinder method in BindingContext now returns the binder
instance rather than a Mono with the expectation that binder
initialization (e.g. @InitBinder) does not require blocking.

Issue: SPR-14543
2016-10-31 16:11:44 +02:00
Rossen Stoyanchev
b55ab1119e Sync argument resolution and HandlerMethod invocation
HandlerMethodArgumentResolver is a non-blocking contract, however only
implementations that read the request body require blocking.

This commit introduces SyncMethodArgumentResolver as an extension of
the non-blocking contract that allows synchronous implementations to
use synchronous argument resolution.

There is also a SyncInvocableHandlerMethod extension that uses only
sync argument resolvers and allows a synchronous invocation.

Issue: SPR-14543
2016-10-31 16:11:44 +02:00
Juergen Hoeller
ac80ac6f8b Consistent instanceof/casting of Class references 2016-10-30 21:40:27 +01:00
Juergen Hoeller
7627c38695 Exceptions thrown from @ExceptionHandler methods logged at warn level (instead of debug)
Issue: SPR-14861
2016-10-30 21:40:20 +01:00
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