0

Edit: Please do not downvote without leaving at least a comment.

I'd like to implement websocket in a SpringBoot application without Message Broker and STOMP. However, I need to access Spring Beans (repositories and services).

The Java API is so simple that I can't understand why Spring made it so complex.

Here's what I need:

I need to implement a websocket endpoint with dynamic URI so I can use @PathParam like this:

@ServerEndpoint(value = "/chat/{username}")
public class wsEndpoint

Using @EnableWebSocket with WebSocketConfigurer and TextWebSocketHandler only allows me to implement static endpoints.

The alternative recommended by Spring documentation is to implement Message Brokers and STOMP, which makes usage (IMHO) unnecessarily complex for most cases.

I really would like to use @EnableWebSocket with WebSocketConfigurer, TextWebSocketHandler and dynamic URIs. Is there a way to do so?

Sidney de Moraes
  • 993
  • 3
  • 11
  • 29
  • Why people downvote questions without any comment? – Sidney de Moraes Jan 18 '18 at 12:35
  • Are you in a Java EE environment? If yes, can you use Spring beans in a standard websocket implementation (Tyrus implementation of the JSR-356)? – Al-un Jan 24 '18 at 09:48
  • @Al1 AFAIK I can't because a standard websocket would not be a Spring bean itself, so I can't autowire anything. – Sidney de Moraes Jan 24 '18 at 13:29
  • Correcting myself. Just remembered I can add the standard websocket as a Bean through a configuration class, so yes. I can autowire things in there. But anyway my question regards to dynamic URIs. – Sidney de Moraes Jan 24 '18 at 13:31

0 Answers0