Class CompatibleMarshallingDecoder

  • All Implemented Interfaces:
    io.netty.channel.ChannelHandler, io.netty.channel.ChannelInboundHandler

    public class CompatibleMarshallingDecoder
    extends io.netty.handler.codec.ReplayingDecoder<Void>
    ReplayingDecoder which use an Unmarshaller to read the Object out of the ByteBuf. If you can you should use MarshallingDecoder.
    • Nested Class Summary

      • Nested classes/interfaces inherited from class io.netty.handler.codec.ByteToMessageDecoder

        io.netty.handler.codec.ByteToMessageDecoder.Cumulator
      • Nested classes/interfaces inherited from interface io.netty.channel.ChannelHandler

        io.netty.channel.ChannelHandler.Sharable
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected int maxObjectSize  
      protected UnmarshallerProvider provider  
      • Fields inherited from class io.netty.handler.codec.ByteToMessageDecoder

        COMPOSITE_CUMULATOR, MERGE_CUMULATOR
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      protected void decode​(io.netty.channel.ChannelHandlerContext ctx, io.netty.buffer.ByteBuf buffer, List<Object> out)  
      protected void decodeLast​(io.netty.channel.ChannelHandlerContext ctx, io.netty.buffer.ByteBuf buffer, List<Object> out)  
      void exceptionCaught​(io.netty.channel.ChannelHandlerContext ctx, Throwable cause)  
      • Methods inherited from class io.netty.handler.codec.ReplayingDecoder

        callDecode, checkpoint, checkpoint, state, state
      • Methods inherited from class io.netty.handler.codec.ByteToMessageDecoder

        actualReadableBytes, channelInactive, channelRead, channelReadComplete, discardSomeReadBytes, handlerRemoved, handlerRemoved0, internalBuffer, isSingleDecode, setCumulator, setDiscardAfterReads, setSingleDecode, userEventTriggered
      • Methods inherited from class io.netty.channel.ChannelInboundHandlerAdapter

        channelActive, channelRegistered, channelUnregistered, channelWritabilityChanged
      • Methods inherited from class io.netty.channel.ChannelHandlerAdapter

        ensureNotSharable, handlerAdded, isSharable
      • Methods inherited from interface io.netty.channel.ChannelHandler

        handlerAdded
    • Field Detail

      • maxObjectSize

        protected final int maxObjectSize
    • Constructor Detail

      • CompatibleMarshallingDecoder

        public CompatibleMarshallingDecoder​(UnmarshallerProvider provider,
                                            int maxObjectSize)
        Create a new instance of CompatibleMarshallingDecoder.
        Parameters:
        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 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.
    • Method Detail

      • decode

        protected void decode​(io.netty.channel.ChannelHandlerContext ctx,
                              io.netty.buffer.ByteBuf buffer,
                              List<Object> out)
                       throws Exception
        Specified by:
        decode in class io.netty.handler.codec.ByteToMessageDecoder
        Throws:
        Exception
      • decodeLast

        protected void decodeLast​(io.netty.channel.ChannelHandlerContext ctx,
                                  io.netty.buffer.ByteBuf buffer,
                                  List<Object> out)
                           throws Exception
        Overrides:
        decodeLast in class io.netty.handler.codec.ByteToMessageDecoder
        Throws:
        Exception
      • exceptionCaught

        public void exceptionCaught​(io.netty.channel.ChannelHandlerContext ctx,
                                    Throwable cause)
                             throws Exception
        Specified by:
        exceptionCaught in interface io.netty.channel.ChannelHandler
        Specified by:
        exceptionCaught in interface io.netty.channel.ChannelInboundHandler
        Overrides:
        exceptionCaught in class io.netty.channel.ChannelInboundHandlerAdapter
        Throws:
        Exception