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.
| Modifier and Type | Field and Description |
|---|---|
| private final boolean | |
| private final TypeParameterMatcher |
| Access | Constructor and Description |
|---|---|
| protected | SimpleUserEventChannelHandler()
see |
| protected | SimpleUserEventChannelHandler(boolean
true if handled events should be released automatically by passing them to
ReferenceCountUtil#release(Object).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 |
| 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).Create a new instance |
| Modifier and Type | Method and Description |
|---|---|
| protected boolean | |
| protected abstract void | eventReceived(ChannelHandlerContext
the ctx, I ChannelHandlerContext which this SimpleUserEventChannelHandler belongs tothe user event to handle evt)Is called for each user event triggered of type |
| public final void | userEventTriggered(ChannelHandlerContext ctx, Object evt)
Overrides io. Implements io. ChannelHandlerContext#fireUserEventTriggered(Object) to forward
to the next ChannelInboundHandler in the ChannelPipeline.
|
| autoRelease | back to summary |
|---|---|
| private final boolean autoRelease | |
| matcher | back to summary |
|---|---|
| private final TypeParameterMatcher matcher | |
| SimpleUserEventChannelHandler | back to summary |
|---|---|
| protected SimpleUserEventChannelHandler() see | |
| SimpleUserEventChannelHandler | back 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.
| |
| SimpleUserEventChannelHandler | back to summary |
|---|---|
| protected SimpleUserEventChannelHandler(Class<? extends I> eventType) see | |
| SimpleUserEventChannelHandler | back to summary |
|---|---|
| protected SimpleUserEventChannelHandler(Class<? extends I> eventType, boolean autoRelease) Create a new instance
| |
| acceptEvent | back to summary |
|---|---|
| protected boolean acceptEvent(Object evt) throws Exception Returns | |
| eventReceived | back to summary |
|---|---|
| protected abstract void eventReceived(ChannelHandlerContext ctx, I evt) throws Exception Is called for each user event triggered of type
| |
| userEventTriggered | back to summary |
|---|---|
| public final void userEventTriggered(ChannelHandlerContext ctx, Object evt) throws Exception Overrides io. Implements io. Doc from io. Calls
| |