diff --git a/spring-websocket/src/main/java/org/springframework/web/socket/sockjs/frame/SockJsFrame.java b/spring-websocket/src/main/java/org/springframework/web/socket/sockjs/frame/SockJsFrame.java index fbd5ca13bb..97a620170d 100644 --- a/spring-websocket/src/main/java/org/springframework/web/socket/sockjs/frame/SockJsFrame.java +++ b/spring-websocket/src/main/java/org/springframework/web/socket/sockjs/frame/SockJsFrame.java @@ -21,7 +21,8 @@ import java.nio.charset.Charset; import org.springframework.util.Assert; /** - * Represents a SockJS frame and provides factory methods for creating SockJS frames. + * Represents a SockJS frame. Provides factory methods to create SockJS frames on + * the server side. * * @author Rossen Stoyanchev * @since 4.0 @@ -30,21 +31,29 @@ public class SockJsFrame { private static final Charset UTF8_CHARSET = Charset.forName("UTF-8"); - private static final SockJsFrame openFrame = new SockJsFrame("o"); + private static final SockJsFrame OPEN_FRAME = new SockJsFrame("o"); - private static final SockJsFrame heartbeatFrame = new SockJsFrame("h"); + private static final SockJsFrame HEARTBEAT_FRAME = new SockJsFrame("h"); - private static final SockJsFrame closeGoAwayFrame = closeFrame(3000, "Go away!"); + private static final SockJsFrame CLOSE_GO_AWAY_FRAME = closeFrame(3000, "Go away!"); - private static final SockJsFrame closeAnotherConnectionOpenFrame = closeFrame(2010, "Another connection still open"); + private static final SockJsFrame CLOSE_ANOTHER_CONNECTION_OPEN_FRAME = closeFrame(2010, "Another connection still open"); + private final String content; + + + public SockJsFrame(String content) { + Assert.notNull("Content must not be null"); + this.content = content; + } + public static SockJsFrame openFrame() { - return openFrame; + return OPEN_FRAME; } public static SockJsFrame heartbeatFrame() { - return heartbeatFrame; + return HEARTBEAT_FRAME; } public static SockJsFrame messageFrame(SockJsMessageCodec codec, String... messages) { @@ -53,11 +62,11 @@ public class SockJsFrame { } public static SockJsFrame closeFrameGoAway() { - return closeGoAwayFrame; + return CLOSE_GO_AWAY_FRAME; } public static SockJsFrame closeFrameAnotherConnectionOpen() { - return closeAnotherConnectionOpenFrame; + return CLOSE_ANOTHER_CONNECTION_OPEN_FRAME; } public static SockJsFrame closeFrame(int code, String reason) { @@ -65,15 +74,6 @@ public class SockJsFrame { } - private final String content; - - - public SockJsFrame(String content) { - Assert.notNull("Content must not be null"); - this.content = content; - } - - public String getContent() { return this.content; } @@ -82,6 +82,7 @@ public class SockJsFrame { return this.content.getBytes(UTF8_CHARSET); } + @Override public boolean equals(Object other) { if (this == other) {