Class AbstractMemcacheObjectEncoder<M extends MemcacheMessage>

  • All Implemented Interfaces:
    io.netty.channel.ChannelHandler, io.netty.channel.ChannelOutboundHandler
    Direct Known Subclasses:
    AbstractBinaryMemcacheEncoder

    @UnstableApi
    public abstract class AbstractMemcacheObjectEncoder<M extends MemcacheMessage>
    extends io.netty.handler.codec.MessageToMessageEncoder<Object>
    A general purpose AbstractMemcacheObjectEncoder that encodes MemcacheMessages.

    Note that this class is designed to be extended, especially because both the binary and ascii protocol require different treatment of their messages. Since the content chunk writing is the same for both, the encoder abstracts this right away.

    • Nested Class Summary

      • Nested classes/interfaces inherited from interface io.netty.channel.ChannelHandler

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

      All Methods Instance Methods Abstract Methods Concrete Methods 
      Modifier and Type Method Description
      boolean acceptOutboundMessage​(Object msg)  
      protected void encode​(io.netty.channel.ChannelHandlerContext ctx, Object msg, List<Object> out)  
      protected abstract io.netty.buffer.ByteBuf encodeMessage​(io.netty.channel.ChannelHandlerContext ctx, M msg)
      Take the given MemcacheMessage and encode it into a writable ByteBuf.
      • Methods inherited from class io.netty.handler.codec.MessageToMessageEncoder

        write
      • Methods inherited from class io.netty.channel.ChannelOutboundHandlerAdapter

        bind, close, connect, deregister, disconnect, flush, read
      • Methods inherited from class io.netty.channel.ChannelHandlerAdapter

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

        exceptionCaught, handlerAdded, handlerRemoved
    • Constructor Detail

      • AbstractMemcacheObjectEncoder

        public AbstractMemcacheObjectEncoder()
    • Method Detail

      • encode

        protected void encode​(io.netty.channel.ChannelHandlerContext ctx,
                              Object msg,
                              List<Object> out)
                       throws Exception
        Specified by:
        encode in class io.netty.handler.codec.MessageToMessageEncoder<Object>
        Throws:
        Exception
      • acceptOutboundMessage

        public boolean acceptOutboundMessage​(Object msg)
                                      throws Exception
        Overrides:
        acceptOutboundMessage in class io.netty.handler.codec.MessageToMessageEncoder<Object>
        Throws:
        Exception
      • encodeMessage

        protected abstract io.netty.buffer.ByteBuf encodeMessage​(io.netty.channel.ChannelHandlerContext ctx,
                                                                 M msg)
        Take the given MemcacheMessage and encode it into a writable ByteBuf.
        Parameters:
        ctx - the channel handler context.
        msg - the message to encode.
        Returns:
        the ByteBuf representation of the message.