[undertow-dev] Dealing with different request types in a consistent manner

Stuart Douglas stuart.w.douglas at gmail.com
Sat Mar 2 17:47:20 EST 2013


So I have been thinking a bit about how to handle different request 
types in a consistent manner. In particular, at the moment we have the 
following types of request:

- Native non-blocking
- Native blocking
- Servlet blocking

This makes it very hard to write handlers that are re-usable by all 
three request types, for example if we want to write some code that 
handles web socket upgrades we will need three separate slightly 
different implementations.

To get around this in web sockets I added the following SPI interface:

https://github.com/undertow-io/undertow/blob/master/websockets/src/main/java/io/undertow/websockets/spi/WebSocketHttpExchange.java

This abstracts away the details of the underling request, and makes it 
possible to write a handler that deals with all three cases 
consistently. Unless anyone objects, I am going to look at moving this 
concept into undertow core, to hopefully make it easier to write generic 
handlers that are usable for all request types.

Stuart


More information about the undertow-dev mailing list