WebSocketHandler that initializes and destroys a WebSocketHandler
instance for each WebSocket connection and delegates all other methods to it.
Essentially create an instance of this class once, providing the type of
WebSocketHandler class to create for each connection, and then pass it to any
API method that expects a WebSocketHandler.
If initializing the target WebSocketHandler type requires a Spring
BeanFactory, then the setBeanFactory(BeanFactory) property accordingly. Simply
declaring this class as a Spring bean will do that. Otherwise, WebSocketHandler
instances of the target type will be created using the default constructor.
| Modifier and Type | Field and Description |
|---|---|
| private final Map | |
| private static final Log | |
| private final BeanCreatingHandlerProvider | |
| private final boolean |
| Access | Constructor and Description |
|---|---|
| public | |
| public | PerConnectionWebSocketHandler(Class<? extends WebSocketHandler> handlerType, boolean supportsPartialMessages)
|
| Modifier and Type | Method and Description |
|---|---|
| public void | afterConnectionClosed(WebSocketSession session, CloseStatus closeStatus)
Implements org. Invoked after the WebSocket connection has been closed by either side, or after a transport error has occurred. |
| public void | afterConnectionEstablished(WebSocketSession session)
Implements org. Invoked after WebSocket negotiation has succeeded and the WebSocket connection is opened and ready for use. |
| private void | |
| private WebSocketHandler | |
| public void | handleMessage(WebSocketSession session, WebSocketMessage<?> message)
Implements org. Invoked when a new WebSocket message arrives. |
| public void | handleTransportError(WebSocketSession session, Throwable exception)
Implements org. Handle an error from the underlying WebSocket message transport. |
| public void | setBeanFactory(BeanFactory
owning BeanFactory (never beanFactory)null).
The bean can immediately call methods on the factory.Implements org. Callback that supplies the owning factory to a bean instance. |
| public boolean | supportsPartialMessages()
Implements org. Whether the WebSocketHandler handles partial messages. |
| public String |
| handlers | back to summary |
|---|---|
| private final Map<WebSocketSession, WebSocketHandler> handlers | |
| logger | back to summary |
|---|---|
| private static final Log logger | |
| provider | back to summary |
|---|---|
| private final BeanCreatingHandlerProvider<WebSocketHandler> provider | |
| supportsPartialMessages | back to summary |
|---|---|
| private final boolean supportsPartialMessages | |
| PerConnectionWebSocketHandler | back to summary |
|---|---|
| public PerConnectionWebSocketHandler(Class<? extends WebSocketHandler> handlerType) | |
| PerConnectionWebSocketHandler | back to summary |
|---|---|
| public PerConnectionWebSocketHandler(Class<? extends WebSocketHandler> handlerType, boolean supportsPartialMessages) | |
| afterConnectionClosed | back to summary |
|---|---|
| public void afterConnectionClosed(WebSocketSession session, CloseStatus closeStatus) throws Exception Implements org. Doc from org. Invoked after the WebSocket connection has been closed by either side, or after a transport error has occurred. Although the session may technically still be open, depending on the underlying implementation, sending messages at this point is discouraged and most likely will not succeed. | |
| afterConnectionEstablished | back to summary |
|---|---|
| public void afterConnectionEstablished(WebSocketSession session) throws Exception Implements org. Doc from org. Invoked after WebSocket negotiation has succeeded and the WebSocket connection is opened and ready for use. | |
| destroyHandler | back to summary |
|---|---|
| private void destroyHandler(WebSocketSession session) | |
| getHandler | back to summary |
|---|---|
| private WebSocketHandler getHandler(WebSocketSession session) | |
| handleMessage | back to summary |
|---|---|
| public void handleMessage(WebSocketSession session, WebSocketMessage<?> message) throws Exception Implements org. Doc from org. Invoked when a new WebSocket message arrives. | |
| handleTransportError | back to summary |
|---|---|
| public void handleTransportError(WebSocketSession session, Throwable exception) throws Exception Implements org. Doc from org. Handle an error from the underlying WebSocket message transport. | |
| setBeanFactory | back to summary |
|---|---|
| public void setBeanFactory(BeanFactory beanFactory) Implements org. Doc from org. Callback that supplies the owning factory to a bean instance. Invoked after the population of normal bean properties
but before an initialization callback such as
| |
| supportsPartialMessages | back to summary |
|---|---|
| public boolean supportsPartialMessages() Implements org. Doc from org. Whether the WebSocketHandler handles partial messages. If this flag is set to
| |
| toString | back to summary |
|---|---|
| public String toString() Overrides java. Doc from java. Returns a string representation of the object.
Satisfying this method's contract implies a non- | |