Top Description Fields Constructors Methods
io.netty.channel

public abstract Class SimpleUserEventChannelHandler<I>

extends ChannelInboundHandlerAdapter
Class Inheritance
Imports
io.netty.util.ReferenceCountUtil, io.netty.util.internal.TypeParameterMatcher

ChannelInboundHandlerAdapter 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 ReferenceCountUtil#release(Object). In this case you may need to use ReferenceCountUtil#retain(Object) if you pass the object to the next handler in the ChannelPipeline.

Field Summary

Modifier and TypeField and Description
private final boolean
private final TypeParameterMatcher

Constructor Summary

AccessConstructor and Description
protected
protected
SimpleUserEventChannelHandler(boolean
true if handled events should be released automatically by passing them to ReferenceCountUtil#release(Object).
autoRelease
)

Create a new instance which will try to detect the types to match out of the type parameter of the class.

protected
SimpleUserEventChannelHandler(Class<? extends I> eventType)

see SimpleUserEventChannelHandler(Class, boolean) with true as boolean value.

protected
SimpleUserEventChannelHandler(Class<? extends I>
The type of events to match
eventType
,
boolean
true if handled events should be released automatically by passing them to ReferenceCountUtil#release(Object).
autoRelease
)

Create a new instance

Method Summary

Modifier and TypeMethod and Description
protected boolean
acceptEvent(Object evt)

Returns true if the given user event should be handled.

protected abstract void
eventReceived(ChannelHandlerContext ctx, I
the user event to handle
evt
)

Is called for each user event triggered of type I.

public final void
Inherited from io.netty.channel.ChannelInboundHandlerAdapter:
channelActivechannelInactivechannelReadchannelReadCompletechannelRegisteredchannelUnregisteredchannelWritabilityChangedexceptionCaught

Field Detail

autoReleaseback to summary
private final boolean autoRelease
matcherback to summary
private final TypeParameterMatcher matcher

Constructor Detail

SimpleUserEventChannelHandlerback to summary
protected SimpleUserEventChannelHandler()

see SimpleUserEventChannelHandler(boolean) with true as boolean parameter.

SimpleUserEventChannelHandlerback to summary
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:boolean

true if handled events should be released automatically by passing them to ReferenceCountUtil#release(Object).

SimpleUserEventChannelHandlerback to summary
protected SimpleUserEventChannelHandler(Class<? extends I> eventType)

see SimpleUserEventChannelHandler(Class, boolean) with true as boolean value.

SimpleUserEventChannelHandlerback to summary
protected SimpleUserEventChannelHandler(Class<? extends I> eventType, boolean autoRelease)

Create a new instance

Parameters
eventType:Class<? extends I>

The type of events to match

autoRelease:boolean

true if handled events should be released automatically by passing them to ReferenceCountUtil#release(Object).

Method Detail

acceptEventback to summary
protected boolean acceptEvent(Object evt) throws Exception

Returns true if the given user event should be handled. If false it will be passed to the next ChannelInboundHandler in the ChannelPipeline.

eventReceivedback to summary
protected abstract void eventReceived(ChannelHandlerContext ctx, I evt) throws Exception

Is called for each user event triggered of type I.

Parameters
ctx:ChannelHandlerContext

the ChannelHandlerContext which this SimpleUserEventChannelHandler belongs to

evt:I

the user event to handle

Exceptions
Exception:
is thrown if an error occurred
userEventTriggeredback to summary
public final void userEventTriggered(ChannelHandlerContext ctx, Object evt) throws Exception

Overrides io.netty.channel.ChannelInboundHandlerAdapter.userEventTriggered.

Implements io.netty.channel.ChannelInboundHandler.userEventTriggered.

Doc from io.netty.channel.ChannelInboundHandlerAdapter.userEventTriggered.

Calls ChannelHandlerContext#fireUserEventTriggered(Object) to forward to the next ChannelInboundHandler in the ChannelPipeline. Sub-classes may override this method to change behavior.

Annotations
@Override