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
public class CompatibleMarshallingDecoder extends ReplayingDecoder<VoidEnum>
ReplayingDecoderwhich use anUnmarshallerto read the Object out of theChannelBuffer. If you can you should useMarshallingDecoder.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.jboss.netty.channel.ChannelHandler
ChannelHandler.Sharable
-
-
Field Summary
Fields Modifier and Type Field Description private booleandiscardingTooLongFrameprotected intmaxObjectSizeprotected UnmarshallerProviderprovider-
Fields inherited from class org.jboss.netty.handler.codec.frame.FrameDecoder
cumulation, DEFAULT_MAX_COMPOSITEBUFFER_COMPONENTS
-
-
Constructor Summary
Constructors Constructor Description CompatibleMarshallingDecoder(UnmarshallerProvider provider, int maxObjectSize)Create a new instance ofCompatibleMarshallingDecoder.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected java.lang.Objectdecode(ChannelHandlerContext ctx, Channel channel, ChannelBuffer buffer, VoidEnum state)Decodes the received packets so far into a frame.protected java.lang.ObjectdecodeLast(ChannelHandlerContext ctx, Channel channel, ChannelBuffer buffer, VoidEnum state)Decodes the received data so far into a frame when the channel is disconnected.voidexceptionCaught(ChannelHandlerContext ctx, ExceptionEvent e)CallsChannel.close()if a TooLongFrameException was thrown-
Methods 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 Detail
-
provider
protected final UnmarshallerProvider provider
-
maxObjectSize
protected final int maxObjectSize
-
discardingTooLongFrame
private boolean discardingTooLongFrame
-
-
Constructor Detail
-
CompatibleMarshallingDecoder
public CompatibleMarshallingDecoder(UnmarshallerProvider provider, int maxObjectSize)
Create a new instance ofCompatibleMarshallingDecoder.- Parameters:
provider- theUnmarshallerProviderwhich is used to obtain theUnmarshallerfor theChannelmaxObjectSize- the maximal size (in bytes) of theObjectto unmarshal. Once the size is exceeded theChannelwill get closed. Use a a maxObjectSize ofInteger.MAX_VALUEto 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 Detail
-
decode
protected java.lang.Object decode(ChannelHandlerContext ctx, Channel channel, ChannelBuffer buffer, VoidEnum state) throws java.lang.Exception
Description copied from class:ReplayingDecoderDecodes the received packets so far into a frame.- Specified by:
decodein 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 (nullif unused)- Returns:
- the decoded frame
- Throws:
java.lang.Exception
-
decodeLast
protected java.lang.Object decodeLast(ChannelHandlerContext ctx, Channel channel, ChannelBuffer buffer, VoidEnum state) throws java.lang.Exception
Description copied from class:ReplayingDecoderDecodes the received data so far into a frame when the channel is disconnected.- Overrides:
decodeLastin 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 (nullif unused)- Returns:
- the decoded frame
- Throws:
java.lang.Exception
-
exceptionCaught
public void exceptionCaught(ChannelHandlerContext ctx, ExceptionEvent e) throws java.lang.Exception
CallsChannel.close()if a TooLongFrameException was thrown- Overrides:
exceptionCaughtin classFrameDecoder- Throws:
java.lang.Exception
-
-