Class EspressoMessageToMessageDecoder<I>

  • All Implemented Interfaces:,
    Direct Known Subclasses:

    public abstract class EspressoMessageToMessageDecoder<I>
    Forked from Netty 4.1.42.Final. Main change is to avoid creating TypeParameterMatcher. ChannelInboundHandlerAdapter which decodes from one message to an other message. For example here is an implementation which decodes a String to an Integer which represent the length of the String.
         public class StringToIntegerDecoder extends
                 MessageToMessageDecoder<String> {
             public void decode(ChannelHandlerContext ctx, String 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 MessageToMessageDecoder will call ReferenceCounted.release() on decoded messages.
    • Nested Class Summary

      • Nested classes/interfaces inherited from interface
    • Constructor Summary

      Modifier Constructor Description
      protected EspressoMessageToMessageDecoder()
      Create a new instance which will try to detect the types to match out of the type parameter of the class.
      protected EspressoMessageToMessageDecoder​(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
      boolean acceptInboundMessage​(java.lang.Object msg)
      Returns true if the given message should be handled.
      void channelRead​( ctx, java.lang.Object msg)  
      protected abstract void decode​( ctx, I msg, java.util.List<java.lang.Object> out)
      Decode from one message to an other.
      • Methods inherited from class

        channelActive, channelInactive, channelReadComplete, channelRegistered, channelUnregistered, channelWritabilityChanged, exceptionCaught, userEventTriggered
      • Methods inherited from class

        ensureNotSharable, 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

        handlerAdded, handlerRemoved
    • Constructor Detail

      • EspressoMessageToMessageDecoder

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

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

      • acceptInboundMessage

        public boolean acceptInboundMessage​(java.lang.Object msg)
                                     throws java.lang.Exception
        Returns true if the given message should be handled. If false it will be passed to the next ChannelInboundHandler in the ChannelPipeline.
      • channelRead

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

        protected abstract void decode​( ctx,
                                       I msg,
                                       java.util.List<java.lang.Object> out)
                                throws java.lang.Exception
        Decode from one message to an other. This method will be called for each written message that can be handled by this decoder.
        ctx - the ChannelHandlerContext which this MessageToMessageDecoder belongs to
        msg - the message to decode to an other one
        out - the List to which decoded messages should be added
        java.lang.Exception - is thrown if an error occurs