ChannelHandler that aggregates a series of message objects into a single aggregated message.
'A series of messages' is composed of the following:
isLastContentMessage(AutoCloseable)
return true for, the aggregator will finish the aggregation and produce the aggregated message and expect
another start message.
| Modifier and Type | Field and Description |
|---|---|
| private boolean | |
| private FutureContextListener | |
| private ChannelHandlerContext | |
| private A | |
| private boolean | |
| private final int |
| Access | Constructor and Description |
|---|---|
| protected | MessageAggregator(int
the maximum length of the aggregated content.
If the length of the aggregated content exceeds this value,
maxContentLength)handleOversizedMessage(ChannelHandlerContext, Object) will be called.Creates a new instance. |
| protected |
| Modifier and Type | Method and Description |
|---|---|
| public boolean | acceptInboundMessage(Object msg)
Overrides io. true if the given message should be handled.
|
| protected abstract void | aggregate(BufferAllocator allocator, A aggregated, C content)
Aggregated the passed |
| protected abstract A | beginAggregation(BufferAllocator allocator, S start)
Creates a new aggregated message from the specified start message. |
| public void | channelInactive(ChannelHandlerContext ctx)
Overrides default io. Channel of the ChannelHandlerContext was registered is now inactive and reached its
end of lifetime.
|
| public void | channelReadComplete(ChannelHandlerContext ctx)
Overrides default io. channelRead(ChannelHandlerContext, Object).
|
| protected abstract boolean | Returns: true if the channel should be closed after the result of
newContinueResponse(Object, int, ChannelPipeline) is written. false otherwise.The return value from msg)newContinueResponse(Object, int, ChannelPipeline).Determine if the channel should be closed after the result of
|
| protected final ChannelHandlerContext | |
| protected void | decode(final ChannelHandlerContext
the ctx, I ChannelHandlerContext which this MessageToMessageDecoder belongs tothe message to decode to another one msg)Overrides io. |
| protected void | finishAggregation(BufferAllocator allocator, A aggregated)
Invoked when the specified |
| private void | |
| protected void | handleOversizedMessage(ChannelHandlerContext ctx, Object
the accumulated message up to this point. oversized)Invoked when an incoming request exceeds the maximum content length. |
| public void | handlerAdded(ChannelHandlerContext ctx)
Overrides default io. ChannelHandler was added to the actual context and it's ready to handle events.
|
| public void | handlerRemoved(ChannelHandlerContext ctx)
Overrides default io. ChannelHandler was removed from the actual context and it doesn't handle events
anymore.
|
| protected abstract boolean | Returns: true if all objects for the current request/response should be ignored or not.
false otherwise.The return value from msg)newContinueResponse(Object, int, ChannelPipeline).Determine if all objects for the current request/response should be ignored or not. |
| private void | |
| protected abstract boolean | |
| protected abstract boolean | Returns: true if the message start's content length is known, and if it greater than
maxContentLength. false otherwise.The message which may indicate the content length. start, int The maximum allowed content length. maxContentLength)Determine if the message |
| protected abstract boolean | isLastContentMessage(C msg)
Returns |
| protected abstract int | Returns: Length in bytes of the passed message.to calculate length. msg)Returns the length in bytes of the passed message. |
| protected abstract int | Returns: Length in bytes of the passed message.to calculate length. msg)Returns the length in bytes of the passed message. |
| public final int | |
| protected abstract Object | Returns: the 'continue response', ornull if there's no message to sendReturns the 'continue response' for the specified start message if necessary. |
| private void | |
| protected abstract C | tryContentMessage(Object msg)
If the passed |
| protected abstract S | tryStartMessage(Object msg)
If the passed |
| private static void |
| aggregating | back to summary |
|---|---|
| private boolean aggregating | |
| continueResponseWriteListener | back to summary |
|---|---|
| private FutureContextListener<ChannelHandlerContext, Void> continueResponseWriteListener | |
| ctx | back to summary |
|---|---|
| private ChannelHandlerContext ctx | |
| currentMessage | back to summary |
|---|---|
| private A currentMessage | |
| handlingOversizedMessage | back to summary |
|---|---|
| private boolean handlingOversizedMessage | |
| maxContentLength | back to summary |
|---|---|
| private final int maxContentLength | |
| MessageAggregator | back to summary |
|---|---|
| protected MessageAggregator(int maxContentLength) Creates a new instance.
| |
| MessageAggregator | back to summary |
|---|---|
| protected MessageAggregator(int maxContentLength, Class<? extends I> inboundMessageType) | |
| acceptInboundMessage | back to summary |
|---|---|
| public boolean acceptInboundMessage(Object msg) throws Exception Overrides io. Doc from io. Returns
| |
| aggregate | back to summary |
|---|---|
| protected abstract void aggregate(BufferAllocator allocator, A aggregated, C content) throws Exception Aggregated the passed | |
| beginAggregation | back to summary |
|---|---|
| protected abstract A beginAggregation(BufferAllocator allocator, S start) throws Exception Creates a new aggregated message from the specified start message. | |
| channelInactive | back to summary |
|---|---|
| public void channelInactive(ChannelHandlerContext ctx) throws Exception Overrides default io. Doc from io. The
| |
| channelReadComplete | back to summary |
|---|---|
| public void channelReadComplete(ChannelHandlerContext ctx) throws Exception Overrides default io. Doc from io. Invoked when the last message read by the current read operation has been consumed by
| |
| closeAfterContinueResponse | back to summary |
|---|---|
| protected abstract boolean closeAfterContinueResponse(Object msg) throws Exception Determine if the channel should be closed after the result of
| |
| ctx | back to summary |
|---|---|
| protected final ChannelHandlerContext ctx() | |
| decode | back to summary |
|---|---|
| protected void decode(final ChannelHandlerContext ctx, I msg) throws Exception Overrides io. Doc from io. Decode from one message to another. This method will be called for each written message that can be handled by this decoder. The message will be disposed of after this call.
Subclasses that wish to sometimes pass messages through, should instead override the
| |
| finishAggregation | back to summary |
|---|---|
| protected void finishAggregation(BufferAllocator allocator, A aggregated) throws Exception Invoked when the specified | |
| finishAggregation0 | back to summary |
|---|---|
| private void finishAggregation0(BufferAllocator allocator, A aggregated) throws Exception | |
| handleOversizedMessage | back to summary |
|---|---|
| protected void handleOversizedMessage(ChannelHandlerContext ctx, Object oversized) throws Exception Invoked when an incoming request exceeds the maximum content length. The default behavior is to trigger an
| |
| handlerAdded | back to summary |
|---|---|
| public void handlerAdded(ChannelHandlerContext ctx) throws Exception Overrides default io. Doc from io. Gets called after the
| |
| handlerRemoved | back to summary |
|---|---|
| public void handlerRemoved(ChannelHandlerContext ctx) throws Exception Overrides default io. Doc from io. Gets called after the
| |
| ignoreContentAfterContinueResponse | back to summary |
|---|---|
| protected abstract boolean ignoreContentAfterContinueResponse(Object msg) throws Exception Determine if all objects for the current request/response should be ignored or not.
Messages will stop being ignored the next time
| |
| invokeHandleOversizedMessage | back to summary |
|---|---|
| private void invokeHandleOversizedMessage(ChannelHandlerContext ctx, Object oversized) throws Exception | |
| isAggregated | back to summary |
|---|---|
| protected abstract boolean isAggregated(Object msg) throws Exception Returns | |
| isContentLengthInvalid | back to summary |
|---|---|
| protected abstract boolean isContentLengthInvalid(S start, int maxContentLength) throws Exception Determine if the message
| |
| isLastContentMessage | back to summary |
|---|---|
| protected abstract boolean isLastContentMessage(C msg) throws Exception Returns return msg instanceof MyLastContentMessage;or with instanceof and boolean field check:
return msg instanceof MyContentMessage && msg.isLastFragment(); | |
| lengthForAggregation | back to summary |
|---|---|
| protected abstract int lengthForAggregation(A msg) Returns the length in bytes of the passed message.
| |
| lengthForContent | back to summary |
|---|---|
| protected abstract int lengthForContent(C msg) Returns the length in bytes of the passed message.
| |
| maxContentLength | back to summary |
|---|---|
| public final int maxContentLength() Returns the maximum allowed length of the aggregated message in bytes. | |
| newContinueResponse | back to summary |
|---|---|
| protected abstract Object newContinueResponse(S start, int maxContentLength, ChannelPipeline pipeline) throws Exception Returns the 'continue response' for the specified start message if necessary. For example, this method is useful to handle an HTTP 100-continue header.
| |
| releaseCurrentMessage | back to summary |
|---|---|
| private void releaseCurrentMessage() throws Exception | |
| tryContentMessage | back to summary |
|---|---|
| protected abstract C tryContentMessage(Object msg) If the passed | |
| tryStartMessage | back to summary |
|---|---|
| protected abstract S tryStartMessage(Object msg) If the passed | |
| validateMaxContentLength | back to summary |
|---|---|
| private static void validateMaxContentLength(int maxContentLength) | |