Skip to content

Commit c42d44a

Browse files
committed
Polishing and documentation fixes
1 parent 5471d6a commit c42d44a

File tree

8 files changed

+48
-57
lines changed

8 files changed

+48
-57
lines changed

spring-web-reactive/src/main/java/org/springframework/web/reactive/function/server/support/ServerRequestWrapper.java

Lines changed: 28 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -39,115 +39,117 @@
3939
import org.springframework.web.server.WebSession;
4040

4141
/**
42-
* Implementation of the {@link ServerRequest} interface that can be subclassed to adapt the request to a
43-
* {@link HandlerFunction handler function}. All methods default to calling through to the wrapped request.
42+
* Implementation of the {@link ServerRequest} interface that can be subclassed
43+
* to adapt the request to a {@link HandlerFunction handler function}.
44+
* All methods default to calling through to the wrapped request.
4445
*
4546
* @author Arjen Poutsma
4647
* @since 5.0
4748
*/
4849
public class ServerRequestWrapper implements ServerRequest {
4950

50-
private final ServerRequest request;
51+
private final ServerRequest delegate;
5152

5253

5354
/**
5455
* Create a new {@code RequestWrapper} that wraps the given request.
55-
*
56-
* @param request the request to wrap
56+
* @param delegate the request to wrap
5757
*/
58-
public ServerRequestWrapper(ServerRequest request) {
59-
Assert.notNull(request, "'request' must not be null");
60-
this.request = request;
58+
public ServerRequestWrapper(ServerRequest delegate) {
59+
Assert.notNull(delegate, "Delegate must not be null");
60+
this.delegate = delegate;
6161
}
6262

63+
6364
/**
6465
* Return the wrapped request.
6566
*/
6667
public ServerRequest request() {
67-
return this.request;
68+
return this.delegate;
6869
}
6970

7071
@Override
7172
public HttpMethod method() {
72-
return this.request.method();
73+
return this.delegate.method();
7374
}
7475

7576
@Override
7677
public URI uri() {
77-
return this.request.uri();
78+
return this.delegate.uri();
7879
}
7980

8081
@Override
8182
public String path() {
82-
return this.request.path();
83+
return this.delegate.path();
8384
}
8485

8586
@Override
8687
public Headers headers() {
87-
return this.request.headers();
88+
return this.delegate.headers();
8889
}
8990

9091
@Override
9192
public <T> T body(BodyExtractor<T, ? super ServerHttpRequest> extractor) {
92-
return this.request.body(extractor);
93+
return this.delegate.body(extractor);
9394
}
9495

9596
@Override
9697
public <T> T body(BodyExtractor<T, ? super ServerHttpRequest> extractor, Map<String, Object> hints) {
97-
return this.request.body(extractor, hints);
98+
return this.delegate.body(extractor, hints);
9899
}
99100

100101
@Override
101102
public <T> Mono<T> bodyToMono(Class<? extends T> elementClass) {
102-
return this.request.bodyToMono(elementClass);
103+
return this.delegate.bodyToMono(elementClass);
103104
}
104105

105106
@Override
106107
public <T> Flux<T> bodyToFlux(Class<? extends T> elementClass) {
107-
return this.request.bodyToFlux(elementClass);
108+
return this.delegate.bodyToFlux(elementClass);
108109
}
109110

110111
@Override
111112
public <T> Optional<T> attribute(String name) {
112-
return this.request.attribute(name);
113+
return this.delegate.attribute(name);
113114
}
114115

115116
@Override
116117
public Optional<String> queryParam(String name) {
117-
return this.request.queryParam(name);
118+
return this.delegate.queryParam(name);
118119
}
119120

120121
@Override
121122
public List<String> queryParams(String name) {
122-
return this.request.queryParams(name);
123+
return this.delegate.queryParams(name);
123124
}
124125

125126
@Override
126127
public String pathVariable(String name) {
127-
return this.request.pathVariable(name);
128+
return this.delegate.pathVariable(name);
128129
}
129130

130131
@Override
131132
public Map<String, String> pathVariables() {
132-
return this.request.pathVariables();
133+
return this.delegate.pathVariables();
133134
}
134135

135136
@Override
136137
public Mono<WebSession> session() {
137-
return this.request.session();
138+
return this.delegate.session();
138139
}
139140

141+
140142
/**
141-
* Implementation of the {@link Headers} interface that can be subclassed to adapt the headers to a
142-
* {@link HandlerFunction handler function}. All methods default to calling through to the wrapped headers.
143+
* Implementation of the {@code Headers} interface that can be subclassed
144+
* to adapt the headers to a {@link HandlerFunction handler function}.
145+
* All methods default to calling through to the wrapped headers.
143146
*/
144147
public static class HeadersWrapper implements ServerRequest.Headers {
145148

146149
private final Headers headers;
147150

148151
/**
149152
* Create a new {@code HeadersWrapper} that wraps the given request.
150-
*
151153
* @param headers the headers to wrap
152154
*/
153155
public HeadersWrapper(Headers headers) {

spring-web-reactive/src/main/java/org/springframework/web/reactive/socket/adapter/AbstractListenerWebSocketSession.java

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2016 the original author or authors.
2+
* Copyright 2002-2017 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -40,7 +40,7 @@
4040
* event-listener WebSocket APIs (e.g. Java WebSocket API JSR-356, Jetty,
4141
* Undertow) and Reactive Streams.
4242
*
43-
* <p>Also an implementation of {@link Subscriber<Void>} so it can be used as
43+
* <p>Also an implementation of {@code Subscriber&lt;Void&gt;} so it can be used as
4444
* the completion subscriber for session handling
4545
*
4646
* @author Violeta Georgieva
@@ -80,7 +80,7 @@ public AbstractListenerWebSocketSession(T delegate, String id, HandshakeInfo han
8080
}
8181

8282
/**
83-
* Alternative constructor with completion {@link Mono<Void>} to propagate
83+
* Alternative constructor with completion {@code Mono&lt;Void&gt;} to propagate
8484
* the session completion (success or error) (for client-side use).
8585
*/
8686
public AbstractListenerWebSocketSession(T delegate, String id, HandshakeInfo handshakeInfo,
@@ -232,6 +232,7 @@ void handleMessage(WebSocketMessage webSocketMessage) {
232232
}
233233
}
234234

235+
235236
protected final class WebSocketSendProcessor extends AbstractListenerWriteProcessor<WebSocketMessage> {
236237

237238
private volatile boolean isReady = true;
@@ -243,20 +244,17 @@ protected boolean write(WebSocketMessage message) throws IOException {
243244

244245
@Override
245246
protected void releaseData() {
246-
if (logger.isTraceEnabled()) {
247-
logger.trace("releaseData: " + this.currentData);
248-
}
249247
this.currentData = null;
250248
}
251249

252250
@Override
253251
protected boolean isDataEmpty(WebSocketMessage message) {
254-
return message.getPayload().readableByteCount() == 0;
252+
return (message.getPayload().readableByteCount() == 0);
255253
}
256254

257255
@Override
258256
protected boolean isWritePossible() {
259-
return this.isReady && this.currentData != null;
257+
return (this.isReady && this.currentData != null);
260258
}
261259

262260
/**
@@ -269,4 +267,4 @@ public void setReadyToSend(boolean ready) {
269267
}
270268
}
271269

272-
}
270+
}

spring-web-reactive/src/main/java/org/springframework/web/reactive/socket/adapter/AbstractWebSocketSession.java

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2016 the original author or authors.
2+
* Copyright 2002-2017 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -19,8 +19,6 @@
1919
import java.nio.charset.StandardCharsets;
2020
import java.util.function.Function;
2121

22-
import org.apache.commons.logging.Log;
23-
import org.apache.commons.logging.LogFactory;
2422
import org.reactivestreams.Publisher;
2523
import reactor.core.publisher.Flux;
2624
import reactor.core.publisher.Mono;
@@ -42,9 +40,6 @@
4240
*/
4341
public abstract class AbstractWebSocketSession<T> implements WebSocketSession {
4442

45-
protected final Log logger = LogFactory.getLog(getClass());
46-
47-
4843
private final T delegate;
4944

5045
private final String id;

spring-web-reactive/src/main/java/org/springframework/web/reactive/socket/adapter/RxNettyWebSocketSession.java

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2016 the original author or authors.
2+
* Copyright 2002-2017 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -31,7 +31,6 @@
3131
import rx.RxReactiveStreams;
3232

3333
import org.springframework.core.io.buffer.NettyDataBufferFactory;
34-
import org.springframework.util.Assert;
3534
import org.springframework.web.reactive.socket.CloseStatus;
3635
import org.springframework.web.reactive.socket.HandshakeInfo;
3736
import org.springframework.web.reactive.socket.WebSocketMessage;
@@ -53,27 +52,26 @@ public class RxNettyWebSocketSession extends NettyWebSocketSessionSupport<WebSoc
5352
public static final String FRAME_AGGREGATOR_NAME = "websocket-frame-aggregator";
5453

5554

56-
public RxNettyWebSocketSession(WebSocketConnection conn, HandshakeInfo info,
57-
NettyDataBufferFactory factory) {
58-
55+
public RxNettyWebSocketSession(WebSocketConnection conn, HandshakeInfo info, NettyDataBufferFactory factory) {
5956
super(conn, info, factory);
6057
}
6158

6259

6360
/**
64-
* Inserts an {@link WebSocketFrameAggregator} after the
61+
* Insert an {@link WebSocketFrameAggregator} after the
6562
* {@code WebSocketFrameDecoder} for receiving full messages.
6663
* @param channel the channel for the session
6764
* @param frameDecoderName the name of the WebSocketFrame decoder
6865
*/
6966
public RxNettyWebSocketSession aggregateFrames(Channel channel, String frameDecoderName) {
7067
ChannelPipeline pipeline = channel.pipeline();
7168
if (pipeline.context(FRAME_AGGREGATOR_NAME) != null) {
72-
logger.trace("WebSocketFrameAggregator already registered.");
7369
return this;
7470
}
7571
ChannelHandlerContext frameDecoder = pipeline.context(frameDecoderName);
76-
Assert.notNull(frameDecoder, "WebSocketFrameDecoder not found: " + frameDecoderName);
72+
if (frameDecoder == null) {
73+
throw new IllegalArgumentException("WebSocketFrameDecoder not found: " + frameDecoderName);
74+
}
7775
ChannelHandler frameAggregator = new WebSocketFrameAggregator(DEFAULT_FRAME_MAX_SIZE);
7876
pipeline.addAfter(frameDecoder.name(), FRAME_AGGREGATOR_NAME, frameAggregator);
7977
return this;

spring-web-reactive/src/main/java/org/springframework/web/reactive/socket/server/WebSocketService.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2016 the original author or authors.
2+
* Copyright 2002-2017 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -13,6 +13,7 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
*/
16+
1617
package org.springframework.web.reactive.socket.server;
1718

1819
import reactor.core.publisher.Mono;
@@ -29,7 +30,7 @@
2930
*
3031
* @author Rossen Stoyanchev
3132
* @since 5.0
32-
* @see org.springframework.web.reactive.socket.server.support.HandshakeWebSocketService;
33+
* @see org.springframework.web.reactive.socket.server.support.HandshakeWebSocketService
3334
*/
3435
public interface WebSocketService {
3536

spring-web/src/main/java/org/springframework/http/HttpHeaders.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -442,7 +442,6 @@ public List<MediaType> getAccept() {
442442
/**
443443
* Set the acceptable language ranges, as specified by the
444444
* {@literal Accept-Language} header.
445-
* @see Locale.LanguageRange
446445
* @since 5.0
447446
*/
448447
public void setAcceptLanguage(List<Locale.LanguageRange> languages) {
@@ -464,7 +463,6 @@ public void setAcceptLanguage(List<Locale.LanguageRange> languages) {
464463
* {@link #getAcceptLanguageAsLocale()} or if you need to filter based on
465464
* a list of supporeted locales you can pass the returned list to
466465
* {@link Locale#filter(List, Collection)}.
467-
* @see Locale.LanguageRange
468466
* @since 5.0
469467
*/
470468
public List<Locale.LanguageRange> getAcceptLanguage() {

src/asciidoc/data-access.adoc

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6101,7 +6101,7 @@ Spring's O/X mapping operates through two global interfaces: the `Marshaller` an
61016101
with relative ease, with little or no changes required on the classes that do the
61026102
marshalling. This approach has the additional benefit of making it possible to do XML
61036103
marshalling with a mix-and-match approach (e.g. some marshalling performed using JAXB,
6104-
other using XMLBeans) in a non-intrusive fashion, leveraging the strength of each
6104+
other using Castor) in a non-intrusive fashion, leveraging the strength of each
61056105
technology.
61066106

61076107

@@ -6374,9 +6374,8 @@ preamble of the XML configuration file. Note the 'oxm' related text below:
63746374
Currently, the following tags are available:
63756375

63766376
* <<oxm-jaxb2-xsd, `jaxb2-marshaller`>>
6377-
* <<oxm-xmlbeans-xsd, `xmlbeans-marshaller`>>
6378-
* <<oxm-castor-xsd, `castor-marshaller`>>
63796377
* <<oxm-jibx-xsd, `jibx-marshaller`>>
6378+
* <<oxm-castor-xsd, `castor-marshaller`>>
63806379

63816380
Each tag will be explained in its respective marshaller's section. As an example though,
63826381
here is how the configuration of a JAXB2 marshaller might look like:

src/asciidoc/integration.adoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2099,7 +2099,7 @@ details of how it is represented as a JMS message.
20992099
The sandbox currently includes a `MapMessageConverter` which uses reflection to convert
21002100
between a JavaBean and a `MapMessage`. Other popular implementation choices you might
21012101
implement yourself are Converters that use an existing XML marshalling package, such as
2102-
JAXB, Castor, XMLBeans, or XStream, to create a `TextMessage` representing the object.
2102+
JAXB, Castor or XStream, to create a `TextMessage` representing the object.
21032103

21042104
To accommodate the setting of a message's properties, headers, and body that can not be
21052105
generically encapsulated inside a converter class, the `MessagePostProcessor` interface

0 commit comments

Comments
 (0)