Class CompatibleMarshallingDecoder
java.lang.Object
org.jboss.netty.channel.SimpleChannelUpstreamHandler
org.jboss.netty.handler.codec.frame.FrameDecoder
org.jboss.netty.handler.codec.replay.ReplayingDecoder<VoidEnum>
org.jboss.netty.handler.codec.marshalling.CompatibleMarshallingDecoder
- All Implemented Interfaces:
ChannelHandler
,ChannelUpstreamHandler
,LifeCycleAwareChannelHandler
ReplayingDecoder
which use an Unmarshaller
to read the Object out of the ChannelBuffer
.
If you can you should use MarshallingDecoder
.-
Nested Class Summary
Nested classes/interfaces inherited from interface org.jboss.netty.channel.ChannelHandler
ChannelHandler.Sharable
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate boolean
protected final int
protected final UnmarshallerProvider
Fields inherited from class org.jboss.netty.handler.codec.frame.FrameDecoder
cumulation, DEFAULT_MAX_COMPOSITEBUFFER_COMPONENTS
-
Constructor Summary
ConstructorsConstructorDescriptionCompatibleMarshallingDecoder
(UnmarshallerProvider provider, int maxObjectSize) Create a new instance ofCompatibleMarshallingDecoder
. -
Method Summary
Modifier and TypeMethodDescriptionprotected 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
CallsChannel.close()
if a TooLongFrameException was thrownMethods inherited from class org.jboss.netty.handler.codec.replay.ReplayingDecoder
checkpoint, checkpoint, cleanup, decode, decodeLast, getState, internalBuffer, messageReceived, setState
Methods inherited from class org.jboss.netty.handler.codec.frame.FrameDecoder
actualReadableBytes, afterAdd, afterRemove, appendToCumulation, beforeAdd, beforeRemove, channelClosed, channelDisconnected, extractFrame, getMaxCumulationBufferCapacity, getMaxCumulationBufferComponents, isUnfold, 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
-
maxObjectSize
protected final int maxObjectSize -
discardingTooLongFrame
private boolean discardingTooLongFrame
-
-
Constructor Details
-
CompatibleMarshallingDecoder
Create a new instance ofCompatibleMarshallingDecoder
.- Parameters:
provider
- theUnmarshallerProvider
which is used to obtain theUnmarshaller
for theChannel
maxObjectSize
- the maximal size (in bytes) of theObject
to unmarshal. Once the size is exceeded theChannel
will get closed. Use a a maxObjectSize ofInteger.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 anOutOfMemoryError
.
-
-
Method Details
-
decode
protected Object decode(ChannelHandlerContext ctx, Channel channel, ChannelBuffer buffer, VoidEnum state) throws Exception Description copied from class:ReplayingDecoder
Decodes the received packets so far into a frame.- Specified by:
decode
in classReplayingDecoder<VoidEnum>
- 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.state
- the current decoder state (null
if unused)- Returns:
- the decoded frame
- Throws:
Exception
-
decodeLast
protected Object decodeLast(ChannelHandlerContext ctx, Channel channel, ChannelBuffer buffer, VoidEnum state) throws Exception Description copied from class:ReplayingDecoder
Decodes the received data so far into a frame when the channel is disconnected.- Overrides:
decodeLast
in classReplayingDecoder<VoidEnum>
- 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.state
- the current decoder state (null
if unused)- Returns:
- the decoded frame
- Throws:
Exception
-
exceptionCaught
CallsChannel.close()
if a TooLongFrameException was thrown- Overrides:
exceptionCaught
in classFrameDecoder
- Throws:
Exception
-