Polish WebMvcStompEndpointRegistry
This commit is contained in:
parent
d1cc8bac5c
commit
b6b76ad1b4
|
|
@ -17,6 +17,7 @@
|
|||
package org.springframework.web.socket.config.annotation;
|
||||
|
||||
import org.springframework.web.socket.messaging.StompSubProtocolErrorHandler;
|
||||
import org.springframework.web.util.UrlPathHelper;
|
||||
|
||||
/**
|
||||
* A contract for registering STOMP over WebSocket endpoints.
|
||||
|
|
@ -31,6 +32,19 @@ public interface StompEndpointRegistry {
|
|||
*/
|
||||
StompWebSocketEndpointRegistration addEndpoint(String... paths);
|
||||
|
||||
/**
|
||||
* Set the order of the {@link org.springframework.web.servlet.HandlerMapping}
|
||||
* used for STOMP endpoints relative to other Spring MVC handler mappings.
|
||||
* <p>By default this is set to 1.
|
||||
*/
|
||||
void setOrder(int order);
|
||||
|
||||
/**
|
||||
* Configure a customized {@link UrlPathHelper} for the STOMP endpoint
|
||||
* {@link org.springframework.web.servlet.HandlerMapping HandlerMapping}.
|
||||
*/
|
||||
void setUrlPathHelper(UrlPathHelper urlPathHelper);
|
||||
|
||||
/**
|
||||
* Configure a handler for customizing or handling STOMP ERROR frames to clients.
|
||||
* @param errorHandler the error handler
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2014 the original author or authors.
|
||||
* Copyright 2002-2015 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.
|
||||
|
|
@ -47,6 +47,12 @@ public class WebMvcStompEndpointRegistry implements StompEndpointRegistry {
|
|||
|
||||
private final WebSocketHandler webSocketHandler;
|
||||
|
||||
private final TaskScheduler sockJsScheduler;
|
||||
|
||||
private int order = 1;
|
||||
|
||||
private UrlPathHelper urlPathHelper;
|
||||
|
||||
private final SubProtocolWebSocketHandler subProtocolWebSocketHandler;
|
||||
|
||||
private final StompSubProtocolHandler stompHandler;
|
||||
|
|
@ -54,12 +60,6 @@ public class WebMvcStompEndpointRegistry implements StompEndpointRegistry {
|
|||
private final List<WebMvcStompWebSocketEndpointRegistration> registrations =
|
||||
new ArrayList<WebMvcStompWebSocketEndpointRegistration>();
|
||||
|
||||
private final TaskScheduler sockJsScheduler;
|
||||
|
||||
private int order = 1;
|
||||
|
||||
private UrlPathHelper urlPathHelper;
|
||||
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public WebMvcStompEndpointRegistry(WebSocketHandler webSocketHandler,
|
||||
|
|
@ -91,9 +91,9 @@ public class WebMvcStompEndpointRegistry implements StompEndpointRegistry {
|
|||
this.sockJsScheduler = defaultSockJsTaskScheduler;
|
||||
}
|
||||
|
||||
private static SubProtocolWebSocketHandler unwrapSubProtocolWebSocketHandler(WebSocketHandler wsHandler) {
|
||||
WebSocketHandler actual = WebSocketHandlerDecorator.unwrap(wsHandler);
|
||||
Assert.isInstanceOf(SubProtocolWebSocketHandler.class, actual, "No SubProtocolWebSocketHandler in " + wsHandler);
|
||||
private static SubProtocolWebSocketHandler unwrapSubProtocolWebSocketHandler(WebSocketHandler handler) {
|
||||
WebSocketHandler actual = WebSocketHandlerDecorator.unwrap(handler);
|
||||
Assert.isInstanceOf(SubProtocolWebSocketHandler.class, actual, "No SubProtocolWebSocketHandler in " + handler);
|
||||
return (SubProtocolWebSocketHandler) actual;
|
||||
}
|
||||
|
||||
|
|
@ -115,11 +115,12 @@ public class WebMvcStompEndpointRegistry implements StompEndpointRegistry {
|
|||
* other handler mappings configured in Spring MVC.
|
||||
* <p>The default value is 1.
|
||||
*/
|
||||
@Override
|
||||
public void setOrder(int order) {
|
||||
this.order = order;
|
||||
}
|
||||
|
||||
public int getOrder() {
|
||||
protected int getOrder() {
|
||||
return this.order;
|
||||
}
|
||||
|
||||
|
|
@ -127,11 +128,12 @@ public class WebMvcStompEndpointRegistry implements StompEndpointRegistry {
|
|||
* Set the UrlPathHelper to configure on the {@code SimpleUrlHandlerMapping}
|
||||
* used to map handshake requests.
|
||||
*/
|
||||
@Override
|
||||
public void setUrlPathHelper(UrlPathHelper urlPathHelper) {
|
||||
this.urlPathHelper = urlPathHelper;
|
||||
}
|
||||
|
||||
public UrlPathHelper getUrlPathHelper() {
|
||||
protected UrlPathHelper getUrlPathHelper() {
|
||||
return this.urlPathHelper;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue