Class MarshallingDecoder
java.lang.Object
io.netty.channel.ChannelHandlerAdapter
io.netty.channel.ChannelInboundHandlerAdapter
io.netty.handler.codec.ByteToMessageDecoder
io.netty.handler.codec.LengthFieldBasedFrameDecoder
io.netty.handler.codec.marshalling.MarshallingDecoder
- All Implemented Interfaces:
ChannelHandler, ChannelInboundHandler
Decoder which MUST be used with
MarshallingEncoder.
A LengthFieldBasedFrameDecoder which use an Unmarshaller to read the Object out
of the ByteBuf.-
Nested Class Summary
Nested classes/interfaces inherited from class ByteToMessageDecoder
ByteToMessageDecoder.CumulatorNested classes/interfaces inherited from interface ChannelHandler
ChannelHandler.Sharable -
Field Summary
Fields inherited from class ByteToMessageDecoder
COMPOSITE_CUMULATOR, MERGE_CUMULATOR -
Constructor Summary
ConstructorsConstructorDescriptionMarshallingDecoder(UnmarshallerProvider provider) Creates a new decoder whose maximum object size is1048576bytes.MarshallingDecoder(UnmarshallerProvider provider, int maxObjectSize) Creates a new decoder with the specified maximum object size. -
Method Summary
Modifier and TypeMethodDescriptionprotected Objectdecode(ChannelHandlerContext ctx, ByteBuf in) Create a frame out of theByteBufand return it.protected ByteBufextractFrame(ChannelHandlerContext ctx, ByteBuf buffer, int index, int length) Extract the sub-region of the specified buffer.Methods inherited from class LengthFieldBasedFrameDecoder
decode, getUnadjustedFrameLengthMethods inherited from class ByteToMessageDecoder
actualReadableBytes, callDecode, channelInactive, channelRead, channelReadComplete, decodeLast, discardSomeReadBytes, handlerRemoved, handlerRemoved0, internalBuffer, isSingleDecode, setCumulator, setDiscardAfterReads, setSingleDecode, userEventTriggeredMethods inherited from class ChannelInboundHandlerAdapter
channelActive, channelRegistered, channelUnregistered, channelWritabilityChanged, exceptionCaughtMethods inherited from class ChannelHandlerAdapter
ensureNotSharable, handlerAdded, isSharableMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface ChannelHandler
handlerAdded
-
Constructor Details
-
MarshallingDecoder
Creates a new decoder whose maximum object size is1048576bytes. If the size of the received object is greater than1048576bytes, aStreamCorruptedExceptionwill be raised. -
MarshallingDecoder
Creates a new decoder with the specified maximum object size.- Parameters:
maxObjectSize- the maximum byte length of the serialized object. if the length of the received object is greater than this value,TooLongFrameExceptionwill be raised.
-
-
Method Details
-
decode
Description copied from class:LengthFieldBasedFrameDecoderCreate a frame out of theByteBufand return it.- Overrides:
decodein classLengthFieldBasedFrameDecoder- Parameters:
ctx- theChannelHandlerContextwhich thisByteToMessageDecoderbelongs toin- theByteBuffrom which to read data- Returns:
- frame the
ByteBufwhich represent the frame ornullif no frame could be created. - Throws:
Exception
-
extractFrame
Description copied from class:LengthFieldBasedFrameDecoderExtract the sub-region of the specified buffer.- Overrides:
extractFramein classLengthFieldBasedFrameDecoder
-