public class HttpWebHandlerAdapter extends WebHandlerDecorator implements HttpHandler
WebHandler
to the HttpHandler
contract.
By default creates and configures a DefaultServerWebExchange
and
then invokes the target WebHandler
.
Modifier and Type | Field and Description |
---|---|
private ServerCodecConfigurer |
codecConfigurer |
private static java.util.Set<java.lang.String> |
DISCONNECTED_CLIENT_EXCEPTIONS
Tomcat: ClientAbortException or EOFException
Jetty: EofException
WildFly, GlassFish: java.io.IOException "Broken pipe" (already covered)
|
private static java.lang.String |
DISCONNECTED_CLIENT_LOG_CATEGORY
Dedicated log category for disconnected client exceptions.
|
private static Log |
disconnectedClientLogger |
private LocaleContextResolver |
localeContextResolver |
private static Log |
logger |
private WebSessionManager |
sessionManager |
Constructor and Description |
---|
HttpWebHandlerAdapter(WebHandler delegate) |
getDelegate, handle, toString
private static final java.lang.String DISCONNECTED_CLIENT_LOG_CATEGORY
Servlet containers do not expose a notification when a client disconnects, e.g. SERVLET_SPEC-44.
To avoid filling logs with unnecessary stack traces, we make an effort to identify such network failures on a per-server basis, and then log under a separate log category a simple one-line message at DEBUG level or a full stack trace only at TRACE level.
private static final java.util.Set<java.lang.String> DISCONNECTED_CLIENT_EXCEPTIONS
TODO: This definition is currently duplicated between HttpWebHandlerAdapter and AbstractSockJsSession. It is a candidate for a common utility class.
indicatesDisconnectedClient(Throwable)
private static final Log logger
private static final Log disconnectedClientLogger
private WebSessionManager sessionManager
@Nullable private ServerCodecConfigurer codecConfigurer
@Nullable private LocaleContextResolver localeContextResolver
public HttpWebHandlerAdapter(WebHandler delegate)
public void setSessionManager(WebSessionManager sessionManager)
WebSessionManager
to use for managing web
sessions. The provided instance is set on each created
DefaultServerWebExchange
.
By default this is set to DefaultWebSessionManager
.
sessionManager
- the session manager to usepublic WebSessionManager getSessionManager()
WebSessionManager
.public void setCodecConfigurer(ServerCodecConfigurer codecConfigurer)
ServerCodecConfigurer
. The provided instance is set on
each created DefaultServerWebExchange
.
By default this is set to ServerCodecConfigurer.create()
.
codecConfigurer
- the codec configurer to usepublic void setLocaleContextResolver(LocaleContextResolver localeContextResolver)
LocaleContextResolver
. The provided instance is set on
each created DefaultServerWebExchange
.
By default this is set to
AcceptHeaderLocaleContextResolver
.
localeContextResolver
- the locale context resolver to usepublic ServerCodecConfigurer getCodecConfigurer()
ServerCodecConfigurer
.public LocaleContextResolver getLocaleContextResolver()
LocaleContextResolver
.public <any> handle(ServerHttpRequest request, ServerHttpResponse response)
HttpHandler
handle
in interface HttpHandler
request
- current requestresponse
- current responseprotected ServerWebExchange createExchange(ServerHttpRequest request, ServerHttpResponse response)
private void logHandleFailure(java.lang.Throwable ex)
private boolean indicatesDisconnectedClient(java.lang.Throwable ex)