public class ObjectDecoder extends LengthFieldBasedFrameDecoder
ChannelBuffer
s into Java
objects.
Please note that the serialized form this decoder expects is not
compatible with the standard ObjectOutputStream
. Please use
ObjectEncoder
or ObjectEncoderOutputStream
to ensure the
interoperability with this decoder.
ChannelHandler.Sharable
cumulation, DEFAULT_MAX_COMPOSITEBUFFER_COMPONENTS
Constructor and Description |
---|
ObjectDecoder()
Deprecated.
|
ObjectDecoder(ClassResolver classResolver)
Creates a new decoder whose maximum object size is
1048576
bytes. |
ObjectDecoder(int maxObjectSize)
Deprecated.
|
ObjectDecoder(int maxObjectSize,
ClassLoader classLoader)
Deprecated.
|
ObjectDecoder(int maxObjectSize,
ClassResolver classResolver)
Creates a new decoder with the specified maximum object size.
|
Modifier and Type | Method and Description |
---|---|
protected 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
@Deprecated public ObjectDecoder()
ObjectDecoder(ClassResolver)
1048576
bytes. If the size of the received object is greater than
1048576
bytes, a StreamCorruptedException
will be
raised.public ObjectDecoder(ClassResolver classResolver)
1048576
bytes. If the size of the received object is greater than
1048576
bytes, a StreamCorruptedException
will be
raised.classResolver
- the ClassResolver
to use for this decoder@Deprecated public ObjectDecoder(int maxObjectSize)
ObjectDecoder(int, ClassResolver)
maxObjectSize
- the maximum byte length of the serialized object.
if the length of the received object is greater
than this value, StreamCorruptedException
will be raised.public ObjectDecoder(int maxObjectSize, ClassResolver classResolver)
maxObjectSize
- the maximum byte length of the serialized object.
if the length of the received object is greater
than this value, StreamCorruptedException
will be raised.classResolver
- the ClassResolver
which will load the class
of the serialized object@Deprecated public ObjectDecoder(int maxObjectSize, ClassLoader classLoader)
ObjectDecoder(int, ClassResolver)
ClassLoader
wrapped in ClassResolvers.weakCachingResolver(ClassLoader)
.maxObjectSize
- the maximum byte length of the serialized object.
if the length of the received object is greater
than this value, StreamCorruptedException
will be raised.classLoader
- the the classloader to useprotected Object decode(ChannelHandlerContext ctx, Channel channel, ChannelBuffer buffer) throws Exception
FrameDecoder
FrameDecoder.extractFrame(ChannelBuffer, int, int)
method,
to make optimizations easier later.decode
in class 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.Exception
protected ChannelBuffer extractFrame(ChannelBuffer buffer, int index, int length)
FrameDecoder
extractFrame
in class FrameDecoder
Copyright © 2008-2015 The Netty Project. All Rights Reserved.