Browse Source

Polishing

pull/1261/merge
Juergen Hoeller 9 years ago
parent
commit
12973ac702
  1. 4
      build.gradle
  2. 4
      spring-messaging/src/main/java/org/springframework/messaging/simp/stomp/StompBrokerRelayMessageHandler.java
  3. 69
      spring-websocket/src/main/java/org/springframework/web/socket/sockjs/frame/SockJsFrame.java

4
build.gradle

@ -1324,9 +1324,7 @@ configure(rootProject) { @@ -1324,9 +1324,7 @@ configure(rootProject) {
doFirst {
classpath = files(
// ensure Servlet 3.x has precedence on the javadoc classpath
project(":spring-webmvc").sourceSets.main.compileClasspath.files.find { it =~ "servlet-api" },
// ensure the javadoc process can resolve types compiled from .aj sources
// Ensure the javadoc process can resolve types compiled from .aj sources
project(":spring-aspects").sourceSets.main.output
)
classpath += files(subprojects.collect { it.sourceSets.main.compileClasspath })

4
spring-messaging/src/main/java/org/springframework/messaging/simp/stomp/StompBrokerRelayMessageHandler.java

@ -1,5 +1,5 @@ @@ -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.
@ -973,7 +973,7 @@ public class StompBrokerRelayMessageHandler extends AbstractBrokerMessageHandler @@ -973,7 +973,7 @@ public class StompBrokerRelayMessageHandler extends AbstractBrokerMessageHandler
private static class VoidCallable implements Callable<Void> {
@Override
public Void call() {
public Void call() throws Exception {
return null;
}
}

69
spring-websocket/src/main/java/org/springframework/web/socket/sockjs/frame/SockJsFrame.java

@ -1,5 +1,5 @@ @@ -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.
@ -37,7 +37,8 @@ public class SockJsFrame { @@ -37,7 +37,8 @@ public class SockJsFrame {
private static final SockJsFrame CLOSE_GO_AWAY_FRAME = closeFrame(3000, "Go away!");
private static final SockJsFrame CLOSE_ANOTHER_CONNECTION_OPEN_FRAME = closeFrame(2010, "Another connection still open");
private static final SockJsFrame CLOSE_ANOTHER_CONNECTION_OPEN_FRAME =
closeFrame(2010, "Another connection still open");
private final SockJsFrameType type;
@ -47,10 +48,10 @@ public class SockJsFrame { @@ -47,10 +48,10 @@ public class SockJsFrame {
/**
* Create a new instance frame with the given frame content.
* @param content the content, must be a non-empty and represent a valid SockJS frame
* @param content the content (must be a non-empty and represent a valid SockJS frame)
*/
public SockJsFrame(String content) {
Assert.hasText(content);
Assert.hasText(content, "Content must not be empty");
if ("o".equals(content)) {
this.type = SockJsFrameType.OPEN;
this.content = content;
@ -72,35 +73,10 @@ public class SockJsFrame { @@ -72,35 +73,10 @@ public class SockJsFrame {
this.content = (content.length() > 1 ? content : "c[]");
}
else {
throw new IllegalArgumentException("Unexpected SockJS frame type in content=\"" + content + "\"");
throw new IllegalArgumentException("Unexpected SockJS frame type in content \"" + content + "\"");
}
}
public static SockJsFrame openFrame() {
return OPEN_FRAME;
}
public static SockJsFrame heartbeatFrame() {
return HEARTBEAT_FRAME;
}
public static SockJsFrame messageFrame(SockJsMessageCodec codec, String... messages) {
String encoded = codec.encode(messages);
return new SockJsFrame(encoded);
}
public static SockJsFrame closeFrameGoAway() {
return CLOSE_GO_AWAY_FRAME;
}
public static SockJsFrame closeFrameAnotherConnectionOpen() {
return CLOSE_ANOTHER_CONNECTION_OPEN_FRAME;
}
public static SockJsFrame closeFrame(int code, String reason) {
return new SockJsFrame("c[" + code + ",\"" + reason + "\"]");
}
/**
* Return the SockJS frame type.
@ -110,7 +86,7 @@ public class SockJsFrame { @@ -110,7 +86,7 @@ public class SockJsFrame {
}
/**
* Return the SockJS frame content, never {@code null}.
* Return the SockJS frame content (never {@code null}).
*/
public String getContent() {
return this.content;
@ -129,7 +105,7 @@ public class SockJsFrame { @@ -129,7 +105,7 @@ public class SockJsFrame {
* {@code null}.
*/
public String getFrameData() {
if (SockJsFrameType.OPEN == getType() || SockJsFrameType.HEARTBEAT == getType()) {
if (getType() == SockJsFrameType.OPEN || getType() == SockJsFrameType.HEARTBEAT) {
return null;
}
else {
@ -146,7 +122,8 @@ public class SockJsFrame { @@ -146,7 +122,8 @@ public class SockJsFrame {
if (!(other instanceof SockJsFrame)) {
return false;
}
return (this.type.equals(((SockJsFrame) other).type) && this.content.equals(((SockJsFrame) other).content));
SockJsFrame otherFrame = (SockJsFrame) other;
return (this.type.equals(otherFrame.type) && this.content.equals(otherFrame.content));
}
@Override
@ -163,4 +140,30 @@ public class SockJsFrame { @@ -163,4 +140,30 @@ public class SockJsFrame {
return "SockJsFrame content='" + result.replace("\n", "\\n").replace("\r", "\\r") + "'";
}
public static SockJsFrame openFrame() {
return OPEN_FRAME;
}
public static SockJsFrame heartbeatFrame() {
return HEARTBEAT_FRAME;
}
public static SockJsFrame messageFrame(SockJsMessageCodec codec, String... messages) {
String encoded = codec.encode(messages);
return new SockJsFrame(encoded);
}
public static SockJsFrame closeFrameGoAway() {
return CLOSE_GO_AWAY_FRAME;
}
public static SockJsFrame closeFrameAnotherConnectionOpen() {
return CLOSE_ANOTHER_CONNECTION_OPEN_FRAME;
}
public static SockJsFrame closeFrame(int code, String reason) {
return new SockJsFrame("c[" + code + ",\"" + reason + "\"]");
}
}

Loading…
Cancel
Save