T - the common supertype of messages that can be decodedH - the type of "headers" messagesD - the type of "data" messagespublic abstract class AbstractContainerRequestDecoder<T,H extends T,D extends T> extends MessageToMessageDecoder<T>
MessageToMessageDecoder that decodes messages of a
specific type into ContainerRequests.
Instances of this class are normally followed in a ChannelPipeline by instances of the AbstractContainerRequestHandlingResponseWriter class.
ChannelHandler.Sharable| Modifier | Constructor and Description |
|---|---|
protected |
AbstractContainerRequestDecoder(URI baseUri,
Class<H> headersClass,
Class<D> dataClass)
Deprecated.
Please use the
AbstractContainerRequestDecoder(URI, Configuration, Class,
Class) constructor instead. |
protected |
AbstractContainerRequestDecoder(URI baseUri,
Configuration configuration,
Class<H> headersClass,
Class<D> dataClass)
Creates a new
AbstractContainerRequestDecoder implementation. |
protected |
AbstractContainerRequestDecoder(URI baseUri,
Supplier<? extends Configuration> configurationSupplier,
Class<H> headersClass,
Class<D> dataClass)
Creates a new
AbstractContainerRequestDecoder implementation. |
| Modifier and Type | Method and Description |
|---|---|
boolean |
acceptInboundMessage(Object message)
Returns
true if the supplied message is an
instance of either the headers type
or data type supplied at construction time, and false in
all other cases. |
void |
channelReadComplete(ChannelHandlerContext channelHandlerContext)
Overrides the
ChannelInboundHandlerAdapter.channelReadComplete(ChannelHandlerContext)
method to request a
read when necessary, taking the auto-read status of the associated
Channel into account. |
protected PropertiesDelegate |
createPropertiesDelegate(H message)
Creates and returns a
PropertiesDelegate appropriate for the
supplied message, which is guaranteed to be a "headers" message. |
protected SecurityContext |
createSecurityContext(H message)
Creates and returns a
SecurityContext appropriate for the
supplied message, which is guaranteed to be a "headers" message. |
protected TerminableByteBufInputStream |
createTerminableByteBufInputStream(ByteBufAllocator byteBufAllocator)
Creates and returns a new
TerminableByteBufInputStream. |
protected void |
decode(ChannelHandlerContext channelHandlerContext,
T message,
List<Object> out)
|
protected ByteBuf |
getContent(D message)
Extracts any content from the supplied "data" message as a
ByteBuf, or returns
null if there is no such content. |
protected abstract String |
getMethod(H message)
Extracts and returns a
String representing a request
method from the supplied message, which is guaranteed to be a
"headers" message. |
protected abstract String |
getRequestUriString(H message)
Extracts and returns a
String representing a request URI
from the supplied message, which is guaranteed to be a
"headers" message. |
protected void |
installMessage(ChannelHandlerContext channelHandlerContext,
H message,
ContainerRequest containerRequest)
Installs the supplied
message into the supplied ContainerRequest in some way. |
protected boolean |
isData(T message)
Returns
true if the supplied message represents a
"data" message (as distinguished from a "headers" message). |
protected boolean |
isHeaders(T message)
Returns
true if the supplied message represents a
"headers" message (as distinguished from a "data" message). |
protected abstract boolean |
isLast(T message)
Returns
true if there will be no further message
components in an overall larger message after the supplied one. |
channelReadchannelActive, channelInactive, channelRegistered, channelUnregistered, channelWritabilityChanged, exceptionCaught, userEventTriggeredensureNotSharable, handlerAdded, handlerRemoved, isSharableclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waithandlerAdded, handlerRemoved@Deprecated protected AbstractContainerRequestDecoder(URI baseUri, Class<H> headersClass, Class<D> dataClass)
AbstractContainerRequestDecoder(URI, Configuration, Class,
Class) constructor instead.AbstractContainerRequestDecoder implementation.baseUri - the base URI against which relative
request URIs will be resolved; may be null in which case
the return value of URI.create("/")
will be used insteadheadersClass - the type representing a "headers" message;
must not be nulldataClass - the type representing a "data" message; must not
be nullNullPointerException - if either headersClass or
dataClass is nullAbstractContainerRequestDecoder(URI, Configuration, Class,
Class)protected AbstractContainerRequestDecoder(URI baseUri, Configuration configuration, Class<H> headersClass, Class<D> dataClass)
AbstractContainerRequestDecoder implementation.baseUri - the base URI against which relative
request URIs will be resolved; may be null in which case
the return value of URI.create("/")
will be used insteadconfiguration - a Configuration describing how the
container is configured; may be nullheadersClass - the type representing a "headers" message;
must not be nulldataClass - the type representing a "data" message; must not
be nullNullPointerException - if either headersClass or
dataClass is nullprotected AbstractContainerRequestDecoder(URI baseUri, Supplier<? extends Configuration> configurationSupplier, Class<H> headersClass, Class<D> dataClass)
AbstractContainerRequestDecoder implementation.baseUri - the base URI against which relative
request URIs will be resolved; may be null in which case
the return value of URI.create("/")
will be used insteadconfigurationSupplier - a Supplier of Configuration instances describing how the container is
configured; may be nullheadersClass - the type representing a "headers" message;
must not be nulldataClass - the type representing a "data" message; must not
be nullNullPointerException - if either headersClass or
dataClass is nullpublic void channelReadComplete(ChannelHandlerContext channelHandlerContext) throws Exception
ChannelInboundHandlerAdapter.channelReadComplete(ChannelHandlerContext)
method to request a
read when necessary, taking the auto-read status of the associated
Channel into account.channelReadComplete in interface ChannelInboundHandlerchannelReadComplete in class ChannelInboundHandlerAdapterchannelHandlerContext - the ChannelHandlerContext in
effect; must not be nullNullPointerException - if channelHandlerContext
is nullExceptionChannelConfig.isAutoRead(),
ChannelInboundHandlerAdapter.channelReadComplete(ChannelHandlerContext)public boolean acceptInboundMessage(Object message)
true if the supplied message is an
instance of either the headers type
or data type supplied at construction time, and false in
all other cases.acceptInboundMessage in class MessageToMessageDecoder<T>message - the message to interrogate; may be null in
which case false will be returnedtrue if the supplied message is an
instance of either the headers type
or data type supplied at construction time; false in all
other casesAbstractContainerRequestDecoder(URI, Class, Class)protected boolean isHeaders(T message)
true if the supplied message represents a
"headers" message (as distinguished from a "data" message).message - the message to interrogate; will not be nulltrue if the supplied message represents a
"headers" message; false otherwiseisData(Object)protected abstract String getRequestUriString(H message)
String representing a request URI
from the supplied message, which is guaranteed to be a
"headers" message.
Implementations of this method may return null but
normally will not.
message - the message to interrogate; will not be nullString representing a request URI from the
supplied message, or nullprotected abstract String getMethod(H message)
String representing a request
method from the supplied message, which is guaranteed to be a
"headers" message.
Implementations of this method may return null but
normally will not.
message - the message to interrogate; will not be nullString representing a request method from the
supplied message, or nullprotected SecurityContext createSecurityContext(H message)
SecurityContext appropriate for the
supplied message, which is guaranteed to be a "headers" message.
Implementations of this method must not return null.
message - the "headers"
message for which a new SecurityContext is to be
returned; will not be nullnull SecurityContextprotected PropertiesDelegate createPropertiesDelegate(H message)
PropertiesDelegate appropriate for the
supplied message, which is guaranteed to be a "headers" message.
Implementations of this method must not return null.
message - the "headers"
message for which a new PropertiesDelegate is to be
returned; will not be nullnull PropertiesDelegateprotected void installMessage(ChannelHandlerContext channelHandlerContext, H message, ContainerRequest containerRequest)
message into the supplied ContainerRequest in some way.
This implementation calls ContainerRequest.setProperty(String, Object) with the
fully-qualified class name of the
headers class supplied at construction time as the key, and the
supplied message as the value.
channelHandlerContext - the ChannelHandlerContext in
effect; will not be null; supplied for convenience;
overrides may (and often do) ignore this parametermessage - the message to install; will not be null
and is guaranteed to be a "headers" messagecontainerRequest - the just-constructed ContainerRequest into which to install the supplied message; will not be nullprotected boolean isData(T message)
true if the supplied message represents a
"data" message (as distinguished from a "headers" message).message - the message to interrogate; will not be nulltrue if the supplied message represents a
"data" message; false otherwiseisHeaders(Object)protected ByteBuf getContent(D message)
ByteBuf, or returns
null if there is no such content.message - the "data" message
from which a ByteBuf is to be extracted; will not be
nullByteBuf representing the message's content, or
nullprotected abstract boolean isLast(T message)
true if there will be no further message
components in an overall larger message after the supplied one.protected final void decode(ChannelHandlerContext channelHandlerContext, T message, List<Object> out)
decode in class MessageToMessageDecoder<T>channelHandlerContext - the ChannelHandlerContext in
effect; must not be nullmessage - the message to decode; must not be null
and must be acceptableout - a List of Objects that result from
decoding the supplied message; must not be null
and must be mutableNullPointerException - if channelHandlerContext
or out is nullIllegalArgumentException - if message is null or otherwise unacceptableIllegalStateException - if there is an internal problem
with state managementprotected TerminableByteBufInputStream createTerminableByteBufInputStream(ByteBufAllocator byteBufAllocator)
TerminableByteBufInputStream.byteBufAllocator - a ByteBufAllocator that may be
used or ignored; will not be nullnull TerminableByteBufInputStreamCopyright © 2019–2020, microBean™. All rights reserved.