Class EspressoMessageToMessageEncoder<I>

  • All Implemented Interfaces:,
    Direct Known Subclasses:

    public abstract class EspressoMessageToMessageEncoder<I>
    Forked from Netty 4.1.42.Final. Main change is to avoid creating TypeParameterMatcher. ChannelOutboundHandlerAdapter which encodes from one message to an other message For example here is an implementation which decodes an Integer to an String.
         public class IntegerToStringEncoder extends
                 MessageToMessageEncoder<Integer> {
             public void encode(ChannelHandlerContext ctx, Integer message, List<Object> out)
                     throws Exception {
    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 MessageToMessageEncoder will call ReferenceCounted.release() on encoded messages.
    • Nested Class Summary

      • Nested classes/interfaces inherited from interface
    • Constructor Summary

      Modifier Constructor Description
      protected EspressoMessageToMessageEncoder()
      Create a new instance which will try to detect the types to match out of the type parameter of the class.
      protected EspressoMessageToMessageEncoder​(java.lang.Class<? extends I> inboundMessageType)
      Create a new instance
    • Method Summary

      All Methods Instance Methods Abstract Methods Concrete Methods 
      Modifier and Type Method Description
      protected boolean acceptOutboundMessage​(java.lang.Object msg)  
      protected abstract void encode​( ctx, I msg, java.util.List<java.lang.Object> out)
      Encode from one message to an other.
      void write​( ctx, java.lang.Object msg, promise)  
      • Methods inherited from class

        bind, close, connect, deregister, disconnect, flush, read
      • Methods inherited from class

        ensureNotSharable, exceptionCaught, handlerAdded, handlerRemoved, isSharable
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
      • Methods inherited from interface

        exceptionCaught, handlerAdded, handlerRemoved
    • Constructor Detail

      • EspressoMessageToMessageEncoder

        protected EspressoMessageToMessageEncoder()
        Create a new instance which will try to detect the types to match out of the type parameter of the class.
      • EspressoMessageToMessageEncoder

        protected EspressoMessageToMessageEncoder​(java.lang.Class<? extends I> inboundMessageType)
        Create a new instance
        inboundMessageType - The type of messages to match and so decode
    • Method Detail

      • write

        public void write​( ctx,
                          java.lang.Object msg,
                   throws java.lang.Exception
        Specified by:
        write in interface
        write in class
      • acceptOutboundMessage

        protected boolean acceptOutboundMessage​(java.lang.Object msg)
                                         throws java.lang.Exception
      • encode

        protected abstract void encode​( ctx,
                                       I msg,
                                       java.util.List<java.lang.Object> out)
                                throws java.lang.Exception
        Encode from one message to an other. This method will be called for each written message that can be handled by this encoder.
        ctx - the ChannelHandlerContext which this MessageToMessageEncoder belongs to
        msg - the message to encode to an other one
        out - the List into which the encoded msg should be added needs to do some kind of aggregation
        java.lang.Exception - is thrown if an error occurs