ChannelInboundHandlerAdapter 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 channelRead0(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
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 | SimpleChannelInboundHandler()
see |
| protected | SimpleChannelInboundHandler(boolean
true if handled messages 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 | SimpleChannelInboundHandler(Class<? extends I> inboundMessageType)
see |
| protected | SimpleChannelInboundHandler(Class<? extends I>
The type of messages to match inboundMessageType, boolean true if handled messages should be released automatically by passing them to
ReferenceCountUtil#release(Object).Create a new instance |
| Modifier and Type | Method and Description |
|---|---|
| public boolean | |
| public void | channelRead(ChannelHandlerContext ctx, Object msg)
Overrides io. Implements io. ChannelHandlerContext#fireChannelRead(Object) to forward
to the next ChannelInboundHandler in the ChannelPipeline.
|
| protected abstract void | channelRead0(ChannelHandlerContext
the ctx, I ChannelHandlerContext which this SimpleChannelInboundHandler
belongs tothe message to handle msg)Is called for each message of type |
| autoRelease | back to summary |
|---|---|
| private final boolean autoRelease | |
| matcher | back to summary |
|---|---|
| private final TypeParameterMatcher matcher | |
| SimpleChannelInboundHandler | back to summary |
|---|---|
| protected SimpleChannelInboundHandler() see | |
| SimpleChannelInboundHandler | back to summary |
|---|---|
| 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.
| |
| SimpleChannelInboundHandler | back to summary |
|---|---|
| protected SimpleChannelInboundHandler(Class<? extends I> inboundMessageType) see | |
| SimpleChannelInboundHandler | back to summary |
|---|---|
| protected SimpleChannelInboundHandler(Class<? extends I> inboundMessageType, boolean autoRelease) Create a new instance
| |
| acceptInboundMessage | back to summary |
|---|---|
| public boolean acceptInboundMessage(Object msg) throws Exception Returns | |
| channelRead | back to summary |
|---|---|
| public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception Overrides io. Implements io. Doc from io. Calls
| |
| channelRead0 | back to summary |
|---|---|
| protected abstract void channelRead0(ChannelHandlerContext ctx, I msg) throws Exception Is called for each message of type
| |