public class MarshallingDecoder extends LengthFieldBasedFrameDecoder
MarshallingEncoder
.
A LengthFieldBasedFrameDecoder
which use an Unmarshaller
to read the Object out
of the ChannelBuffer
.ChannelHandler.Sharable
cumulation, DEFAULT_MAX_COMPOSITEBUFFER_COMPONENTS
构造器和说明 |
---|
MarshallingDecoder(UnmarshallerProvider provider)
Creates a new decoder whose maximum object size is
1048576
bytes. |
MarshallingDecoder(UnmarshallerProvider provider,
int maxObjectSize)
Creates a new decoder with the specified maximum object size.
|
限定符和类型 | 方法和说明 |
---|---|
protected java.lang.Object |
decode(ChannelHandlerContext ctx,
Channel channel,
ChannelBuffer buffer)
Decodes the received packets so far into a frame.
|
protected ChannelBuffer |
extractFrame(ChannelBuffer buffer,
int index,
int length)
Extract a Frame of the specified buffer.
|
actualReadableBytes, afterAdd, afterRemove, appendToCumulation, beforeAdd, beforeRemove, channelClosed, channelDisconnected, cleanup, decodeLast, exceptionCaught, getMaxCumulationBufferCapacity, getMaxCumulationBufferComponents, internalBuffer, isUnfold, messageReceived, newCumulationBuffer, replace, setMaxCumulationBufferCapacity, setMaxCumulationBufferComponents, setUnfold, unfoldAndFireMessageReceived, updateCumulation
channelBound, channelConnected, channelInterestChanged, channelOpen, channelUnbound, childChannelClosed, childChannelOpen, handleUpstream, writeComplete
public MarshallingDecoder(UnmarshallerProvider provider)
1048576
bytes. If the size of the received object is greater than
1048576
bytes, a StreamCorruptedException
will be
raised.public MarshallingDecoder(UnmarshallerProvider provider, int maxObjectSize)
maxObjectSize
- the maximum byte length of the serialized object.
if the length of the received object is greater
than this value, TooLongFrameException
will be raised.protected java.lang.Object decode(ChannelHandlerContext ctx, Channel channel, ChannelBuffer buffer) throws java.lang.Exception
FrameDecoder
FrameDecoder.extractFrame(ChannelBuffer, int, int)
method,
to make optimizations easier later.decode
在类中 LengthFieldBasedFrameDecoder
ctx
- the context of this handlerchannel
- the current channelbuffer
- the cumulative buffer of received packets so far.
Note that the buffer might be empty, which means you
should not make an assumption that the buffer contains
at least one byte in your decoder implementation.null
if there's not enough data in the buffer to decode a frame.java.lang.Exception
protected ChannelBuffer extractFrame(ChannelBuffer buffer, int index, int length)
FrameDecoder
extractFrame
在类中 FrameDecoder