Commit Graph

693 Commits

Author SHA1 Message Date
Rossen Stoyanchev
d6895aa098 Consistently extend WebSocketHandlerAdapterSupport
The WebSocketHandler adapters for all runtimes now extend
WebSocketHandlerAdapterSupport, which now also exposes
a shared DataBufferFactory property initialized from the response.

Issue: SPR-14527
2016-12-12 17:56:48 -05:00
Rossen Stoyanchev
5829e1c141 Polish method and field declaration order 2016-12-12 17:56:48 -05:00
Rossen Stoyanchev
f32a41933e Polish 2016-12-12 17:56:48 -05:00
Rossen Stoyanchev
db5bc4a24e Minor refactoring of suspend/resumeReceiving
suspend/resumeReceiving in the AbstractListenerWebSocketSession are
now abstract methods. In Tomcat/Jetty these methods are no-op
implementations that are then coupled with a buffering strategy via
Flux#onBackpressureBuffer. In Undertow they rely on flow control for
receiving WebSocket messages.

Issue: SPR-14527
2016-12-12 17:56:48 -05:00
Violeta Georgieva
08edec006b Refactor AbstractListenerWebSocketSession
- Added suspended flag to indicate whether the ReceivePublisher
is able to process the incoming messages.
- Use buffer strategy for the incoming messages.

Issue: SPR-14527
2016-12-12 17:56:48 -05:00
Rossen Stoyanchev
d1411d9fc2 Simple refactorings in AbstractListenerWebSocketSessionSupport
Dropped "Support" from the name since it not only provides support
methods but actually implements WebSocketSession.

Renamed inner classes:
WebSocketMessagePublisher -> WebSocketReceivePublisher
WebSocketMessageProcessor -> WebSocketSendProcessor

Add protected getter for sendProcessor.

Reduce scoping:
WebSocketReceivePublisher -> private
WebSocketSendProcessor -> protected
WebSocketSendProcessor#setReady -> public (class is still protected)

A few more method name alignments and Javadoc updates.

Issue: SPR-14527
2016-12-12 17:56:48 -05:00
Rossen Stoyanchev
fe7ee5ff33 Rename "Request/ResponseBody" publisher/processor
AbstractRequestBodyPublisher and AbstractResponseBodyProcessor are now
used for WebSocket messages too and have been renamed more generally to
AbstractListenerReadPublisher and AbstractListenerWriteProcessor.

Issue: SPR-14527
2016-12-12 17:56:48 -05:00
Violeta Georgieva
a2053a516e Initial reactive, WebSocket Jetty support
Issue: SPR-14527
2016-12-12 17:56:47 -05:00
Violeta Georgieva
80040ef43b Initial reactive, WebSocket Undertow support
Issue: SPR-14527
2016-12-12 17:56:47 -05:00
Violeta Georgieva
46b39f4372 Initial reactive, WebSocket Tomcat support
Issue: SPR-14527
2016-12-12 17:56:47 -05:00
Brian Clozel
933f1501e8 Do not include URL hash in resource paths
When getting the lookup path of a resource, both query params and hashes
should be removed from the request path.

This commit fixes the public path resolution for paths like
`/resources/main.svg#icon-hamburgermenu`.

Issue: SPR-14928
2016-12-12 15:14:50 +01:00
Juergen Hoeller
66e6b35e9f Reliable content length check in ResourceHandlerFunctionTests 2016-12-12 09:57:57 +01:00
bedrin
8315a4033f Add consumes attribute to @GetMapping
Issue: SPR-14988
2016-12-07 17:45:43 -05:00
Rossen Stoyanchev
1b0e95d7d8 Support for RequestUpgradeStrategy + Lifecycle
Issue: SPR-15527
2016-12-07 17:03:56 -05:00
Rossen Stoyanchev
2c2de82ffb Flush after each WebSocket message by default
Issue: SPR-14527
2016-12-06 17:08:30 -05:00
Rossen Stoyanchev
c097c0284a Reactor Netty WebSocket server-side support
Issue: SPR-14527
2016-12-06 17:08:30 -05:00
Rossen Stoyanchev
46f2aafdc0 Extract Netty WebSocket session + adapter base classes
Issue: SPR-14527
2016-12-06 17:08:30 -05:00
Arjen Poutsma
30bd3d8736 Allow use of WebFilters in RouterFunction
This commit changes RouterFunctions.toHttpHandler to return
HttpWebHandlerAdapter (instead of HttpHandler), so that WebFilters and
WebExceptionHandler can be applied to it.

Issue: SPR-14979
2016-12-06 17:12:40 +01:00
Rossen Stoyanchev
953f7d40cf Filter out hanging tests realted to Reactor Netty
Issue: SPR-14975
2016-12-05 16:03:12 -05:00
Rossen Stoyanchev
55d4268448 ReactiveAdapterRegistry is a bean 2016-12-02 20:41:39 -05:00
Rossen Stoyanchev
8ad95b09e8 ReactiveContext and BindStatus in spring-web-reactive
Issue: SPR-14533
2016-12-02 11:48:54 -05:00
Arjen Poutsma
136b33bc4a Allow serving static files from RouterFunctions
This commit adds the ability to serve Resources (static files) through a
RouterFunction. Two methods have been added to RouterFunctions: one that
exposes a given directory given a path pattern, and a generic method
that requires a lookup function.

Issue: SPR-14913
2016-12-02 15:47:26 +01:00
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