Polishing and documentation fixes

This commit is contained in:
Juergen Hoeller
2017-01-17 12:47:04 +01:00
parent 5471d6a465
commit c42d44a42c
8 changed files with 48 additions and 57 deletions

View File

@@ -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> T body(BodyExtractor<T, ? super ServerHttpRequest> extractor) {
return this.request.body(extractor);
return this.delegate.body(extractor);
}
@Override
public <T> T body(BodyExtractor<T, ? super ServerHttpRequest> extractor, Map<String, Object> hints) {
return this.request.body(extractor, hints);
return this.delegate.body(extractor, hints);
}
@Override
public <T> Mono<T> bodyToMono(Class<? extends T> elementClass) {
return this.request.bodyToMono(elementClass);
return this.delegate.bodyToMono(elementClass);
}
@Override
public <T> Flux<T> bodyToFlux(Class<? extends T> elementClass) {
return this.request.bodyToFlux(elementClass);
return this.delegate.bodyToFlux(elementClass);
}
@Override
public <T> Optional<T> attribute(String name) {
return this.request.attribute(name);
return this.delegate.attribute(name);
}
@Override
public Optional<String> queryParam(String name) {
return this.request.queryParam(name);
return this.delegate.queryParam(name);
}
@Override
public List<String> 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<String, String> pathVariables() {
return this.request.pathVariables();
return this.delegate.pathVariables();
}
@Override
public Mono<WebSession> 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) {

View File

@@ -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.
*
* <p>Also an implementation of {@link Subscriber<Void>} so it can be used as
* <p>Also an implementation of {@code Subscriber&lt;Void&gt;} so it can be used as
* the completion subscriber for session handling
*
* @author Violeta Georgieva
@@ -80,7 +80,7 @@ public abstract class AbstractListenerWebSocketSession<T> extends AbstractWebSoc
}
/**
* Alternative constructor with completion {@link Mono<Void>} to propagate
* Alternative constructor with completion {@code Mono&lt;Void&gt;} 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<T> extends AbstractWebSoc
}
}
protected final class WebSocketSendProcessor extends AbstractListenerWriteProcessor<WebSocketMessage> {
private volatile boolean isReady = true;
@@ -243,20 +244,17 @@ public abstract class AbstractListenerWebSocketSession<T> 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<T> extends AbstractWebSoc
}
}
}
}

View File

@@ -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<T> implements WebSocketSession {
protected final Log logger = LogFactory.getLog(getClass());
private final T delegate;
private final String id;

View File

@@ -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<WebSoc
public static final String FRAME_AGGREGATOR_NAME = "websocket-frame-aggregator";
public RxNettyWebSocketSession(WebSocketConnection conn, HandshakeInfo info,
NettyDataBufferFactory factory) {
public RxNettyWebSocketSession(WebSocketConnection conn, HandshakeInfo info, NettyDataBufferFactory factory) {
super(conn, info, factory);
}
/**
* Inserts an {@link WebSocketFrameAggregator} after the
* Insert an {@link WebSocketFrameAggregator} after the
* {@code WebSocketFrameDecoder} for receiving full messages.
* @param channel the channel for the session
* @param frameDecoderName the name of the WebSocketFrame decoder
@@ -69,11 +66,12 @@ public class RxNettyWebSocketSession extends NettyWebSocketSessionSupport<WebSoc
public RxNettyWebSocketSession aggregateFrames(Channel channel, String frameDecoderName) {
ChannelPipeline pipeline = channel.pipeline();
if (pipeline.context(FRAME_AGGREGATOR_NAME) != null) {
logger.trace("WebSocketFrameAggregator already registered.");
return this;
}
ChannelHandlerContext frameDecoder = pipeline.context(frameDecoderName);
Assert.notNull(frameDecoder, "WebSocketFrameDecoder not found: " + frameDecoderName);
if (frameDecoder == null) {
throw new IllegalArgumentException("WebSocketFrameDecoder not found: " + frameDecoderName);
}
ChannelHandler frameAggregator = new WebSocketFrameAggregator(DEFAULT_FRAME_MAX_SIZE);
pipeline.addAfter(frameDecoder.name(), FRAME_AGGREGATOR_NAME, frameAggregator);
return this;

View File

@@ -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.
@@ -13,6 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.web.reactive.socket.server;
import reactor.core.publisher.Mono;
@@ -29,7 +30,7 @@ import org.springframework.web.server.ServerWebExchange;
*
* @author Rossen Stoyanchev
* @since 5.0
* @see org.springframework.web.reactive.socket.server.support.HandshakeWebSocketService;
* @see org.springframework.web.reactive.socket.server.support.HandshakeWebSocketService
*/
public interface WebSocketService {

View File

@@ -442,7 +442,6 @@ public class HttpHeaders implements MultiValueMap<String, String>, Serializable
/**
* Set the acceptable language ranges, as specified by the
* {@literal Accept-Language} header.
* @see Locale.LanguageRange
* @since 5.0
*/
public void setAcceptLanguage(List<Locale.LanguageRange> languages) {
@@ -464,7 +463,6 @@ public class HttpHeaders implements MultiValueMap<String, String>, 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<Locale.LanguageRange> getAcceptLanguage() {

View File

@@ -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:
* <<oxm-jaxb2-xsd, `jaxb2-marshaller`>>
* <<oxm-xmlbeans-xsd, `xmlbeans-marshaller`>>
* <<oxm-castor-xsd, `castor-marshaller`>>
* <<oxm-jibx-xsd, `jibx-marshaller`>>
* <<oxm-castor-xsd, `castor-marshaller`>>
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:

View File

@@ -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