Class ObjectEncoder

  • All Implemented Interfaces:
    io.netty5.channel.ChannelHandler

    public class ObjectEncoder
    extends io.netty5.handler.codec.MessageToByteEncoder<Serializable>
    An encoder which serializes a Java object into a Buffer.

    Please note that the serialized form this encoder produces is not compatible with the standard ObjectInputStream. Please use ObjectDecoder or ObjectDecoderInputStream to ensure the interoperability with this encoder.

    • Constructor Summary

      Constructors 
      Constructor Description
      ObjectEncoder()  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      protected io.netty5.buffer.Buffer allocateBuffer​(io.netty5.channel.ChannelHandlerContext ctx, Serializable msg)  
      protected void encode​(io.netty5.channel.ChannelHandlerContext ctx, Serializable msg, io.netty5.buffer.Buffer out)  
      boolean isSharable()  
      • Methods inherited from class io.netty5.handler.codec.MessageToByteEncoder

        acceptOutboundMessage, write
      • Methods inherited from interface io.netty5.channel.ChannelHandler

        bind, channelActive, channelExceptionCaught, channelInactive, channelInboundEvent, channelRead, channelReadComplete, channelRegistered, channelShutdown, channelUnregistered, channelWritabilityChanged, close, connect, deregister, disconnect, flush, handlerAdded, handlerRemoved, pendingOutboundBytes, read, register, sendOutboundEvent, shutdown
    • Constructor Detail

      • ObjectEncoder

        public ObjectEncoder()
    • Method Detail

      • allocateBuffer

        protected io.netty5.buffer.Buffer allocateBuffer​(io.netty5.channel.ChannelHandlerContext ctx,
                                                         Serializable msg)
        Specified by:
        allocateBuffer in class io.netty5.handler.codec.MessageToByteEncoder<Serializable>
      • encode

        protected void encode​(io.netty5.channel.ChannelHandlerContext ctx,
                              Serializable msg,
                              io.netty5.buffer.Buffer out)
                       throws Exception
        Specified by:
        encode in class io.netty5.handler.codec.MessageToByteEncoder<Serializable>
        Throws:
        Exception
      • isSharable

        public boolean isSharable()