Class SimpleChannelInboundHandler<I>

  • All Implemented Interfaces:
    ChannelHandler

    public abstract class SimpleChannelInboundHandler<I>
    extends Object
    implements ChannelHandler
    ChannelHandler which allows to explicit only handle a specific type of messages. For example here is an implementation which only handle String messages.
         public class StringHandler extends
                 SimpleChannelInboundHandler<String> {
    
             @Override
             protected void messageReceived(ChannelHandlerContext ctx, String message)
                     throws Exception {
                 System.out.println(message);
             }
         }
     
    Be aware that depending of the constructor parameters it will release all handled messages by passing them to Resource.dispose(Object).
    • Constructor Detail

      • SimpleChannelInboundHandler

        protected SimpleChannelInboundHandler​(boolean autoRelease)
        Create a new instance which will try to detect the types to match out of the type parameter of the class.
        Parameters:
        autoRelease - true if handled messages should be released automatically by passing them to Resource.dispose(Object).
      • SimpleChannelInboundHandler

        protected SimpleChannelInboundHandler​(Class<? extends I> inboundMessageType,
                                              boolean autoRelease)
        Create a new instance
        Parameters:
        inboundMessageType - The type of messages to match
        autoRelease - true if handled messages should be released automatically by passing them to Resource.dispose(Object).