From c42d44a42c83ee44d91f99bf41072bdc62cb9d48 Mon Sep 17 00:00:00 2001 From: Juergen Hoeller Date: Tue, 17 Jan 2017 12:47:04 +0100 Subject: [PATCH] Polishing and documentation fixes --- .../server/support/ServerRequestWrapper.java | 54 ++++++++++--------- .../AbstractListenerWebSocketSession.java | 16 +++--- .../adapter/AbstractWebSocketSession.java | 7 +-- .../adapter/RxNettyWebSocketSession.java | 14 +++-- .../socket/server/WebSocketService.java | 5 +- .../org/springframework/http/HttpHeaders.java | 2 - src/asciidoc/data-access.adoc | 5 +- src/asciidoc/integration.adoc | 2 +- 8 files changed, 48 insertions(+), 57 deletions(-) diff --git a/spring-web-reactive/src/main/java/org/springframework/web/reactive/function/server/support/ServerRequestWrapper.java b/spring-web-reactive/src/main/java/org/springframework/web/reactive/function/server/support/ServerRequestWrapper.java index d1a74e400d..4193edc7d5 100644 --- a/spring-web-reactive/src/main/java/org/springframework/web/reactive/function/server/support/ServerRequestWrapper.java +++ b/spring-web-reactive/src/main/java/org/springframework/web/reactive/function/server/support/ServerRequestWrapper.java @@ -39,107 +39,110 @@ import org.springframework.web.reactive.function.server.ServerRequest; import org.springframework.web.server.WebSession; /** - * Implementation of the {@link ServerRequest} interface that can be subclassed to adapt the request to a - * {@link HandlerFunction handler function}. All methods default to calling through to the wrapped request. + * Implementation of the {@link ServerRequest} interface that can be subclassed + * to adapt the request to a {@link HandlerFunction handler function}. + * All methods default to calling through to the wrapped request. * * @author Arjen Poutsma * @since 5.0 */ public class ServerRequestWrapper implements ServerRequest { - private final ServerRequest request; + private final ServerRequest delegate; /** * Create a new {@code RequestWrapper} that wraps the given request. - * - * @param request the request to wrap + * @param delegate the request to wrap */ - public ServerRequestWrapper(ServerRequest request) { - Assert.notNull(request, "'request' must not be null"); - this.request = request; + public ServerRequestWrapper(ServerRequest delegate) { + Assert.notNull(delegate, "Delegate must not be null"); + this.delegate = delegate; } + /** * Return the wrapped request. */ public ServerRequest request() { - return this.request; + return this.delegate; } @Override public HttpMethod method() { - return this.request.method(); + return this.delegate.method(); } @Override public URI uri() { - return this.request.uri(); + return this.delegate.uri(); } @Override public String path() { - return this.request.path(); + return this.delegate.path(); } @Override public Headers headers() { - return this.request.headers(); + return this.delegate.headers(); } @Override public T body(BodyExtractor extractor) { - return this.request.body(extractor); + return this.delegate.body(extractor); } @Override public T body(BodyExtractor extractor, Map hints) { - return this.request.body(extractor, hints); + return this.delegate.body(extractor, hints); } @Override public Mono bodyToMono(Class elementClass) { - return this.request.bodyToMono(elementClass); + return this.delegate.bodyToMono(elementClass); } @Override public Flux bodyToFlux(Class elementClass) { - return this.request.bodyToFlux(elementClass); + return this.delegate.bodyToFlux(elementClass); } @Override public Optional attribute(String name) { - return this.request.attribute(name); + return this.delegate.attribute(name); } @Override public Optional queryParam(String name) { - return this.request.queryParam(name); + return this.delegate.queryParam(name); } @Override public List queryParams(String name) { - return this.request.queryParams(name); + return this.delegate.queryParams(name); } @Override public String pathVariable(String name) { - return this.request.pathVariable(name); + return this.delegate.pathVariable(name); } @Override public Map pathVariables() { - return this.request.pathVariables(); + return this.delegate.pathVariables(); } @Override public Mono session() { - return this.request.session(); + return this.delegate.session(); } + /** - * Implementation of the {@link Headers} interface that can be subclassed to adapt the headers to a - * {@link HandlerFunction handler function}. All methods default to calling through to the wrapped headers. + * Implementation of the {@code Headers} interface that can be subclassed + * to adapt the headers to a {@link HandlerFunction handler function}. + * All methods default to calling through to the wrapped headers. */ public static class HeadersWrapper implements ServerRequest.Headers { @@ -147,7 +150,6 @@ public class ServerRequestWrapper implements ServerRequest { /** * Create a new {@code HeadersWrapper} that wraps the given request. - * * @param headers the headers to wrap */ public HeadersWrapper(Headers headers) { diff --git a/spring-web-reactive/src/main/java/org/springframework/web/reactive/socket/adapter/AbstractListenerWebSocketSession.java b/spring-web-reactive/src/main/java/org/springframework/web/reactive/socket/adapter/AbstractListenerWebSocketSession.java index b8a1d4a282..658fc6cf60 100644 --- a/spring-web-reactive/src/main/java/org/springframework/web/reactive/socket/adapter/AbstractListenerWebSocketSession.java +++ b/spring-web-reactive/src/main/java/org/springframework/web/reactive/socket/adapter/AbstractListenerWebSocketSession.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2016 the original author or authors. + * Copyright 2002-2017 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -40,7 +40,7 @@ import org.springframework.web.reactive.socket.WebSocketSession; * event-listener WebSocket APIs (e.g. Java WebSocket API JSR-356, Jetty, * Undertow) and Reactive Streams. * - *

Also an implementation of {@link Subscriber} so it can be used as + *

Also an implementation of {@code Subscriber<Void>} so it can be used as * the completion subscriber for session handling * * @author Violeta Georgieva @@ -80,7 +80,7 @@ public abstract class AbstractListenerWebSocketSession extends AbstractWebSoc } /** - * Alternative constructor with completion {@link Mono} to propagate + * Alternative constructor with completion {@code Mono<Void>} to propagate * the session completion (success or error) (for client-side use). */ public AbstractListenerWebSocketSession(T delegate, String id, HandshakeInfo handshakeInfo, @@ -232,6 +232,7 @@ public abstract class AbstractListenerWebSocketSession extends AbstractWebSoc } } + protected final class WebSocketSendProcessor extends AbstractListenerWriteProcessor { private volatile boolean isReady = true; @@ -243,20 +244,17 @@ public abstract class AbstractListenerWebSocketSession extends AbstractWebSoc @Override protected void releaseData() { - if (logger.isTraceEnabled()) { - logger.trace("releaseData: " + this.currentData); - } this.currentData = null; } @Override protected boolean isDataEmpty(WebSocketMessage message) { - return message.getPayload().readableByteCount() == 0; + return (message.getPayload().readableByteCount() == 0); } @Override protected boolean isWritePossible() { - return this.isReady && this.currentData != null; + return (this.isReady && this.currentData != null); } /** @@ -269,4 +267,4 @@ public abstract class AbstractListenerWebSocketSession extends AbstractWebSoc } } -} \ No newline at end of file +} diff --git a/spring-web-reactive/src/main/java/org/springframework/web/reactive/socket/adapter/AbstractWebSocketSession.java b/spring-web-reactive/src/main/java/org/springframework/web/reactive/socket/adapter/AbstractWebSocketSession.java index b47787c5f6..ef68b17d13 100644 --- a/spring-web-reactive/src/main/java/org/springframework/web/reactive/socket/adapter/AbstractWebSocketSession.java +++ b/spring-web-reactive/src/main/java/org/springframework/web/reactive/socket/adapter/AbstractWebSocketSession.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2016 the original author or authors. + * Copyright 2002-2017 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -19,8 +19,6 @@ package org.springframework.web.reactive.socket.adapter; import java.nio.charset.StandardCharsets; import java.util.function.Function; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; import org.reactivestreams.Publisher; import reactor.core.publisher.Flux; import reactor.core.publisher.Mono; @@ -42,9 +40,6 @@ import org.springframework.web.reactive.socket.WebSocketSession; */ public abstract class AbstractWebSocketSession implements WebSocketSession { - protected final Log logger = LogFactory.getLog(getClass()); - - private final T delegate; private final String id; diff --git a/spring-web-reactive/src/main/java/org/springframework/web/reactive/socket/adapter/RxNettyWebSocketSession.java b/spring-web-reactive/src/main/java/org/springframework/web/reactive/socket/adapter/RxNettyWebSocketSession.java index d352831af0..53d6477a83 100644 --- a/spring-web-reactive/src/main/java/org/springframework/web/reactive/socket/adapter/RxNettyWebSocketSession.java +++ b/spring-web-reactive/src/main/java/org/springframework/web/reactive/socket/adapter/RxNettyWebSocketSession.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2016 the original author or authors. + * Copyright 2002-2017 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -31,7 +31,6 @@ import rx.Observable; import rx.RxReactiveStreams; import org.springframework.core.io.buffer.NettyDataBufferFactory; -import org.springframework.util.Assert; import org.springframework.web.reactive.socket.CloseStatus; import org.springframework.web.reactive.socket.HandshakeInfo; import org.springframework.web.reactive.socket.WebSocketMessage; @@ -53,15 +52,13 @@ public class RxNettyWebSocketSession extends NettyWebSocketSessionSupport, Serializable /** * Set the acceptable language ranges, as specified by the * {@literal Accept-Language} header. - * @see Locale.LanguageRange * @since 5.0 */ public void setAcceptLanguage(List languages) { @@ -464,7 +463,6 @@ public class HttpHeaders implements MultiValueMap, Serializable * {@link #getAcceptLanguageAsLocale()} or if you need to filter based on * a list of supporeted locales you can pass the returned list to * {@link Locale#filter(List, Collection)}. - * @see Locale.LanguageRange * @since 5.0 */ public List getAcceptLanguage() { diff --git a/src/asciidoc/data-access.adoc b/src/asciidoc/data-access.adoc index f184183fe9..6531bcea0f 100644 --- a/src/asciidoc/data-access.adoc +++ b/src/asciidoc/data-access.adoc @@ -6101,7 +6101,7 @@ Spring's O/X mapping operates through two global interfaces: the `Marshaller` an with relative ease, with little or no changes required on the classes that do the marshalling. This approach has the additional benefit of making it possible to do XML marshalling with a mix-and-match approach (e.g. some marshalling performed using JAXB, -other using XMLBeans) in a non-intrusive fashion, leveraging the strength of each +other using Castor) in a non-intrusive fashion, leveraging the strength of each technology. @@ -6374,9 +6374,8 @@ preamble of the XML configuration file. Note the 'oxm' related text below: Currently, the following tags are available: * <> -* <> -* <> * <> +* <> Each tag will be explained in its respective marshaller's section. As an example though, here is how the configuration of a JAXB2 marshaller might look like: diff --git a/src/asciidoc/integration.adoc b/src/asciidoc/integration.adoc index e5c488b30e..8cddd53386 100644 --- a/src/asciidoc/integration.adoc +++ b/src/asciidoc/integration.adoc @@ -2099,7 +2099,7 @@ details of how it is represented as a JMS message. The sandbox currently includes a `MapMessageConverter` which uses reflection to convert between a JavaBean and a `MapMessage`. Other popular implementation choices you might implement yourself are Converters that use an existing XML marshalling package, such as -JAXB, Castor, XMLBeans, or XStream, to create a `TextMessage` representing the object. +JAXB, Castor or XStream, to create a `TextMessage` representing the object. To accommodate the setting of a message's properties, headers, and body that can not be generically encapsulated inside a converter class, the `MessagePostProcessor` interface