Class MessageToMessageCodec<INBOUND_IN,OUTBOUND_IN>

All Implemented Interfaces:
ChannelHandler, ChannelInboundHandler, ChannelOutboundHandler
Direct Known Subclasses:
Http2StreamFrameToHttpObjectCodec, HttpContentEncoder, SpdyHttpResponseStreamIdHandler

public abstract class MessageToMessageCodec<INBOUND_IN,OUTBOUND_IN> extends ChannelDuplexHandler
A Codec for on-the-fly encoding/decoding of message. This can be thought of as a combination of MessageToMessageDecoder and MessageToMessageEncoder. Here is an example of a MessageToMessageCodec which just decode from Integer to Long and encode from Long to Integer.
     public class NumberCodec extends
             MessageToMessageCodec<Integer, Long> {
         @Override
         public Long decode(ChannelHandlerContext ctx, Integer msg, List<Object> out)
                 throws Exception {
             out.add(msg.longValue());
         }

         @Override
         public Integer encode(ChannelHandlerContext ctx, Long msg, List<Object> out)
                 throws Exception {
             out.add(msg.intValue());
         }
     }
 
Be aware that you need to call ReferenceCounted.retain() on messages that are just passed through if they are of type ReferenceCounted. This is needed as the MessageToMessageCodec will call ReferenceCounted.release() on encoded / decoded messages.