Javadocs and general formatting polish

This commit is contained in:
Phillip Webb 2013-04-24 22:51:36 -07:00
parent 9da2c21edb
commit db2c2480db
65 changed files with 321 additions and 92 deletions

View File

@ -37,7 +37,8 @@ import org.springframework.websocket.WebSocketSession;
*/ */
public abstract class AbstractSockJsSession implements WebSocketSession { public abstract class AbstractSockJsSession implements WebSocketSession {
protected Log logger = LogFactory.getLog(this.getClass()); protected final Log logger = LogFactory.getLog(getClass());
private final String sessionId; private final String sessionId;

View File

@ -20,15 +20,21 @@ import org.springframework.websocket.HandlerProvider;
import org.springframework.websocket.WebSocketHandler; import org.springframework.websocket.WebSocketHandler;
import org.springframework.websocket.WebSocketSession; import org.springframework.websocket.WebSocketSession;
/** /**
* A factory for creating a SockJS session. * A factory for creating a SockJS session.
* *
* @param <S> The type of session being created
* @author Rossen Stoyanchev * @author Rossen Stoyanchev
* @since 4.0 * @since 4.0
*/ */
public interface SockJsSessionFactory<S extends WebSocketSession>{ public interface SockJsSessionFactory<S extends WebSocketSession>{
/**
* Create a new SockJS session.
* @param sessionId the ID of the session
* @param handler the underlying {@link WebSocketHandler}
* @return a new non-null session
*/
S createSession(String sessionId, HandlerProvider<WebSocketHandler> handler); S createSession(String sessionId, HandlerProvider<WebSocketHandler> handler);
} }

View File

@ -1,7 +1,21 @@
/*
* Copyright 2002-2013 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.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/** /**
* Common abstractions and Spring configuration support for the SockJS protocol. * Common abstractions and Spring configuration support for the SockJS protocol.
*
*/ */
package org.springframework.sockjs; package org.springframework.sockjs;

View File

@ -30,7 +30,6 @@ import org.springframework.websocket.TextMessage;
import org.springframework.websocket.WebSocketHandler; import org.springframework.websocket.WebSocketHandler;
import org.springframework.websocket.WebSocketMessage; import org.springframework.websocket.WebSocketMessage;
/** /**
* Provides partial implementations of {@link SockJsSession} methods to send messages, * Provides partial implementations of {@link SockJsSession} methods to send messages,
* including heartbeat messages and to manage session state. * including heartbeat messages and to manage session state.

View File

@ -39,7 +39,6 @@ import org.springframework.util.StringUtils;
import org.springframework.websocket.HandlerProvider; import org.springframework.websocket.HandlerProvider;
import org.springframework.websocket.WebSocketHandler; import org.springframework.websocket.WebSocketHandler;
/** /**
* Provides support for SockJS configuration options and serves the static SockJS URLs. * Provides support for SockJS configuration options and serves the static SockJS URLs.
* *

View File

@ -16,9 +16,7 @@
package org.springframework.sockjs.server; package org.springframework.sockjs.server;
/** /**
*
* @author Rossen Stoyanchev * @author Rossen Stoyanchev
* @since 4.0 * @since 4.0
*/ */

View File

@ -18,7 +18,6 @@ package org.springframework.sockjs.server;
import org.springframework.core.NestedRuntimeException; import org.springframework.core.NestedRuntimeException;
/** /**
* *
* @author Rossen Stoyanchev * @author Rossen Stoyanchev
@ -27,7 +26,6 @@ import org.springframework.core.NestedRuntimeException;
@SuppressWarnings("serial") @SuppressWarnings("serial")
public class NestedSockJsRuntimeException extends NestedRuntimeException { public class NestedSockJsRuntimeException extends NestedRuntimeException {
public NestedSockJsRuntimeException(String msg) { public NestedSockJsRuntimeException(String msg) {
super(msg); super(msg);
} }

View File

@ -13,13 +13,13 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package org.springframework.sockjs.server; package org.springframework.sockjs.server;
import org.springframework.scheduling.TaskScheduler; import org.springframework.scheduling.TaskScheduler;
import org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler; import org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler;
/** /**
*
* @author Rossen Stoyanchev * @author Rossen Stoyanchev
* @since 4.0 * @since 4.0
*/ */

View File

@ -13,6 +13,7 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package org.springframework.sockjs.server; package org.springframework.sockjs.server;
import java.nio.charset.Charset; import java.nio.charset.Charset;
@ -21,10 +22,7 @@ import org.springframework.util.Assert;
import com.fasterxml.jackson.core.io.JsonStringEncoder; import com.fasterxml.jackson.core.io.JsonStringEncoder;
/** /**
*
*
* @author Rossen Stoyanchev * @author Rossen Stoyanchev
* @since 4.0 * @since 4.0
*/ */
@ -46,6 +44,7 @@ public class SockJsFrame {
this.content = content; this.content = content;
} }
public static SockJsFrame openFrame() { public static SockJsFrame openFrame() {
return OPEN_FRAME; return OPEN_FRAME;
} }

View File

@ -23,15 +23,12 @@ import org.springframework.http.server.ServerHttpResponse;
import org.springframework.websocket.HandlerProvider; import org.springframework.websocket.HandlerProvider;
import org.springframework.websocket.WebSocketHandler; import org.springframework.websocket.WebSocketHandler;
/** /**
*
* @author Rossen Stoyanchev * @author Rossen Stoyanchev
* @since 4.0 * @since 4.0
*/ */
public interface SockJsService { public interface SockJsService {
void handleRequest(ServerHttpRequest request, ServerHttpResponse response, String sockJsPath, void handleRequest(ServerHttpRequest request, ServerHttpResponse response, String sockJsPath,
HandlerProvider<WebSocketHandler> handler) throws IOException, TransportErrorException; HandlerProvider<WebSocketHandler> handler) throws IOException, TransportErrorException;

View File

@ -13,6 +13,7 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package org.springframework.sockjs.server; package org.springframework.sockjs.server;
import org.springframework.http.server.ServerHttpRequest; import org.springframework.http.server.ServerHttpRequest;
@ -21,9 +22,7 @@ import org.springframework.sockjs.AbstractSockJsSession;
import org.springframework.websocket.HandlerProvider; import org.springframework.websocket.HandlerProvider;
import org.springframework.websocket.WebSocketHandler; import org.springframework.websocket.WebSocketHandler;
/** /**
*
* @author Rossen Stoyanchev * @author Rossen Stoyanchev
* @since 4.0 * @since 4.0
*/ */

View File

@ -13,6 +13,7 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package org.springframework.sockjs.server; package org.springframework.sockjs.server;
import java.util.Arrays; import java.util.Arrays;
@ -20,9 +21,7 @@ import java.util.List;
import org.springframework.http.HttpMethod; import org.springframework.http.HttpMethod;
/** /**
*
* @author Rossen Stoyanchev * @author Rossen Stoyanchev
* @since 4.0 * @since 4.0
*/ */

View File

@ -1,7 +1,21 @@
/*
* Copyright 2002-2013 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.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/** /**
* Server-side SockJS abstractions and base classes. * Server-side SockJS abstractions and base classes.
*
*/ */
package org.springframework.sockjs.server; package org.springframework.sockjs.server;

View File

@ -13,6 +13,7 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package org.springframework.sockjs.server.support; package org.springframework.sockjs.server.support;
import java.io.IOException; import java.io.IOException;

View File

@ -35,9 +35,7 @@ import org.springframework.websocket.HandlerProvider;
import org.springframework.websocket.WebSocketHandler; import org.springframework.websocket.WebSocketHandler;
import org.springframework.websocket.support.SimpleHandlerProvider; import org.springframework.websocket.support.SimpleHandlerProvider;
/** /**
*
* @author Rossen Stoyanchev * @author Rossen Stoyanchev
* @since 4.0 * @since 4.0
*/ */
@ -89,6 +87,7 @@ public class SockJsHttpRequestHandler implements HttpRequestHandler {
this.handlerProvider = handlerProvider; this.handlerProvider = handlerProvider;
} }
public String getPrefix() { public String getPrefix() {
return this.prefix; return this.prefix;
} }

View File

@ -1,3 +1,18 @@
/*
* Copyright 2002-2013 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.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/** /**
* Server-side SockJS classes including a * Server-side SockJS classes including a

View File

@ -13,6 +13,7 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package org.springframework.sockjs.server.transport; package org.springframework.sockjs.server.transport;
import java.io.IOException; import java.io.IOException;
@ -34,7 +35,6 @@ import org.springframework.websocket.WebSocketHandler;
import com.fasterxml.jackson.databind.JsonMappingException; import com.fasterxml.jackson.databind.JsonMappingException;
import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.ObjectMapper;
/** /**
* TODO * TODO
* *

View File

@ -13,6 +13,7 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package org.springframework.sockjs.server.transport; package org.springframework.sockjs.server.transport;
import java.io.IOException; import java.io.IOException;

View File

@ -13,6 +13,7 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package org.springframework.sockjs.server.transport; package org.springframework.sockjs.server.transport;
import java.io.IOException; import java.io.IOException;

View File

@ -13,6 +13,7 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package org.springframework.sockjs.server.transport; package org.springframework.sockjs.server.transport;
import java.io.IOException; import java.io.IOException;
@ -27,7 +28,6 @@ import org.springframework.util.Assert;
import org.springframework.websocket.HandlerProvider; import org.springframework.websocket.HandlerProvider;
import org.springframework.websocket.WebSocketHandler; import org.springframework.websocket.WebSocketHandler;
/** /**
* TODO * TODO
* *
@ -36,7 +36,6 @@ import org.springframework.websocket.WebSocketHandler;
*/ */
public class EventSourceTransportHandler extends AbstractHttpSendingTransportHandler { public class EventSourceTransportHandler extends AbstractHttpSendingTransportHandler {
@Override @Override
public TransportType getTransportType() { public TransportType getTransportType() {
return TransportType.EVENT_SOURCE; return TransportType.EVENT_SOURCE;

View File

@ -13,6 +13,7 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package org.springframework.sockjs.server.transport; package org.springframework.sockjs.server.transport;
import java.io.IOException; import java.io.IOException;
@ -32,7 +33,6 @@ import org.springframework.web.util.JavaScriptUtils;
import org.springframework.websocket.HandlerProvider; import org.springframework.websocket.HandlerProvider;
import org.springframework.websocket.WebSocketHandler; import org.springframework.websocket.WebSocketHandler;
/** /**
* TODO * TODO
* *

View File

@ -13,6 +13,7 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package org.springframework.sockjs.server.transport; package org.springframework.sockjs.server.transport;
import java.nio.charset.Charset; import java.nio.charset.Charset;
@ -31,7 +32,6 @@ import org.springframework.web.util.JavaScriptUtils;
import org.springframework.websocket.HandlerProvider; import org.springframework.websocket.HandlerProvider;
import org.springframework.websocket.WebSocketHandler; import org.springframework.websocket.WebSocketHandler;
/** /**
* TODO * TODO
* *
@ -40,7 +40,6 @@ import org.springframework.websocket.WebSocketHandler;
*/ */
public class JsonpPollingTransportHandler extends AbstractHttpSendingTransportHandler { public class JsonpPollingTransportHandler extends AbstractHttpSendingTransportHandler {
@Override @Override
public TransportType getTransportType() { public TransportType getTransportType() {
return TransportType.JSONP; return TransportType.JSONP;

View File

@ -13,6 +13,7 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package org.springframework.sockjs.server.transport; package org.springframework.sockjs.server.transport;
import java.io.IOException; import java.io.IOException;
@ -27,7 +28,6 @@ import org.springframework.sockjs.server.TransportType;
public class JsonpTransportHandler extends AbstractHttpReceivingTransportHandler { public class JsonpTransportHandler extends AbstractHttpReceivingTransportHandler {
@Override @Override
public TransportType getTransportType() { public TransportType getTransportType() {
return TransportType.JSONP_SEND; return TransportType.JSONP_SEND;

View File

@ -13,6 +13,7 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package org.springframework.sockjs.server.transport; package org.springframework.sockjs.server.transport;
import java.io.IOException; import java.io.IOException;
@ -26,7 +27,6 @@ import org.springframework.sockjs.server.TransportErrorException;
import org.springframework.websocket.HandlerProvider; import org.springframework.websocket.HandlerProvider;
import org.springframework.websocket.WebSocketHandler; import org.springframework.websocket.WebSocketHandler;
public class StreamingServerSockJsSession extends AbstractHttpServerSockJsSession { public class StreamingServerSockJsSession extends AbstractHttpServerSockJsSession {
private int byteCount; private int byteCount;
@ -38,6 +38,7 @@ public class StreamingServerSockJsSession extends AbstractHttpServerSockJsSessio
super(sessionId, sockJsConfig, handler); super(sessionId, sockJsConfig, handler);
} }
@Override @Override
public synchronized void setInitialRequest(ServerHttpRequest request, ServerHttpResponse response, public synchronized void setInitialRequest(ServerHttpRequest request, ServerHttpResponse response,
FrameFormat frameFormat) throws TransportErrorException { FrameFormat frameFormat) throws TransportErrorException {

View File

@ -1,3 +1,18 @@
/*
* Copyright 2002-2013 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.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/** /**
* Server-side support for SockJS transports including * Server-side support for SockJS transports including

View File

@ -23,10 +23,11 @@ import org.springframework.util.Assert;
/** /**
* Represents a binary WebSocket message. * A {@link WebSocketMessage} that contains a binary {@link ByteBuffer} payload.
* *
* @author Rossen Stoyanchev * @author Rossen Stoyanchev
* @since 4.0 * @since 4.0
* @see WebSocketMessage
*/ */
public final class BinaryMessage extends WebSocketMessage<ByteBuffer> { public final class BinaryMessage extends WebSocketMessage<ByteBuffer> {
@ -35,41 +36,80 @@ public final class BinaryMessage extends WebSocketMessage<ByteBuffer> {
private final boolean last; private final boolean last;
/**
* Create a new {@link BinaryMessage} instance.
* @param payload a non-null payload
*/
public BinaryMessage(ByteBuffer payload) { public BinaryMessage(ByteBuffer payload) {
this(payload, true); this(payload, true);
} }
/**
* Create a new {@link BinaryMessage} instance.
* @param payload a non-null payload
* @param isLast if the message is the last of a series of partial messages
*/
public BinaryMessage(ByteBuffer payload, boolean isLast) { public BinaryMessage(ByteBuffer payload, boolean isLast) {
super(payload); super(payload);
this.bytes = null; this.bytes = null;
this.last = isLast; this.last = isLast;
} }
/**
* Create a new {@link BinaryMessage} instance.
* @param payload a non-null payload
*/
public BinaryMessage(byte[] payload) { public BinaryMessage(byte[] payload) {
this(payload, true); this(payload, true);
} }
/**
* Create a new {@link BinaryMessage} instance.
* @param payload a non-null payload
* @param isLast if the message is the last of a series of partial messages
*/
public BinaryMessage(byte[] payload, boolean isLast) { public BinaryMessage(byte[] payload, boolean isLast) {
this(payload, 0, (payload == null ? 0 : payload.length), isLast); this(payload, 0, (payload == null ? 0 : payload.length), isLast);
} }
/**
* Create a new {@link BinaryMessage} instance by wrapping an existing byte array.
* @param payload a non-null payload, NOTE: this value is not copied so care must be
* taken not to modify the array.
* @param isLast if the message is the last of a series of partial messages
*/
public BinaryMessage(byte[] payload, int offset, int len) { public BinaryMessage(byte[] payload, int offset, int len) {
this(payload, offset, len, true); this(payload, offset, len, true);
} }
/**
* Create a new {@link BinaryMessage} instance by wrapping an existing byte array.
* @param payload a non-null payload, NOTE: this value is not copied so care must be
* taken not to modify the array.
* @param offset the offet into the array where the payload starts
* @param len the length of the array considered for the payload
* @param isLast if the message is the last of a series of partial messages
*/
public BinaryMessage(byte[] payload, int offset, int len, boolean isLast) { public BinaryMessage(byte[] payload, int offset, int len, boolean isLast) {
super(payload != null ? ByteBuffer.wrap(payload, offset, len) : null); super(payload != null ? ByteBuffer.wrap(payload, offset, len) : null);
if(payload != null && offset == 0 && len == payload.length) { if(offset == 0 && len == payload.length) {
// FIXME better if a message always needs a payload?
this.bytes = payload; this.bytes = payload;
} }
this.last = isLast; this.last = isLast;
} }
/**
* Returns if this is the last part in a series of partial messages. If this is
* not a partial message this method will return {@code true}.
*/
public boolean isLast() { public boolean isLast() {
return this.last; return this.last;
} }
/**
* Returns access to the message payload as a byte array. NOTE: the returned array
* should be considered read-only and should not be modified.
*/
public byte[] getByteArray() { public byte[] getByteArray() {
if(this.bytes == null && getPayload() != null) { if(this.bytes == null && getPayload() != null) {
this.bytes = getRemainingBytes(getPayload()); this.bytes = getRemainingBytes(getPayload());
@ -83,6 +123,9 @@ public final class BinaryMessage extends WebSocketMessage<ByteBuffer> {
return result; return result;
} }
/**
* Returns access to the message payload as an {@link InputStream}.
*/
public InputStream getInputStream() { public InputStream getInputStream() {
byte[] array = getByteArray(); byte[] array = getByteArray();
return (array != null) ? new ByteArrayInputStream(array) : null; return (array != null) ? new ByteArrayInputStream(array) : null;

View File

@ -15,10 +15,10 @@
*/ */
package org.springframework.websocket; package org.springframework.websocket;
import org.eclipse.jetty.websocket.api.StatusCode;
import org.springframework.util.Assert; import org.springframework.util.Assert;
import org.springframework.util.ObjectUtils; import org.springframework.util.ObjectUtils;
/** /**
* Represents a WebSocket close status code and reason. Status codes in the 1xxx range are * Represents a WebSocket close status code and reason. Status codes in the 1xxx range are
* pre-defined by the protocol. Optionally, a status code may be sent with a reason. * pre-defined by the protocol. Optionally, a status code may be sent with a reason.
@ -28,11 +28,10 @@ import org.springframework.util.ObjectUtils;
* *
* @author Rossen Stoyanchev * @author Rossen Stoyanchev
* @since 4.0 * @since 4.0
*
*/ */
public final class CloseStatus { public final class CloseStatus {
/** /**
* "1000 indicates a normal closure, meaning that the purpose for which the connection * "1000 indicates a normal closure, meaning that the purpose for which the connection
* was established has been fulfilled." * was established has been fulfilled."
*/ */
@ -44,13 +43,13 @@ public final class CloseStatus {
*/ */
public static final CloseStatus GOING_AWAY = new CloseStatus(1001); public static final CloseStatus GOING_AWAY = new CloseStatus(1001);
/** /**
* "1002 indicates that an endpoint is terminating the connection due to a protocol * "1002 indicates that an endpoint is terminating the connection due to a protocol
* error." * error."
*/ */
public static final CloseStatus PROTOCOL_ERROR = new CloseStatus(1002); public static final CloseStatus PROTOCOL_ERROR = new CloseStatus(1002);
/** /**
* "1003 indicates that an endpoint is terminating the connection because it has * "1003 indicates that an endpoint is terminating the connection because it has
* received a type of data it cannot accept (e.g., an endpoint that understands only * received a type of data it cannot accept (e.g., an endpoint that understands only
* text data MAY send this if it receives a binary message)." * text data MAY send this if it receives a binary message)."
@ -82,7 +81,7 @@ public final class CloseStatus {
*/ */
public static final CloseStatus BAD_DATA = new CloseStatus(1007); public static final CloseStatus BAD_DATA = new CloseStatus(1007);
/** /**
* "1008 indicates that an endpoint is terminating the connection because it has * "1008 indicates that an endpoint is terminating the connection because it has
* received a message that violates its policy. This is a generic status code that can * received a message that violates its policy. This is a generic status code that can
* be returned when there is no other more suitable status code (e.g., 1003 or 1009) * be returned when there is no other more suitable status code (e.g., 1003 or 1009)
@ -90,13 +89,13 @@ public final class CloseStatus {
*/ */
public static final CloseStatus POLICY_VIOLATION = new CloseStatus(1008); public static final CloseStatus POLICY_VIOLATION = new CloseStatus(1008);
/** /**
* "1009 indicates that an endpoint is terminating the connection because it has * "1009 indicates that an endpoint is terminating the connection because it has
* received a message that is too big for it to process." * received a message that is too big for it to process."
*/ */
public static final CloseStatus TOO_BIG_TO_PROCESS = new CloseStatus(1009); public static final CloseStatus TOO_BIG_TO_PROCESS = new CloseStatus(1009);
/** /**
* "1010 indicates that an endpoint (client) is terminating the connection because it * "1010 indicates that an endpoint (client) is terminating the connection because it
* has expected the server to negotiate one or more extension, but the server didn't * has expected the server to negotiate one or more extension, but the server didn't
* return them in the response message of the WebSocket handshake. The list of * return them in the response message of the WebSocket handshake. The list of
@ -106,7 +105,7 @@ public final class CloseStatus {
*/ */
public static final CloseStatus REQUIRED_EXTENSION = new CloseStatus(1010); public static final CloseStatus REQUIRED_EXTENSION = new CloseStatus(1010);
/** /**
* "1011 indicates that a server is terminating the connection because it encountered * "1011 indicates that a server is terminating the connection because it encountered
* an unexpected condition that prevented it from fulfilling the request." * an unexpected condition that prevented it from fulfilling the request."
*/ */
@ -125,7 +124,7 @@ public final class CloseStatus {
*/ */
public static final CloseStatus SERVICE_OVERLOAD = new CloseStatus(1013); public static final CloseStatus SERVICE_OVERLOAD = new CloseStatus(1013);
/** /**
* "1015 is a reserved value and MUST NOT be set as a status code in a Close control * "1015 is a reserved value and MUST NOT be set as a status code in a Close control
* frame by an endpoint. It is designated for use in applications expecting a status * frame by an endpoint. It is designated for use in applications expecting a status
* code to indicate that the connection was closed due to a failure to perform a TLS * code to indicate that the connection was closed due to a failure to perform a TLS
@ -134,32 +133,51 @@ public final class CloseStatus {
public static final CloseStatus TLS_HANDSHAKE_FAILURE = new CloseStatus(1015); public static final CloseStatus TLS_HANDSHAKE_FAILURE = new CloseStatus(1015);
private final int code; private final int code;
private final String reason; private final String reason;
/**
* Create a new {@link CloseStatus} instance.
* @param code the status code
*/
public CloseStatus(int code) { public CloseStatus(int code) {
this(code, null); this(code, null);
} }
/**
* Create a new {@link CloseStatus} instance.
* @param code
* @param reason
*/
public CloseStatus(int code, String reason) { public CloseStatus(int code, String reason) {
Assert.isTrue((code >= 1000 && code < 5000), "Invalid code"); Assert.isTrue((code >= 1000 && code < 5000), "Invalid code");
this.code = code; this.code = code;
this.reason = reason; this.reason = reason;
} }
/**
* Returns the status code.
*/
public int getCode() { public int getCode() {
return this.code; return this.code;
} }
/**
* Returns the reason or {@code null}.
*/
public String getReason() { public String getReason() {
return this.reason; return this.reason;
} }
/**
* Crate a new {@link CloseStatus} from this one with the specified reason.
* @param reason the reason
* @return a new {@link StatusCode} instance
*/
public CloseStatus withReason(String reason) { public CloseStatus withReason(String reason) {
Assert.hasText(reason, "Expected non-empty reason"); Assert.hasText(reason, "Reason must not be empty");
return new CloseStatus(this.code, reason); return new CloseStatus(this.code, reason);
} }

View File

@ -13,8 +13,8 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package org.springframework.websocket;
package org.springframework.websocket;
/** /**
* A strategy for obtaining a handler instance that is scoped to external lifecycle events * A strategy for obtaining a handler instance that is scoped to external lifecycle events

View File

@ -13,8 +13,8 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package org.springframework.websocket;
package org.springframework.websocket;
/** /**
* A "marker" interface for {@link BinaryMessageHandler} types that wish to handle partial * A "marker" interface for {@link BinaryMessageHandler} types that wish to handle partial

View File

@ -13,23 +13,31 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package org.springframework.websocket; package org.springframework.websocket;
import java.io.Reader; import java.io.Reader;
import java.io.StringReader; import java.io.StringReader;
/** /**
* Represents a text WebSocket message. * A {@link WebSocketMessage} that contains a textual {@link String} payload.
* *
* @author Rossen Stoyanchev * @author Rossen Stoyanchev
* @since 4.0 * @since 4.0
*/ */
public final class TextMessage extends WebSocketMessage<String> { public final class TextMessage extends WebSocketMessage<String> {
public TextMessage(String payload) { /**
super(payload); * Create a new {@link TextMessage} instance.
* @param payload the payload
*/
public TextMessage(CharSequence payload) {
super(payload.toString());
} }
/**
* Returns access to the message payload as a {@link Reader}.
*/
public Reader getReader() { public Reader getReader() {
return new StringReader(getPayload()); return new StringReader(getPayload());
} }

View File

@ -16,8 +16,6 @@
package org.springframework.websocket; package org.springframework.websocket;
/** /**
* A handler for WebSocket sessions. * A handler for WebSocket sessions.
* *

View File

@ -22,6 +22,7 @@ package org.springframework.websocket;
* *
* @author Rossen Stoyanchev * @author Rossen Stoyanchev
* @since 4.0 * @since 4.0
* @see WebSocketHandler
*/ */
public class WebSocketHandlerAdapter implements WebSocketHandler { public class WebSocketHandlerAdapter implements WebSocketHandler {

View File

@ -13,27 +13,40 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package org.springframework.websocket; package org.springframework.websocket;
import org.springframework.util.Assert; import org.springframework.util.Assert;
import org.springframework.util.ObjectUtils; import org.springframework.util.ObjectUtils;
/** /**
* A message that can be sent or received over a WebSocket connection. A WebSocket
* message must be either a {@link BinaryMessage} or a {@link TextMessage} depending
* on the payload. No further subclasses are supported.
* *
* @author Rossen Stoyanchev * @author Rossen Stoyanchev
* @since 4.0 * @since 4.0
* @see BinaryMessage
* @see TextMessage
*/ */
public abstract class WebSocketMessage<T> { public abstract class WebSocketMessage<T> {
private final T payload; private final T payload;
/**
* Create a new {@link WebSocketMessage} instance.
* @param payload a non-null payload
*/
WebSocketMessage(T payload) { WebSocketMessage(T payload) {
Assert.notNull(payload, "Payload must not be null"); Assert.notNull(payload, "Payload must not be null");
this.payload = payload; this.payload = payload;
} }
/**
* Returns the message payload. This will never be {@code null}.
*/
public T getPayload() { public T getPayload() {
return this.payload; return this.payload;
} }

View File

@ -19,7 +19,6 @@ package org.springframework.websocket;
import java.io.IOException; import java.io.IOException;
import java.net.URI; import java.net.URI;
/** /**
* Allows sending messages over a WebSocket connection as well as closing it. * Allows sending messages over a WebSocket connection as well as closing it.
* *

View File

@ -13,6 +13,7 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package org.springframework.websocket.client; package org.springframework.websocket.client;
import java.net.URI; import java.net.URI;
@ -24,8 +25,8 @@ import org.springframework.core.task.SimpleAsyncTaskExecutor;
import org.springframework.core.task.TaskExecutor; import org.springframework.core.task.TaskExecutor;
import org.springframework.web.util.UriComponentsBuilder; import org.springframework.web.util.UriComponentsBuilder;
/** /**
* Abstract base class for WebSocketConnection managers.
* *
* @author Rossen Stoyanchev * @author Rossen Stoyanchev
* @since 4.0 * @since 4.0
@ -34,6 +35,7 @@ public abstract class AbstractWebSocketConnectionManager implements SmartLifecyc
protected final Log logger = LogFactory.getLog(getClass()); protected final Log logger = LogFactory.getLog(getClass());
private final URI uri; private final URI uri;
private boolean autoStartup = false; private boolean autoStartup = false;

View File

@ -22,7 +22,6 @@ import org.springframework.websocket.HandlerProvider;
import org.springframework.websocket.WebSocketHandler; import org.springframework.websocket.WebSocketHandler;
import org.springframework.websocket.WebSocketSession; import org.springframework.websocket.WebSocketSession;
/** /**
* Contract for starting a WebSocket handshake request. * Contract for starting a WebSocket handshake request.
* *
@ -36,7 +35,6 @@ import org.springframework.websocket.WebSocketSession;
*/ */
public interface WebSocketClient { public interface WebSocketClient {
WebSocketSession doHandshake(WebSocketHandler handler, WebSocketSession doHandshake(WebSocketHandler handler,
String uriTemplate, Object... uriVariables) throws WebSocketConnectFailureException; String uriTemplate, Object... uriVariables) throws WebSocketConnectFailureException;

View File

@ -13,20 +13,18 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package org.springframework.websocket.client; package org.springframework.websocket.client;
import org.springframework.core.NestedRuntimeException; import org.springframework.core.NestedRuntimeException;
/** /**
*
* @author Rossen Stoyanchev * @author Rossen Stoyanchev
* @since 4.0 * @since 4.0
*/ */
@SuppressWarnings("serial") @SuppressWarnings("serial")
public class WebSocketConnectFailureException extends NestedRuntimeException { public class WebSocketConnectFailureException extends NestedRuntimeException {
public WebSocketConnectFailureException(String msg, Throwable cause) { public WebSocketConnectFailureException(String msg, Throwable cause) {
super(msg, cause); super(msg, cause);
} }

View File

@ -13,6 +13,7 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package org.springframework.websocket.client; package org.springframework.websocket.client;
import java.util.ArrayList; import java.util.ArrayList;
@ -25,9 +26,7 @@ import org.springframework.websocket.WebSocketHandler;
import org.springframework.websocket.WebSocketSession; import org.springframework.websocket.WebSocketSession;
import org.springframework.websocket.support.SimpleHandlerProvider; import org.springframework.websocket.support.SimpleHandlerProvider;
/** /**
*
* @author Rossen Stoyanchev * @author Rossen Stoyanchev
* @since 4.0 * @since 4.0
*/ */
@ -58,6 +57,7 @@ public class WebSocketConnectionManager extends AbstractWebSocketConnectionManag
this.handlerProvider = handlerProvider; this.handlerProvider = handlerProvider;
} }
public void setSubProtocols(List<String> subProtocols) { public void setSubProtocols(List<String> subProtocols) {
this.subProtocols.clear(); this.subProtocols.clear();
if (!CollectionUtils.isEmpty(subProtocols)) { if (!CollectionUtils.isEmpty(subProtocols)) {

View File

@ -25,9 +25,7 @@ import org.springframework.websocket.HandlerProvider;
import org.springframework.websocket.support.BeanCreatingHandlerProvider; import org.springframework.websocket.support.BeanCreatingHandlerProvider;
import org.springframework.websocket.support.SimpleHandlerProvider; import org.springframework.websocket.support.SimpleHandlerProvider;
/** /**
*
* @author Rossen Stoyanchev * @author Rossen Stoyanchev
* @since 4.0 * @since 4.0
*/ */
@ -47,6 +45,7 @@ public class AnnotatedEndpointConnectionManager extends EndpointConnectionManage
this.handlerProvider = new BeanCreatingHandlerProvider<Object>(endpointClass); this.handlerProvider = new BeanCreatingHandlerProvider<Object>(endpointClass);
} }
@Override @Override
public void setBeanFactory(BeanFactory beanFactory) throws BeansException { public void setBeanFactory(BeanFactory beanFactory) throws BeansException {
if (this.handlerProvider instanceof BeanFactoryAware) { if (this.handlerProvider instanceof BeanFactoryAware) {

View File

@ -35,9 +35,7 @@ import org.springframework.websocket.HandlerProvider;
import org.springframework.websocket.support.BeanCreatingHandlerProvider; import org.springframework.websocket.support.BeanCreatingHandlerProvider;
import org.springframework.websocket.support.SimpleHandlerProvider; import org.springframework.websocket.support.SimpleHandlerProvider;
/** /**
*
* @author Rossen Stoyanchev * @author Rossen Stoyanchev
* @since 4.0 * @since 4.0
*/ */
@ -60,6 +58,7 @@ public class EndpointConnectionManager extends EndpointConnectionManagerSupport
this.handlerProvider = new BeanCreatingHandlerProvider<Endpoint>(endpointClass); this.handlerProvider = new BeanCreatingHandlerProvider<Endpoint>(endpointClass);
} }
public void setSubProtocols(String... subprotocols) { public void setSubProtocols(String... subprotocols) {
this.configBuilder.preferredSubprotocols(Arrays.asList(subprotocols)); this.configBuilder.preferredSubprotocols(Arrays.asList(subprotocols));
} }

View File

@ -22,9 +22,7 @@ import javax.websocket.WebSocketContainer;
import org.springframework.websocket.client.AbstractWebSocketConnectionManager; import org.springframework.websocket.client.AbstractWebSocketConnectionManager;
/** /**
*
* @author Rossen Stoyanchev * @author Rossen Stoyanchev
* @since 4.0 * @since 4.0
*/ */
@ -39,6 +37,7 @@ public abstract class EndpointConnectionManagerSupport extends AbstractWebSocket
super(uriTemplate, uriVariables); super(uriTemplate, uriVariables);
} }
public void setWebSocketContainer(WebSocketContainer webSocketContainer) { public void setWebSocketContainer(WebSocketContainer webSocketContainer) {
this.webSocketContainer = webSocketContainer; this.webSocketContainer = webSocketContainer;
} }

View File

@ -13,6 +13,7 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package org.springframework.websocket.client.endpoint; package org.springframework.websocket.client.endpoint;
import java.net.URI; import java.net.URI;
@ -40,7 +41,6 @@ import org.springframework.websocket.endpoint.StandardWebSocketSession;
import org.springframework.websocket.endpoint.WebSocketHandlerEndpoint; import org.springframework.websocket.endpoint.WebSocketHandlerEndpoint;
import org.springframework.websocket.support.SimpleHandlerProvider; import org.springframework.websocket.support.SimpleHandlerProvider;
/** /**
* A standard Java {@link WebSocketClient}. * A standard Java {@link WebSocketClient}.
* *

View File

@ -13,6 +13,7 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package org.springframework.websocket.client.endpoint; package org.springframework.websocket.client.endpoint;
import javax.websocket.ContainerProvider; import javax.websocket.ContainerProvider;
@ -20,7 +21,6 @@ import javax.websocket.WebSocketContainer;
import org.springframework.beans.factory.FactoryBean; import org.springframework.beans.factory.FactoryBean;
/** /**
* A FactoryBean for creating and configuring a {@link javax.websocket.WebSocketContainer} * A FactoryBean for creating and configuring a {@link javax.websocket.WebSocketContainer}
* through Spring XML configuration. In Java configuration, ignore this class and use * through Spring XML configuration. In Java configuration, ignore this class and use

View File

@ -1,3 +1,19 @@
/*
* Copyright 2002-2013 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.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/** /**
* Client-side classes for use with standard Java WebSocket endpoints including * Client-side classes for use with standard Java WebSocket endpoints including
* {@link org.springframework.websocket.client.endpoint.EndpointConnectionManager} and * {@link org.springframework.websocket.client.endpoint.EndpointConnectionManager} and

View File

@ -1,6 +1,21 @@
/*
* Copyright 2002-2013 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.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/** /**
* Server-side abstractions for WebSocket applications. * Server-side abstractions for WebSocket applications.
*
*/ */
package org.springframework.websocket.client; package org.springframework.websocket.client;

View File

@ -32,7 +32,6 @@ import org.springframework.websocket.TextMessage;
import org.springframework.websocket.WebSocketMessage; import org.springframework.websocket.WebSocketMessage;
import org.springframework.websocket.WebSocketSession; import org.springframework.websocket.WebSocketSession;
/** /**
* A standard Java implementation of {@link WebSocketSession} that delegates to * A standard Java implementation of {@link WebSocketSession} that delegates to
* {@link javax.websocket.Session}. * {@link javax.websocket.Session}.
@ -52,6 +51,7 @@ public class StandardWebSocketSession implements WebSocketSession {
this.session = session; this.session = session;
} }
@Override @Override
public String getId() { public String getId() {
return this.session.getId(); return this.session.getId();

View File

@ -59,6 +59,7 @@ public class WebSocketHandlerEndpoint extends Endpoint {
this.handlerProvider = handlerProvider; this.handlerProvider = handlerProvider;
} }
@Override @Override
public void onOpen(final javax.websocket.Session session, EndpointConfig config) { public void onOpen(final javax.websocket.Session session, EndpointConfig config) {

View File

@ -1,8 +1,22 @@
/*
* Copyright 2002-2013 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.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/** /**
* Classes for use with the standard Java WebSocket endpoints from both client and * Classes for use with the standard Java WebSocket endpoints from both client and
* server code. * server code.
*
*/ */
package org.springframework.websocket.endpoint; package org.springframework.websocket.endpoint;

View File

@ -1,7 +1,21 @@
/*
* Copyright 2002-2013 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.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/** /**
* Common abstractions and Spring configuration support for WebSocket applications. * Common abstractions and Spring configuration support for WebSocket applications.
*
*/ */
package org.springframework.websocket; package org.springframework.websocket;

View File

@ -38,7 +38,6 @@ import org.springframework.util.StringUtils;
import org.springframework.websocket.HandlerProvider; import org.springframework.websocket.HandlerProvider;
import org.springframework.websocket.WebSocketHandler; import org.springframework.websocket.WebSocketHandler;
/** /**
* TODO * TODO
* <p> * <p>
@ -78,6 +77,7 @@ public class DefaultHandshakeHandler implements HandshakeHandler {
this.requestUpgradeStrategy = upgradeStrategy; this.requestUpgradeStrategy = upgradeStrategy;
} }
public void setSupportedProtocols(String... protocols) { public void setSupportedProtocols(String... protocols) {
this.supportedProtocols = Arrays.asList(protocols); this.supportedProtocols = Arrays.asList(protocols);
} }

View File

@ -23,7 +23,6 @@ import org.springframework.http.server.ServerHttpResponse;
import org.springframework.websocket.HandlerProvider; import org.springframework.websocket.HandlerProvider;
import org.springframework.websocket.WebSocketHandler; import org.springframework.websocket.WebSocketHandler;
/** /**
* Contract for processing a WebSocket handshake request. * Contract for processing a WebSocket handshake request.
* *

View File

@ -23,7 +23,6 @@ import org.springframework.http.server.ServerHttpResponse;
import org.springframework.websocket.HandlerProvider; import org.springframework.websocket.HandlerProvider;
import org.springframework.websocket.WebSocketHandler; import org.springframework.websocket.WebSocketHandler;
/** /**
* A strategy for performing container-specific steps to upgrade an HTTP request during a * A strategy for performing container-specific steps to upgrade an HTTP request during a
* WebSocket handshake. Intended for use within {@link HandshakeHandler} implementations. * WebSocket handshake. Intended for use within {@link HandshakeHandler} implementations.

View File

@ -13,6 +13,7 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package org.springframework.websocket.server.endpoint; package org.springframework.websocket.server.endpoint;
import java.lang.reflect.Method; import java.lang.reflect.Method;

View File

@ -94,6 +94,7 @@ public class EndpointRegistration implements ServerEndpointConfig, BeanFactoryAw
this.handlerProvider = new SimpleHandlerProvider<Endpoint>(endpointBean); this.handlerProvider = new SimpleHandlerProvider<Endpoint>(endpointBean);
} }
@Override @Override
public String getPath() { public String getPath() {
return this.path; return this.path;

View File

@ -13,6 +13,7 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package org.springframework.websocket.server.endpoint; package org.springframework.websocket.server.endpoint;
import javax.servlet.ServletContext; import javax.servlet.ServletContext;
@ -26,7 +27,6 @@ import org.springframework.util.Assert;
import org.springframework.web.context.ServletContextAware; import org.springframework.web.context.ServletContextAware;
import org.springframework.websocket.server.DefaultHandshakeHandler; import org.springframework.websocket.server.DefaultHandshakeHandler;
/** /**
* A FactoryBean for {@link javax.websocket.server.ServerContainer}. Since * A FactoryBean for {@link javax.websocket.server.ServerContainer}. Since
* there is only one {@code ServerContainer} instance accessible under a well-known * there is only one {@code ServerContainer} instance accessible under a well-known
@ -46,6 +46,7 @@ public class ServletServerContainerFactoryBean
private static final String SERVER_CONTAINER_ATTR_NAME = "javax.websocket.server.ServerContainer"; private static final String SERVER_CONTAINER_ATTR_NAME = "javax.websocket.server.ServerContainer";
private Long asyncSendTimeout; private Long asyncSendTimeout;
private Long maxSessionIdleTimeout; private Long maxSessionIdleTimeout;
@ -54,7 +55,6 @@ public class ServletServerContainerFactoryBean
private Integer maxBinaryMessageBufferSize; private Integer maxBinaryMessageBufferSize;
private ServerContainer serverContainer; private ServerContainer serverContainer;

View File

@ -26,7 +26,6 @@ import org.apache.commons.logging.LogFactory;
import org.springframework.web.context.ContextLoader; import org.springframework.web.context.ContextLoader;
import org.springframework.web.context.WebApplicationContext; import org.springframework.web.context.WebApplicationContext;
/** /**
* This should be used in conjuction with {@link ServerEndpoint @ServerEndpoint} classes. * This should be used in conjuction with {@link ServerEndpoint @ServerEndpoint} classes.
* *

View File

@ -1,3 +1,18 @@
/*
* Copyright 2002-2013 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.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/** /**
* Server classes for use with standard Java WebSocket endpoints including * Server classes for use with standard Java WebSocket endpoints including

View File

@ -1,7 +1,21 @@
/*
* Copyright 2002-2013 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.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/** /**
* Server-side abstractions for WebSocket applications. * Server-side abstractions for WebSocket applications.
*
*/ */
package org.springframework.websocket.server; package org.springframework.websocket.server;

View File

@ -29,7 +29,6 @@ import org.springframework.websocket.WebSocketHandler;
import org.springframework.websocket.endpoint.WebSocketHandlerEndpoint; import org.springframework.websocket.endpoint.WebSocketHandlerEndpoint;
import org.springframework.websocket.server.RequestUpgradeStrategy; import org.springframework.websocket.server.RequestUpgradeStrategy;
/** /**
* A {@link RequestUpgradeStrategy} that supports WebSocket handlers of type * A {@link RequestUpgradeStrategy} that supports WebSocket handlers of type
* {@link WebSocketHandler} as well as {@link javax.websocket.Endpoint}. * {@link WebSocketHandler} as well as {@link javax.websocket.Endpoint}.

View File

@ -92,6 +92,7 @@ public class JettyRequestUpgradeStrategy implements RequestUpgradeStrategy {
} }
} }
@Override @Override
public String[] getSupportedVersions() { public String[] getSupportedVersions() {
return new String[] { String.valueOf(HandshakeRFC6455.VERSION) }; return new String[] { String.valueOf(HandshakeRFC6455.VERSION) };

View File

@ -34,7 +34,6 @@ import org.springframework.util.Assert;
import org.springframework.util.ReflectionUtils; import org.springframework.util.ReflectionUtils;
import org.springframework.websocket.server.endpoint.EndpointRegistration; import org.springframework.websocket.server.endpoint.EndpointRegistration;
/** /**
* Tomcat support for upgrading an {@link HttpServletRequest} during a WebSocket handshake. * Tomcat support for upgrading an {@link HttpServletRequest} during a WebSocket handshake.
* *
@ -43,7 +42,6 @@ import org.springframework.websocket.server.endpoint.EndpointRegistration;
*/ */
public class TomcatRequestUpgradeStrategy extends AbstractEndpointUpgradeStrategy { public class TomcatRequestUpgradeStrategy extends AbstractEndpointUpgradeStrategy {
@Override @Override
public String[] getSupportedVersions() { public String[] getSupportedVersions() {
return new String[] { "13" }; return new String[] { "13" };

View File

@ -35,7 +35,6 @@ import org.springframework.websocket.server.DefaultHandshakeHandler;
import org.springframework.websocket.server.HandshakeHandler; import org.springframework.websocket.server.HandshakeHandler;
import org.springframework.websocket.support.SimpleHandlerProvider; import org.springframework.websocket.support.SimpleHandlerProvider;
/** /**
* An {@link HttpRequestHandler} that wraps the invocation of a {@link HandshakeHandler}. * An {@link HttpRequestHandler} that wraps the invocation of a {@link HandshakeHandler}.
* *
@ -59,7 +58,6 @@ public class WebSocketHttpRequestHandler implements HttpRequestHandler {
public WebSocketHttpRequestHandler( HandlerProvider<WebSocketHandler> handlerProvider, public WebSocketHttpRequestHandler( HandlerProvider<WebSocketHandler> handlerProvider,
HandshakeHandler handshakeHandler) { HandshakeHandler handshakeHandler) {
Assert.notNull(handlerProvider, "handlerProvider is required"); Assert.notNull(handlerProvider, "handlerProvider is required");
Assert.notNull(handshakeHandler, "handshakeHandler is required"); Assert.notNull(handshakeHandler, "handshakeHandler is required");
this.handlerProvider = handlerProvider; this.handlerProvider = handlerProvider;

View File

@ -1,7 +1,22 @@
/*
* Copyright 2002-2013 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.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/** /**
* Server-side support classes including container-specific strategies for upgrading a request. * Server-side support classes including container-specific strategies for upgrading a
* * request.
*/ */
package org.springframework.websocket.server.support; package org.springframework.websocket.server.support;

View File

@ -26,7 +26,6 @@ import org.springframework.beans.factory.config.AutowireCapableBeanFactory;
import org.springframework.util.Assert; import org.springframework.util.Assert;
import org.springframework.websocket.HandlerProvider; import org.springframework.websocket.HandlerProvider;
/** /**
* A {@link HandlerProvider} that uses {@link AutowireCapableBeanFactory#createBean(Class) * A {@link HandlerProvider} that uses {@link AutowireCapableBeanFactory#createBean(Class)
* creating a fresh instance every time #getHandler() is called. * creating a fresh instance every time #getHandler() is called.
@ -48,6 +47,7 @@ public class BeanCreatingHandlerProvider<T> implements HandlerProvider<T>, BeanF
this.handlerClass = handlerClass; this.handlerClass = handlerClass;
} }
@Override @Override
public void setBeanFactory(BeanFactory beanFactory) throws BeansException { public void setBeanFactory(BeanFactory beanFactory) throws BeansException {
if (beanFactory instanceof AutowireCapableBeanFactory) { if (beanFactory instanceof AutowireCapableBeanFactory) {

View File

@ -13,12 +13,12 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package org.springframework.websocket.support; package org.springframework.websocket.support;
import org.springframework.util.ClassUtils; import org.springframework.util.ClassUtils;
import org.springframework.websocket.HandlerProvider; import org.springframework.websocket.HandlerProvider;
/** /**
* A {@link HandlerProvider} that returns a singleton instance. * A {@link HandlerProvider} that returns a singleton instance.
* *
@ -34,6 +34,7 @@ public class SimpleHandlerProvider<T> implements HandlerProvider<T> {
this.handler = handler; this.handler = handler;
} }
@Override @Override
public boolean isSingleton() { public boolean isSingleton() {
return true; return true;