public final class HttpContainerRequestHandlingResponseWriter extends AbstractContainerRequestHandlingResponseWriter<HttpContent>
AbstractContainerRequestHandlingResponseWriter
implemented in terms of HttpRequest
s, HttpResponse
s
and ByteBufBackedChannelOutboundInvokingHttpContentOutputStream
s.ContainerResponseWriter.TimeoutHandler
ChannelHandler.Sharable
Constructor and Description |
---|
HttpContainerRequestHandlingResponseWriter(ApplicationHandler applicationHandler)
Creates a new
HttpContainerRequestHandlingResponseWriter . |
HttpContainerRequestHandlingResponseWriter(ApplicationHandler applicationHandler,
int flushThreshold,
AbstractByteBufBackedChannelOutboundInvokingOutputStream.ByteBufCreator byteBufCreator)
Creates a new
HttpContainerRequestHandlingResponseWriter . |
HttpContainerRequestHandlingResponseWriter(Supplier<? extends ApplicationHandler> applicationHandlerSupplier)
Creates a new
HttpContainerRequestHandlingResponseWriter . |
HttpContainerRequestHandlingResponseWriter(Supplier<? extends ApplicationHandler> applicationHandlerSupplier,
int flushThreshold,
AbstractByteBufBackedChannelOutboundInvokingOutputStream.ByteBufCreator byteBufCreator)
Creates a new
HttpContainerRequestHandlingResponseWriter . |
Modifier and Type | Method and Description |
---|---|
void |
commit()
Overrides
AbstractContainerRequestHandlingResponseWriter.commit() to still
effectively do nothing, but clean up some internal state. |
protected AbstractChannelOutboundInvokingOutputStream<? extends HttpContent> |
createOutputStream(long contentLength,
ContainerResponse containerResponse)
Creates and returns a new
ByteBufBackedChannelOutboundInvokingHttpContentOutputStream . |
protected void |
writeFailureMessage(Throwable failureCause)
Writes an appropriate failure message using the return value of
the
AbstractContainerRequestHandlingResponseWriter.getChannelHandlerContext() method. |
protected boolean |
writeStatusAndHeaders(long contentLength,
ContainerResponse containerResponse)
Writes the status and headers portion of the response present in
the supplied
ContainerResponse and returns true
if further output is forthcoming. |
channelActive, channelRead, channelReadComplete, copyHeaders, enableResponseBuffering, failure, getByteBufCreator, getChannelHandlerContext, getFlushThreshold, setSuspendTimeout, suspend, writeResponseStatusAndHeaders
channelInactive, channelRegistered, channelUnregistered, channelWritabilityChanged, exceptionCaught, userEventTriggered
ensureNotSharable, handlerAdded, handlerRemoved, isSharable
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
handlerAdded, handlerRemoved
public HttpContainerRequestHandlingResponseWriter(ApplicationHandler applicationHandler)
HttpContainerRequestHandlingResponseWriter
.applicationHandler
- an ApplicationHandler
representing a Jakarta RESTful Web Services application
whose ApplicationHandler.handle(ContainerRequest)
method
will serve as the bridge between Netty and Jersey; may be null
somewhat pathologically but normally is notApplicationHandler
,
ApplicationHandler.handle(ContainerRequest)
public HttpContainerRequestHandlingResponseWriter(ApplicationHandler applicationHandler, int flushThreshold, AbstractByteBufBackedChannelOutboundInvokingOutputStream.ByteBufCreator byteBufCreator)
HttpContainerRequestHandlingResponseWriter
.applicationHandler
- an ApplicationHandler
representing a Jakarta RESTful Web Services application
whose ApplicationHandler.handle(ContainerRequest)
method
will serve as the bridge between Netty and Jersey; may be null
somewhat pathologically but normally is notflushThreshold
- the minimum number of bytes that an OutputStream
returned by the createOutputStream(long,
ContainerResponse)
method must write before an automatic
flush may take place; if less
than 0
0
will be used instead; if Integer.MAX_VALUE
then it is suggested that no automatic
flushing will occurbyteBufCreator
- a AbstractByteBufBackedChannelOutboundInvokingOutputStream.ByteBufCreator
that will be used
by the createOutputStream(long, ContainerResponse)
method; may be null
ApplicationHandler
,
ApplicationHandler.handle(ContainerRequest)
public HttpContainerRequestHandlingResponseWriter(Supplier<? extends ApplicationHandler> applicationHandlerSupplier)
HttpContainerRequestHandlingResponseWriter
.applicationHandlerSupplier
- a Supplier
of an ApplicationHandler
representing a Jakarta RESTful Web Services application
whose ApplicationHandler.handle(ContainerRequest)
method
will serve as the bridge between Netty and Jersey; may be null
somewhat pathologically but normally is notApplicationHandler
,
ApplicationHandler.handle(ContainerRequest)
public HttpContainerRequestHandlingResponseWriter(Supplier<? extends ApplicationHandler> applicationHandlerSupplier, int flushThreshold, AbstractByteBufBackedChannelOutboundInvokingOutputStream.ByteBufCreator byteBufCreator)
HttpContainerRequestHandlingResponseWriter
.applicationHandlerSupplier
- a Supplier
of an ApplicationHandler
representing a Jakarta RESTful Web Services application
whose ApplicationHandler.handle(ContainerRequest)
method
will serve as the bridge between Netty and Jersey; may be null
somewhat pathologically but normally is notflushThreshold
- the minimum number of bytes that an OutputStream
returned by the createOutputStream(long,
ContainerResponse)
method must write before an automatic
flush may take place; if less
than 0
0
will be used instead; if Integer.MAX_VALUE
then it is suggested that no automatic
flushing will occurbyteBufCreator
- a AbstractByteBufBackedChannelOutboundInvokingOutputStream.ByteBufCreator
that will be used
by the createOutputStream(long, ContainerResponse)
method; may be null
ApplicationHandler
,
ApplicationHandler.handle(ContainerRequest)
protected final boolean writeStatusAndHeaders(long contentLength, ContainerResponse containerResponse)
ContainerResponse
and returns true
if further output is forthcoming.
This implementation writes an instance of either DefaultHttpResponse
or DefaultFullHttpResponse
.
writeStatusAndHeaders
in class AbstractContainerRequestHandlingResponseWriter<HttpContent>
contentLength
- the content length as determined by the
logic encapsulated by the ApplicationHandler.handle(ContainerRequest)
method; a value less
than zero indicates an unknown content lengthcontainerResponse
- the ContainerResponse
containing
status and headers information; must not be null
true
if the createOutputStream(long,
ContainerResponse)
method should be invoked, i.e. if
further output is forthcomingNullPointerException
- if containerResponse
is
null
IllegalArgumentException
- if the supplied ContainerResponse
returns null
from its ContainerResponse.getRequestContext()
method or if that ContainerRequest
returns something that is not an HttpRequest
from invoking getProperty("io.netty.handler.codec.http.HttpRequest")
on itApplicationHandler.handle(ContainerRequest)
,
createOutputStream(long, ContainerResponse)
protected final AbstractChannelOutboundInvokingOutputStream<? extends HttpContent> createOutputStream(long contentLength, ContainerResponse containerResponse)
ByteBufBackedChannelOutboundInvokingHttpContentOutputStream
.
This method never returns null
.
createOutputStream
in class AbstractContainerRequestHandlingResponseWriter<HttpContent>
contentLength
- the content length as determined by the
logic encapsulated by the ApplicationHandler.handle(ContainerRequest)
method; must not be
0L
containerResponse
- a ContainerResponse
for which an
OutputStream
is being created and returned; must not be
null
; ignored by this implementationByteBufBackedChannelOutboundInvokingHttpContentOutputStream
NullPointerException
- if containerResponse
is
null
or if AbstractContainerRequestHandlingResponseWriter.getChannelHandlerContext()
returns
null
IllegalArgumentException
- if contentLength
is
0L
ByteBufBackedChannelOutboundInvokingHttpContentOutputStream
public final void commit()
AbstractContainerRequestHandlingResponseWriter.commit()
to still
effectively do nothing, but clean up some internal state.commit
in interface ContainerResponseWriter
commit
in class AbstractContainerRequestHandlingResponseWriter<HttpContent>
AbstractContainerRequestHandlingResponseWriter.commit()
protected final void writeFailureMessage(Throwable failureCause)
AbstractContainerRequestHandlingResponseWriter.getChannelHandlerContext()
method.writeFailureMessage
in class AbstractContainerRequestHandlingResponseWriter<HttpContent>
failureCause
- the Throwable
responsible for this
method's invocation; may be null
in pathological cases;
ignored by this implementationNullPointerException
- if AbstractContainerRequestHandlingResponseWriter.getChannelHandlerContext()
returns null
Copyright © 2019–2020, microBean™. All rights reserved.