In this class @Autowired is work
@Configuration
@EnableWebSocket
public class WebSocketConfig implements WebSocketConfigurer {
@Autowired
private UserDAO userDAO; // is NOT null
@Autowired
private IArticleService articleService; // is NOT null
public void registerWebSocketHandlers(WebSocketHandlerRegistry registry) {
registry.addHandler(new SocketTextHandler(), "/user").addInterceptors(new HttpHandshakeInterceptor());
}
}
In this class @Autowired is NOT work
public class HttpHandshakeInterceptor implements HandshakeInterceptor {
@Autowired
private IArticleService articleService; // is null
@Autowired
private UserDAO userDAO; // is null
public void afterHandshake(ServerHttpRequest request, ServerHttpResponse response, WebSocketHandler wsHandler, Exception ex) {
}
Maybe this is something like a channel wss?