public class StompSubframeAggregator extends MessageAggregator<StompSubframe,StompHeadersSubframe,StompContentSubframe,StompFrame>
ChannelHandler that aggregates an StompHeadersSubframe
and its following StompContentSubframes into a single StompFrame.
It is useful when you don't want to take care of STOMP frames whose content is 'chunked'. Insert this
handler after StompSubframeDecoder in the ChannelPipeline:ChannelHandler.Sharable, ChannelHandler.Skip| Constructor and Description |
|---|
StompSubframeAggregator(int maxContentLength)
Creates a new instance.
|
| Modifier and Type | Method and Description |
|---|---|
protected StompFrame |
beginAggregation(StompHeadersSubframe start,
ByteBuf content)
Creates a new aggregated message from the specified start message and the specified content.
|
protected long |
contentLength(StompHeadersSubframe start)
Retrieves the length of the whole content from the specified start message.
|
protected boolean |
hasContentLength(StompHeadersSubframe start)
Returns
true if and only if the specified start message already contains the information about the
length of the whole content. |
protected boolean |
isAggregated(StompSubframe msg)
Returns
true if and only if the specified message is already aggregated. |
protected boolean |
isContentMessage(StompSubframe msg)
Returns
true if and only if the specified message is a content message. |
protected boolean |
isLastContentMessage(StompContentSubframe msg)
Returns
true if and only if the specified message is the last content message. |
protected boolean |
isStartMessage(StompSubframe msg)
Returns
true if and only if the specified message is a start message. |
protected Object |
newContinueResponse(StompHeadersSubframe start)
Returns the 'continue response' for the specified start message if necessary.
|
acceptInboundMessage, aggregate, channelInactive, ctx, decode, finishAggregation, handleOversizedMessage, handlerAdded, handlerRemoved, isHandlingOversizedMessage, maxContentLength, maxCumulationBufferComponents, setMaxCumulationBufferComponentschannelReadbind, channelActive, channelReadComplete, channelRegistered, channelUnregistered, channelWritabilityChanged, close, connect, deregister, disconnect, exceptionCaught, flush, isSharable, read, userEventTriggered, writepublic StompSubframeAggregator(int maxContentLength)
maxContentLength - the maximum length of the aggregated content.
If the length of the aggregated content exceeds this value,
a TooLongFrameException will be raised.protected boolean isStartMessage(StompSubframe msg) throws Exception
MessageAggregatortrue if and only if the specified message is a start message. Typically, this method is
implemented as a single return statement with instanceof:
return msg instanceof MyStartMessage;
isStartMessage in class MessageAggregator<StompSubframe,StompHeadersSubframe,StompContentSubframe,StompFrame>Exceptionprotected boolean isContentMessage(StompSubframe msg) throws Exception
MessageAggregatortrue if and only if the specified message is a content message. Typically, this method is
implemented as a single return statement with instanceof:
return msg instanceof MyContentMessage;
isContentMessage in class MessageAggregator<StompSubframe,StompHeadersSubframe,StompContentSubframe,StompFrame>Exceptionprotected boolean isLastContentMessage(StompContentSubframe msg) throws Exception
MessageAggregatortrue if and only if the specified message is the last content message. Typically, this method is
implemented as a single return statement with instanceof:
return msg instanceof MyLastContentMessage;or with
instanceof and boolean field check:
return msg instanceof MyContentMessage && msg.isLastFragment();
isLastContentMessage in class MessageAggregator<StompSubframe,StompHeadersSubframe,StompContentSubframe,StompFrame>Exceptionprotected boolean isAggregated(StompSubframe msg) throws Exception
MessageAggregatortrue if and only if the specified message is already aggregated. If this method returns
true, this handler will simply forward the message to the next handler as-is.isAggregated in class MessageAggregator<StompSubframe,StompHeadersSubframe,StompContentSubframe,StompFrame>Exceptionprotected boolean hasContentLength(StompHeadersSubframe start) throws Exception
MessageAggregatortrue if and only if the specified start message already contains the information about the
length of the whole content.hasContentLength in class MessageAggregator<StompSubframe,StompHeadersSubframe,StompContentSubframe,StompFrame>Exceptionprotected long contentLength(StompHeadersSubframe start) throws Exception
MessageAggregatorMessageAggregator.hasContentLength(Object) returned true.contentLength in class MessageAggregator<StompSubframe,StompHeadersSubframe,StompContentSubframe,StompFrame>Exceptionprotected Object newContinueResponse(StompHeadersSubframe start) throws Exception
MessageAggregatornewContinueResponse in class MessageAggregator<StompSubframe,StompHeadersSubframe,StompContentSubframe,StompFrame>null if there's no message to sendExceptionprotected StompFrame beginAggregation(StompHeadersSubframe start, ByteBuf content) throws Exception
MessageAggregatorByteBufHolder, its content is appended to the specified content.
This aggregator will continue to append the received content to the specified content.beginAggregation in class MessageAggregator<StompSubframe,StompHeadersSubframe,StompContentSubframe,StompFrame>ExceptionCopyright © 2008–2015 The Netty Project. All rights reserved.