Fix package cycle
HandshakeInfo has been promoted to the top-level socket package next to WebSocketSession which exposes it.
This commit is contained in:
@@ -13,7 +13,7 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.springframework.web.reactive.socket.adapter;
|
||||
package org.springframework.web.reactive.socket;
|
||||
|
||||
import java.net.URI;
|
||||
import java.security.Principal;
|
||||
@@ -88,20 +88,21 @@ public class WebSocketMessage {
|
||||
* </pre>
|
||||
* @see DataBufferUtils#retain(DataBuffer)
|
||||
*/
|
||||
public void retainPayload() {
|
||||
public WebSocketMessage retain() {
|
||||
DataBufferUtils.retain(this.payload);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Release the data buffer for the message payload, which is useful on
|
||||
* runtimes with pooled buffers, e.g. Netty. This is a shortcut for:
|
||||
* Release the payload {@code DataBuffer} which is useful on runtimes with
|
||||
* pooled buffers such as Netty. Effectively a shortcut for:
|
||||
* <pre>
|
||||
* DataBuffer payload = message.getPayload();
|
||||
* DataBufferUtils.release(payload);
|
||||
* </pre>
|
||||
* @see DataBufferUtils#release(DataBuffer)
|
||||
*/
|
||||
public void releasePayload() {
|
||||
public void release() {
|
||||
DataBufferUtils.release(this.payload);
|
||||
}
|
||||
|
||||
|
||||
@@ -15,9 +15,6 @@
|
||||
*/
|
||||
package org.springframework.web.reactive.socket;
|
||||
|
||||
import java.net.URI;
|
||||
import java.security.Principal;
|
||||
import java.util.Optional;
|
||||
import java.util.function.Function;
|
||||
|
||||
import org.reactivestreams.Publisher;
|
||||
@@ -26,8 +23,6 @@ import reactor.core.publisher.Mono;
|
||||
|
||||
import org.springframework.core.io.buffer.DataBuffer;
|
||||
import org.springframework.core.io.buffer.DataBufferFactory;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.web.reactive.socket.adapter.HandshakeInfo;
|
||||
|
||||
/**
|
||||
* Representation for a WebSocket session.
|
||||
@@ -64,6 +59,22 @@ public interface WebSocketSession {
|
||||
*/
|
||||
Mono<Void> send(Publisher<WebSocketMessage> messages);
|
||||
|
||||
/**
|
||||
* Close the WebSocket session with {@link CloseStatus#NORMAL}.
|
||||
*/
|
||||
default Mono<Void> close() {
|
||||
return close(CloseStatus.NORMAL);
|
||||
}
|
||||
|
||||
/**
|
||||
* Close the WebSocket session with the given status.
|
||||
* @param status the close status
|
||||
*/
|
||||
Mono<Void> close(CloseStatus status);
|
||||
|
||||
|
||||
// WebSocketMessage factory methods
|
||||
|
||||
/**
|
||||
* Factory method to create a text {@link WebSocketMessage} using the
|
||||
* {@link #bufferFactory()} for the session.
|
||||
@@ -88,17 +99,4 @@ public interface WebSocketSession {
|
||||
*/
|
||||
WebSocketMessage pongMessage(Function<DataBufferFactory, DataBuffer> payloadFactory);
|
||||
|
||||
/**
|
||||
* Close the WebSocket session with {@link CloseStatus#NORMAL}.
|
||||
*/
|
||||
default Mono<Void> close() {
|
||||
return close(CloseStatus.NORMAL);
|
||||
}
|
||||
|
||||
/**
|
||||
* Close the WebSocket session with the given status.
|
||||
* @param status the close status
|
||||
*/
|
||||
Mono<Void> close(CloseStatus status);
|
||||
|
||||
}
|
||||
|
||||
@@ -27,6 +27,7 @@ import org.springframework.core.io.buffer.DataBufferFactory;
|
||||
import org.springframework.http.server.reactive.AbstractListenerReadPublisher;
|
||||
import org.springframework.http.server.reactive.AbstractListenerWriteProcessor;
|
||||
import org.springframework.web.reactive.socket.CloseStatus;
|
||||
import org.springframework.web.reactive.socket.HandshakeInfo;
|
||||
import org.springframework.web.reactive.socket.WebSocketMessage;
|
||||
import org.springframework.web.reactive.socket.WebSocketMessage.Type;
|
||||
import org.springframework.web.reactive.socket.WebSocketSession;
|
||||
|
||||
@@ -34,6 +34,7 @@ import org.reactivestreams.Subscription;
|
||||
import org.springframework.core.io.buffer.DataBuffer;
|
||||
import org.springframework.core.io.buffer.DataBufferFactory;
|
||||
import org.springframework.web.reactive.socket.CloseStatus;
|
||||
import org.springframework.web.reactive.socket.HandshakeInfo;
|
||||
import org.springframework.web.reactive.socket.WebSocketHandler;
|
||||
import org.springframework.web.reactive.socket.WebSocketMessage;
|
||||
import org.springframework.web.reactive.socket.WebSocketMessage.Type;
|
||||
|
||||
@@ -27,6 +27,7 @@ import reactor.core.publisher.Mono;
|
||||
import org.springframework.core.io.buffer.DataBufferFactory;
|
||||
import org.springframework.util.ObjectUtils;
|
||||
import org.springframework.web.reactive.socket.CloseStatus;
|
||||
import org.springframework.web.reactive.socket.HandshakeInfo;
|
||||
import org.springframework.web.reactive.socket.WebSocketMessage;
|
||||
import org.springframework.web.reactive.socket.WebSocketSession;
|
||||
|
||||
|
||||
@@ -31,6 +31,7 @@ import reactor.core.publisher.Flux;
|
||||
import org.springframework.core.io.buffer.NettyDataBuffer;
|
||||
import org.springframework.core.io.buffer.NettyDataBufferFactory;
|
||||
import org.springframework.util.ObjectUtils;
|
||||
import org.springframework.web.reactive.socket.HandshakeInfo;
|
||||
import org.springframework.web.reactive.socket.WebSocketMessage;
|
||||
import org.springframework.web.reactive.socket.WebSocketSession;
|
||||
|
||||
|
||||
@@ -25,6 +25,7 @@ import reactor.ipc.netty.http.websocket.WebsocketOutbound;
|
||||
|
||||
import org.springframework.core.io.buffer.NettyDataBufferFactory;
|
||||
import org.springframework.web.reactive.socket.CloseStatus;
|
||||
import org.springframework.web.reactive.socket.HandshakeInfo;
|
||||
import org.springframework.web.reactive.socket.WebSocketMessage;
|
||||
import org.springframework.web.reactive.socket.WebSocketSession;
|
||||
|
||||
|
||||
@@ -26,6 +26,7 @@ import rx.RxReactiveStreams;
|
||||
|
||||
import org.springframework.core.io.buffer.NettyDataBufferFactory;
|
||||
import org.springframework.web.reactive.socket.CloseStatus;
|
||||
import org.springframework.web.reactive.socket.HandshakeInfo;
|
||||
import org.springframework.web.reactive.socket.WebSocketMessage;
|
||||
import org.springframework.web.reactive.socket.WebSocketSession;
|
||||
|
||||
|
||||
@@ -30,6 +30,7 @@ import org.reactivestreams.Subscription;
|
||||
import org.springframework.core.io.buffer.DataBuffer;
|
||||
import org.springframework.core.io.buffer.DataBufferFactory;
|
||||
import org.springframework.web.reactive.socket.CloseStatus;
|
||||
import org.springframework.web.reactive.socket.HandshakeInfo;
|
||||
import org.springframework.web.reactive.socket.WebSocketHandler;
|
||||
import org.springframework.web.reactive.socket.WebSocketMessage;
|
||||
import org.springframework.web.reactive.socket.WebSocketMessage.Type;
|
||||
|
||||
@@ -29,6 +29,7 @@ import reactor.core.publisher.Mono;
|
||||
|
||||
import org.springframework.core.io.buffer.DataBufferFactory;
|
||||
import org.springframework.web.reactive.socket.CloseStatus;
|
||||
import org.springframework.web.reactive.socket.HandshakeInfo;
|
||||
import org.springframework.web.reactive.socket.WebSocketMessage;
|
||||
import org.springframework.web.reactive.socket.WebSocketSession;
|
||||
|
||||
|
||||
@@ -32,6 +32,7 @@ import org.reactivestreams.Subscription;
|
||||
import org.springframework.core.io.buffer.DataBuffer;
|
||||
import org.springframework.core.io.buffer.DataBufferFactory;
|
||||
import org.springframework.web.reactive.socket.CloseStatus;
|
||||
import org.springframework.web.reactive.socket.HandshakeInfo;
|
||||
import org.springframework.web.reactive.socket.WebSocketHandler;
|
||||
import org.springframework.web.reactive.socket.WebSocketMessage;
|
||||
import org.springframework.web.reactive.socket.WebSocketMessage.Type;
|
||||
|
||||
@@ -29,6 +29,7 @@ import reactor.core.publisher.Mono;
|
||||
import org.springframework.core.io.buffer.DataBufferFactory;
|
||||
import org.springframework.util.ObjectUtils;
|
||||
import org.springframework.web.reactive.socket.CloseStatus;
|
||||
import org.springframework.web.reactive.socket.HandshakeInfo;
|
||||
import org.springframework.web.reactive.socket.WebSocketMessage;
|
||||
import org.springframework.web.reactive.socket.WebSocketSession;
|
||||
|
||||
|
||||
@@ -17,6 +17,7 @@ package org.springframework.web.reactive.socket.adapter;
|
||||
|
||||
import org.springframework.core.io.buffer.DataBufferFactory;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.web.reactive.socket.HandshakeInfo;
|
||||
import org.springframework.web.reactive.socket.WebSocketHandler;
|
||||
|
||||
/**
|
||||
|
||||
@@ -29,6 +29,7 @@ import org.springframework.core.io.buffer.DataBuffer;
|
||||
import org.springframework.core.io.buffer.DataBufferFactory;
|
||||
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;
|
||||
import org.springframework.web.reactive.socket.WebSocketSession;
|
||||
|
||||
|
||||
@@ -35,7 +35,7 @@ import rx.RxReactiveStreams;
|
||||
import org.springframework.core.io.buffer.NettyDataBufferFactory;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.web.reactive.socket.WebSocketSession;
|
||||
import org.springframework.web.reactive.socket.adapter.HandshakeInfo;
|
||||
import org.springframework.web.reactive.socket.HandshakeInfo;
|
||||
import org.springframework.web.reactive.socket.adapter.RxNettyWebSocketSession;
|
||||
|
||||
/**
|
||||
|
||||
@@ -37,7 +37,7 @@ import org.springframework.http.server.reactive.ServletServerHttpRequest;
|
||||
import org.springframework.http.server.reactive.ServletServerHttpResponse;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.web.reactive.socket.WebSocketHandler;
|
||||
import org.springframework.web.reactive.socket.adapter.HandshakeInfo;
|
||||
import org.springframework.web.reactive.socket.HandshakeInfo;
|
||||
import org.springframework.web.reactive.socket.adapter.JettyWebSocketHandlerAdapter;
|
||||
import org.springframework.web.reactive.socket.server.RequestUpgradeStrategy;
|
||||
import org.springframework.web.server.ServerWebExchange;
|
||||
|
||||
@@ -27,7 +27,7 @@ import org.springframework.http.server.reactive.ReactorServerHttpRequest;
|
||||
import org.springframework.http.server.reactive.ReactorServerHttpResponse;
|
||||
import org.springframework.util.StringUtils;
|
||||
import org.springframework.web.reactive.socket.WebSocketHandler;
|
||||
import org.springframework.web.reactive.socket.adapter.HandshakeInfo;
|
||||
import org.springframework.web.reactive.socket.HandshakeInfo;
|
||||
import org.springframework.web.reactive.socket.adapter.ReactorNettyWebSocketSession;
|
||||
import org.springframework.web.reactive.socket.server.RequestUpgradeStrategy;
|
||||
import org.springframework.web.server.ServerWebExchange;
|
||||
|
||||
@@ -29,7 +29,7 @@ import org.springframework.http.server.reactive.RxNettyServerHttpRequest;
|
||||
import org.springframework.http.server.reactive.RxNettyServerHttpResponse;
|
||||
import org.springframework.web.reactive.socket.WebSocketHandler;
|
||||
import org.springframework.web.reactive.socket.WebSocketSession;
|
||||
import org.springframework.web.reactive.socket.adapter.HandshakeInfo;
|
||||
import org.springframework.web.reactive.socket.HandshakeInfo;
|
||||
import org.springframework.web.reactive.socket.adapter.RxNettyWebSocketSession;
|
||||
import org.springframework.web.reactive.socket.server.RequestUpgradeStrategy;
|
||||
import org.springframework.web.server.ServerWebExchange;
|
||||
|
||||
@@ -38,7 +38,7 @@ import org.springframework.http.server.reactive.ServletServerHttpRequest;
|
||||
import org.springframework.http.server.reactive.ServletServerHttpResponse;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.web.reactive.socket.WebSocketHandler;
|
||||
import org.springframework.web.reactive.socket.adapter.HandshakeInfo;
|
||||
import org.springframework.web.reactive.socket.HandshakeInfo;
|
||||
import org.springframework.web.reactive.socket.adapter.TomcatWebSocketHandlerAdapter;
|
||||
import org.springframework.web.reactive.socket.server.RequestUpgradeStrategy;
|
||||
import org.springframework.web.server.ServerWebExchange;
|
||||
|
||||
@@ -26,7 +26,7 @@ import org.springframework.http.server.reactive.ServerHttpResponse;
|
||||
import org.springframework.http.server.reactive.UndertowServerHttpRequest;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.web.reactive.socket.WebSocketHandler;
|
||||
import org.springframework.web.reactive.socket.adapter.HandshakeInfo;
|
||||
import org.springframework.web.reactive.socket.HandshakeInfo;
|
||||
import org.springframework.web.reactive.socket.adapter.UndertowWebSocketHandlerAdapter;
|
||||
import org.springframework.web.reactive.socket.server.RequestUpgradeStrategy;
|
||||
import org.springframework.web.server.ServerWebExchange;
|
||||
|
||||
@@ -25,7 +25,6 @@ import reactor.core.publisher.Mono;
|
||||
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.core.io.buffer.DataBufferUtils;
|
||||
import org.springframework.web.reactive.HandlerMapping;
|
||||
import org.springframework.web.reactive.handler.SimpleUrlHandlerMapping;
|
||||
import org.springframework.web.reactive.socket.WebSocketHandler;
|
||||
@@ -61,7 +60,7 @@ public class WebSocketIntegrationTests extends AbstractWebSocketIntegrationTests
|
||||
.take(count)
|
||||
.map(message -> {
|
||||
String text = message.getPayloadAsText();
|
||||
DataBufferUtils.release(message.getPayload());
|
||||
message.release();
|
||||
return text;
|
||||
})
|
||||
));
|
||||
|
||||
Reference in New Issue
Block a user