Class StompSubframeDecoder
java.lang.Object
io.netty.channel.ChannelHandlerAdapter
io.netty.channel.ChannelInboundHandlerAdapter
io.netty.handler.codec.ByteToMessageDecoder
io.netty.handler.codec.ReplayingDecoder<StompSubframeDecoder.State>
io.netty.handler.codec.stomp.StompSubframeDecoder
- All Implemented Interfaces:
ChannelHandler, ChannelInboundHandler
Decodes
ByteBufs into StompHeadersSubframes and StompContentSubframes.
Parameters to control memory consumption:
maxLineLength the maximum length of line - restricts length of command and header lines If the length of the
initial line exceeds this value, a TooLongFrameException will be raised.
maxChunkSize The maximum length of the content or each chunk. If the content length (or the length of each
chunk) exceeds this value, the content or chunk ill be split into multiple StompContentSubframes whose length
is maxChunkSize at maximum.
maxNumHeaders The maximum number of headers per frame.
If this limit exceeded a TooLongFrameException will be raised.
Chunked Content
If the content of a stomp message is greater than maxChunkSize the transfer encoding of the HTTP message is
'chunked', this decoder generates multiple StompContentSubframe instances to avoid excessive memory
consumption. Note, that every message, even with no content decodes with LastStompContentSubframe at the end
to simplify upstream message parsing.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumDeprecated.this should never be used by an user!Nested classes/interfaces inherited from class ByteToMessageDecoder
ByteToMessageDecoder.CumulatorNested classes/interfaces inherited from interface ChannelHandler
ChannelHandler.SharableModifier and TypeInterfaceDescriptionstatic @interfaceIndicates that the same instance of the annotatedChannelHandlercan be added to one or moreChannelPipelines multiple times without a race condition. -
Field Summary
Fields inherited from class ByteToMessageDecoder
COMPOSITE_CUMULATOR, MERGE_CUMULATORModifier and TypeFieldDescriptionstatic final ByteToMessageDecoder.CumulatorCumulateByteBufs by add them to aCompositeByteBufand so do no memory copy whenever possible.static final ByteToMessageDecoder.Cumulator -
Constructor Summary
ConstructorsConstructorDescriptionStompSubframeDecoder(boolean validateHeaders) StompSubframeDecoder(int maxLineLength, int maxChunkSize) StompSubframeDecoder(int maxLineLength, int maxChunkSize, boolean validateHeaders) StompSubframeDecoder(int maxLineLength, int maxChunkSize, int maxNumHeaders, boolean validateHeaders) -
Method Summary
Modifier and TypeMethodDescriptionprotected voiddecode(ChannelHandlerContext ctx, ByteBuf in, List<Object> out) Decode the from oneByteBufto an other.protected voidGets called after theByteToMessageDecoderwas removed from the actual context and it doesn't handle events anymore.Methods inherited from class ReplayingDecoder
callDecode, checkpoint, checkpoint, state, stateModifier and TypeMethodDescriptionprotected voidcallDecode(ChannelHandlerContext ctx, ByteBuf in, List<Object> out) Called once data should be decoded from the givenByteBuf.protected voidStores the internal cumulative buffer's reader position.protected voidStores the internal cumulative buffer's reader position and updates the current decoder state.protected StompSubframeDecoder.Statestate()Returns the current state of this decoder.protected StompSubframeDecoder.Statestate(StompSubframeDecoder.State newState) Sets the current state of this decoder.Methods inherited from class ByteToMessageDecoder
actualReadableBytes, channelInactive, channelRead, channelReadComplete, decodeLast, discardSomeReadBytes, handlerRemoved, internalBuffer, isSingleDecode, setCumulator, setDiscardAfterReads, setSingleDecode, userEventTriggeredModifier and TypeMethodDescriptionprotected intReturns the actual number of readable bytes in the internal cumulative buffer of this decoder.voidCallsChannelHandlerContext.fireChannelInactive()to forward to the nextChannelInboundHandlerin theChannelPipeline.voidchannelRead(ChannelHandlerContext ctx, Object input) CallsChannelHandlerContext.fireChannelRead(Object)to forward to the nextChannelInboundHandlerin theChannelPipeline.voidCallsChannelHandlerContext.fireChannelReadComplete()to forward to the nextChannelInboundHandlerin theChannelPipeline.protected voiddecodeLast(ChannelHandlerContext ctx, ByteBuf in, List<Object> out) Is called one last time when theChannelHandlerContextgoes in-active.protected final voidfinal voidDo nothing by default, sub-classes may override this method.protected ByteBufReturns the internal cumulative buffer of this decoder.booleanIftruethen only one message is decoded on eachByteToMessageDecoder.channelRead(ChannelHandlerContext, Object)call.voidsetCumulator(ByteToMessageDecoder.Cumulator cumulator) Set theByteToMessageDecoder.Cumulatorto use for cumulate the receivedByteBufs.voidsetDiscardAfterReads(int discardAfterReads) Set the number of reads after whichByteBuf.discardSomeReadBytes()are called and so free up memory.voidsetSingleDecode(boolean singleDecode) If set then only one message is decoded on eachByteToMessageDecoder.channelRead(ChannelHandlerContext, Object)call.voiduserEventTriggered(ChannelHandlerContext ctx, Object evt) CallsChannelHandlerContext.fireUserEventTriggered(Object)to forward to the nextChannelInboundHandlerin theChannelPipeline.Methods inherited from class ChannelInboundHandlerAdapter
channelActive, channelRegistered, channelUnregistered, channelWritabilityChanged, exceptionCaughtModifier and TypeMethodDescriptionvoidCallsChannelHandlerContext.fireChannelActive()to forward to the nextChannelInboundHandlerin theChannelPipeline.voidCallsChannelHandlerContext.fireChannelRegistered()to forward to the nextChannelInboundHandlerin theChannelPipeline.voidCallsChannelHandlerContext.fireChannelUnregistered()to forward to the nextChannelInboundHandlerin theChannelPipeline.voidCallsChannelHandlerContext.fireChannelWritabilityChanged()to forward to the nextChannelInboundHandlerin theChannelPipeline.voidexceptionCaught(ChannelHandlerContext ctx, Throwable cause) CallsChannelHandlerContext.fireExceptionCaught(Throwable)to forward to the nextChannelHandlerin theChannelPipeline.Methods inherited from class ChannelHandlerAdapter
ensureNotSharable, handlerAdded, isSharableModifier and TypeMethodDescriptionprotected voidvoidDo nothing by default, sub-classes may override this method.booleanReturntrueif the implementation isChannelHandler.Sharableand so can be added to differentChannelPipelines.
-
Constructor Details
-
StompSubframeDecoder
public StompSubframeDecoder() -
StompSubframeDecoder
public StompSubframeDecoder(boolean validateHeaders) -
StompSubframeDecoder
public StompSubframeDecoder(int maxLineLength, int maxChunkSize) -
StompSubframeDecoder
public StompSubframeDecoder(int maxLineLength, int maxChunkSize, boolean validateHeaders) -
StompSubframeDecoder
public StompSubframeDecoder(int maxLineLength, int maxChunkSize, int maxNumHeaders, boolean validateHeaders)
-
-
Method Details
-
decode
Description copied from class:ByteToMessageDecoderDecode the from oneByteBufto an other. This method will be called till either the inputByteBufhas nothing to read when return from this method or till nothing was read from the inputByteBuf.- Specified by:
decodein classByteToMessageDecoder- Parameters:
ctx- theChannelHandlerContextwhich thisByteToMessageDecoderbelongs toin- theByteBuffrom which to read dataout- theListto which decoded messages should be added- Throws:
Exception- is thrown if an error occurs
-
handlerRemoved0
Description copied from class:ByteToMessageDecoderGets called after theByteToMessageDecoderwas removed from the actual context and it doesn't handle events anymore.- Overrides:
handlerRemoved0in classByteToMessageDecoder- Throws:
Exception
-