Allow WebSocketHandler methods to raise an exception.
By default we install ExceptionWebSocketHandlerDecorator, which logs
unhandled exceptions and closes the session. That decorator can be
extended or replaced.
Any exceptions that remain unhandled still (i.e. no exception handling
decorator), are caught in the lowest level before propagating to the
WebSocket engine or a SockJS transport handler and handled the same
way. That means default behavior is guaranteed but also fully
customizable.
WebSocketHandler implementations:
- methods must deal with exceptions locally
- uncaught runtime exceptions are handled by ending the session
- transport errors (websocket engine) are passed into handleError
WebSocketSession methods may raise IOException
SockJS implementation of WebSocketHandler:
- delegate SockJS transport errors into handleError
- stop runtime exceptions from user WebSocketHandler and end session
SockJsServce and TransportHandlers:
- raise IOException or TransportErrorException
HandshakeHandler:
- raise IOException
HandlerProvider is now an interface that can be used to plug in
WebSocket handlers with per-connection scope semantics. There are two
implementations, of the interface, one simple and a second that creates
handler instances through AutowireCapableBeanFactory.
HandlerProvider also provides a destroy method that is used to
apply a destroy callback whenever a client connection closes.
There is now a WebSocketMessage type with TextMessage and BinaryMessage
sub-types. WebSocketHandler is also sub-divided into TextMessageHandler
and BinaryMessageHandler, so that applications can choose to handle
text, binary, or both.
Also in this commit, the SockJsHandler and SockJsSession interfaces
have been removed. SockJsService now accepts WebSocketHandler.
As opposed to close(), which actively closes the session, the
onClosed method is called when the underlying connection has been
closed or disconnected.
Add HandlerProvider<T> class
Modify HandshakeHandler to accept + adapt WebSocketHandler at runtime
Modify SockJsService to accept + adapt SockJsHandler at runtime
This is useful to make sure response headers are written to the
underlying response. It is also useful in conjunction with long
running, async requests and HTTP streaming, to ensure the Servlet
response buffer is sent to the client without additional delay and
also causes an IOException to be raised if the client has gone away.
- configure SockJS handler by type (as well as by instance)
- add method to obtain SockJS handler instance via SockJsConfiguration
- detect presense of jsr-356 and use it if available