Skip to content

Commit 4372dac

Browse files
committed
Polish
1 parent 0dddb6f commit 4372dac

File tree

2 files changed

+6
-17
lines changed

2 files changed

+6
-17
lines changed

spring-websocket/src/main/java/org/springframework/web/socket/config/annotation/WebMvcStompEndpointRegistry.java

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,7 @@
2121
import java.util.List;
2222
import java.util.Map;
2323

24-
import org.springframework.beans.BeansException;
2524
import org.springframework.context.ApplicationContext;
26-
import org.springframework.context.ApplicationContextAware;
2725
import org.springframework.messaging.simp.user.UserSessionRegistry;
2826
import org.springframework.scheduling.TaskScheduler;
2927
import org.springframework.util.Assert;
@@ -44,7 +42,7 @@
4442
* @author Artem Bilan
4543
* @since 4.0
4644
*/
47-
public class WebMvcStompEndpointRegistry implements StompEndpointRegistry, ApplicationContextAware {
45+
public class WebMvcStompEndpointRegistry implements StompEndpointRegistry {
4846

4947
private final WebSocketHandler webSocketHandler;
5048

@@ -88,17 +86,15 @@ public WebMvcStompEndpointRegistry(WebSocketHandler webSocketHandler,
8886
this.sockJsScheduler = defaultSockJsTaskScheduler;
8987
}
9088

91-
@Override
92-
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
93-
this.stompHandler.setApplicationEventPublisher(applicationContext);
94-
}
95-
9689
private static SubProtocolWebSocketHandler unwrapSubProtocolWebSocketHandler(WebSocketHandler wsHandler) {
9790
WebSocketHandler actual = WebSocketHandlerDecorator.unwrap(wsHandler);
9891
Assert.isInstanceOf(SubProtocolWebSocketHandler.class, actual, "No SubProtocolWebSocketHandler in " + wsHandler);
9992
return (SubProtocolWebSocketHandler) actual;
10093
}
10194

95+
protected void setApplicationContext(ApplicationContext applicationContext) {
96+
this.stompHandler.setApplicationEventPublisher(applicationContext);
97+
}
10298

10399
@Override
104100
public StompWebSocketEndpointRegistration addEndpoint(String... paths) {

spring-websocket/src/main/java/org/springframework/web/socket/config/annotation/WebSocketMessageBrokerConfigurationSupport.java

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -51,18 +51,11 @@ protected WebSocketMessageBrokerConfigurationSupport() {
5151
@Bean
5252
public HandlerMapping stompWebSocketHandlerMapping() {
5353

54-
WebSocketHandler webSocketHandler = subProtocolWebSocketHandler();
55-
UserSessionRegistry sessionRegistry = userSessionRegistry();
56-
WebSocketTransportRegistration transportRegistration = getTransportRegistration();
57-
ThreadPoolTaskScheduler taskScheduler = messageBrokerSockJsTaskScheduler();
58-
59-
WebMvcStompEndpointRegistry registry = new WebMvcStompEndpointRegistry(
60-
webSocketHandler, transportRegistration, sessionRegistry, taskScheduler);
54+
WebMvcStompEndpointRegistry registry = new WebMvcStompEndpointRegistry(subProtocolWebSocketHandler(),
55+
getTransportRegistration(), userSessionRegistry(), messageBrokerSockJsTaskScheduler());
6156

6257
registry.setApplicationContext(getApplicationContext());
63-
6458
registerStompEndpoints(registry);
65-
6659
return registry.getHandlerMapping();
6760
}
6861

0 commit comments

Comments
 (0)