Class ObjectDecoder
- java.lang.Object
-
- io.netty5.channel.ChannelHandlerAdapter
-
- io.netty5.handler.codec.ByteToMessageDecoder
-
- io.netty5.handler.codec.LengthFieldBasedFrameDecoder
-
- io.netty.contrib.handler.codec.serialization.ObjectDecoder
-
- All Implemented Interfaces:
io.netty5.channel.ChannelHandler
public class ObjectDecoder extends io.netty5.handler.codec.LengthFieldBasedFrameDecoderA decoder which deserializes the receivedBuffers into Java objects.Please note that the serialized form this decoder expects is not compatible with the standard
ObjectOutputStream. Please useObjectEncoderorObjectEncoderOutputStreamto ensure the interoperability with this decoder.
-
-
Constructor Summary
Constructors Constructor Description ObjectDecoder(int maxObjectSize, ClassResolver classResolver)Creates a new decoder with the specified maximum object size.ObjectDecoder(ClassResolver classResolver)Creates a new decoder whose maximum object size is1048576bytes.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected Objectdecode0(io.netty5.channel.ChannelHandlerContext ctx, io.netty5.buffer.Buffer in)-
Methods inherited from class io.netty5.handler.codec.LengthFieldBasedFrameDecoder
decode, extractFrame, getUnadjustedFrameLength
-
Methods inherited from class io.netty5.handler.codec.ByteToMessageDecoder
actualReadableBytes, channelInactive, channelRead, channelReadComplete, channelShutdown, decodeLast, discardSomeReadBytes, handlerAdded, handlerAdded0, handlerRemoved, handlerRemoved0, internalBuffer, isSharable, isSingleDecode, setSingleDecode
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface io.netty5.channel.ChannelHandler
bind, channelActive, channelExceptionCaught, channelInboundEvent, channelRegistered, channelUnregistered, channelWritabilityChanged, close, connect, deregister, disconnect, flush, pendingOutboundBytes, read, register, sendOutboundEvent, shutdown, write
-
-
-
-
Constructor Detail
-
ObjectDecoder
public ObjectDecoder(ClassResolver classResolver)
Creates a new decoder whose maximum object size is1048576bytes. If the size of the received object is greater than1048576bytes, aStreamCorruptedExceptionwill be raised.- Parameters:
classResolver- theClassResolverto use for this decoder
-
ObjectDecoder
public ObjectDecoder(int maxObjectSize, ClassResolver classResolver)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,StreamCorruptedExceptionwill be raised.classResolver- theClassResolverwhich will load the class of the serialized object
-
-