public class CompatibleMarshallingDecoder extends ReplayingDecoder<VoidEnum>
ReplayingDecoder
which use an Unmarshaller
to read the Object out of the ChannelBuffer
.
If you can you should use MarshallingDecoder
.ChannelHandler.Sharable
Modifier and Type | Field and Description |
---|---|
protected int |
maxObjectSize |
protected UnmarshallerProvider |
provider |
cumulation, DEFAULT_MAX_COMPOSITEBUFFER_COMPONENTS
Constructor and Description |
---|
CompatibleMarshallingDecoder(UnmarshallerProvider provider,
int maxObjectSize)
Create a new instance of
CompatibleMarshallingDecoder . |
Modifier and Type | Method and Description |
---|---|
protected Object |
decode(ChannelHandlerContext ctx,
Channel channel,
ChannelBuffer buffer,
VoidEnum state)
Decodes the received packets so far into a frame.
|
protected Object |
decodeLast(ChannelHandlerContext ctx,
Channel channel,
ChannelBuffer buffer,
VoidEnum state)
Decodes the received data so far into a frame when the channel is
disconnected.
|
void |
exceptionCaught(ChannelHandlerContext ctx,
ExceptionEvent e)
Calls
Channel.close() if a TooLongFrameException was thrown |
checkpoint, checkpoint, cleanup, decode, decodeLast, getState, internalBuffer, messageReceived, setState
actualReadableBytes, afterAdd, afterRemove, appendToCumulation, beforeAdd, beforeRemove, channelClosed, channelDisconnected, extractFrame, getMaxCumulationBufferCapacity, getMaxCumulationBufferComponents, isUnfold, newCumulationBuffer, replace, setMaxCumulationBufferCapacity, setMaxCumulationBufferComponents, setUnfold, unfoldAndFireMessageReceived, updateCumulation
channelBound, channelConnected, channelInterestChanged, channelOpen, channelUnbound, childChannelClosed, childChannelOpen, handleUpstream, writeComplete
protected final UnmarshallerProvider provider
protected final int maxObjectSize
public CompatibleMarshallingDecoder(UnmarshallerProvider provider, int maxObjectSize)
CompatibleMarshallingDecoder
.provider
- the UnmarshallerProvider
which is used to obtain the Unmarshaller
for the Channel
maxObjectSize
- the maximal size (in bytes) of the Object
to unmarshal. Once the size is
exceeded the Channel
will get closed. Use a a maxObjectSize of
Integer.MAX_VALUE
to disable this. You should only do this if you are sure
that the received Objects will never be big and the sending side are trusted, as
this opens the possibility for a DOS-Attack due an OutOfMemoryError
.protected Object decode(ChannelHandlerContext ctx, Channel channel, ChannelBuffer buffer, VoidEnum state) throws Exception
ReplayingDecoder
decode
in class ReplayingDecoder<VoidEnum>
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.state
- the current decoder state (null
if unused)Exception
protected Object decodeLast(ChannelHandlerContext ctx, Channel channel, ChannelBuffer buffer, VoidEnum state) throws Exception
ReplayingDecoder
decodeLast
in class ReplayingDecoder<VoidEnum>
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.state
- the current decoder state (null
if unused)Exception
public void exceptionCaught(ChannelHandlerContext ctx, ExceptionEvent e) throws Exception
Channel.close()
if a TooLongFrameException was thrownexceptionCaught
in class FrameDecoder
Exception
Copyright © 2008-2014 The Netty Project. All Rights Reserved.