Class MarshallingDecoder
java.lang.Object
org.jboss.netty.channel.SimpleChannelUpstreamHandler
org.jboss.netty.handler.codec.frame.FrameDecoder
org.jboss.netty.handler.codec.frame.LengthFieldBasedFrameDecoder
org.jboss.netty.handler.codec.marshalling.MarshallingDecoder
- All Implemented Interfaces:
ChannelHandler
,ChannelUpstreamHandler
,LifeCycleAwareChannelHandler
Decoder which MUST be used with
MarshallingEncoder
.
A LengthFieldBasedFrameDecoder
which use an Unmarshaller
to read the Object out
of the ChannelBuffer
.-
Nested Class Summary
Nested classes/interfaces inherited from interface org.jboss.netty.channel.ChannelHandler
ChannelHandler.Sharable
-
Field Summary
FieldsFields inherited from class org.jboss.netty.handler.codec.frame.FrameDecoder
cumulation, DEFAULT_MAX_COMPOSITEBUFFER_COMPONENTS
-
Constructor Summary
ConstructorsConstructorDescriptionMarshallingDecoder
(UnmarshallerProvider provider) Creates a new decoder whose maximum object size is1048576
bytes.MarshallingDecoder
(UnmarshallerProvider provider, int maxObjectSize) Creates a new decoder with the specified maximum object size. -
Method Summary
Modifier and TypeMethodDescriptionprotected 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.Methods inherited from class org.jboss.netty.handler.codec.frame.FrameDecoder
actualReadableBytes, afterAdd, afterRemove, appendToCumulation, beforeAdd, beforeRemove, channelClosed, channelDisconnected, cleanup, decodeLast, exceptionCaught, getMaxCumulationBufferCapacity, getMaxCumulationBufferComponents, internalBuffer, isUnfold, messageReceived, newCumulationBuffer, replace, setMaxCumulationBufferCapacity, setMaxCumulationBufferComponents, setUnfold, unfoldAndFireMessageReceived, updateCumulation
Methods inherited from class org.jboss.netty.channel.SimpleChannelUpstreamHandler
channelBound, channelConnected, channelInterestChanged, channelOpen, channelUnbound, childChannelClosed, childChannelOpen, handleUpstream, writeComplete
-
Field Details
-
provider
-
-
Constructor Details
-
MarshallingDecoder
Creates a new decoder whose maximum object size is1048576
bytes. If the size of the received object is greater than1048576
bytes, aStreamCorruptedException
will 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,TooLongFrameException
will be raised.
-
-
Method Details
-
decode
protected Object decode(ChannelHandlerContext ctx, Channel channel, ChannelBuffer buffer) throws Exception Description copied from class:FrameDecoder
Decodes the received packets so far into a frame. If an sub-class wants to extract a frame out of the buffer it should use theFrameDecoder.extractFrame(ChannelBuffer, int, int)
method, to make optimizations easier later.- Overrides:
decode
in classLengthFieldBasedFrameDecoder
- Parameters:
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.- Returns:
- the decoded frame if a full frame was received and decoded.
null
if there's not enough data in the buffer to decode a frame. - Throws:
Exception
-
extractFrame
Description copied from class:FrameDecoder
Extract a Frame of the specified buffer. By default this implementation will return a extract the sub-region of the buffer and create a new one. If an sub-class want to extract a frame from the buffer it should use this method by default. Be sure that this method MUST not modify the readerIndex of the given buffer- Overrides:
extractFrame
in classFrameDecoder
-