Class SimpleUserEventChannelHandler<I>

  • All Implemented Interfaces:
    ChannelHandler

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

      • SimpleUserEventChannelHandler

        protected SimpleUserEventChannelHandler​(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 events should be released automatically by passing them to Resource.dispose(Object).
      • SimpleUserEventChannelHandler

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