public abstract class SimpleChannelInboundHandler<I> extends ChannelInboundHandlerAdapter
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
public void messageReceived(ChannelHandlerContext ctx, String message)
throws Exception {
System.out.println(message);
}
}
ChannelHandler.Sharable| Modifier | Constructor and Description |
|---|---|
protected |
SimpleChannelInboundHandler() |
protected |
SimpleChannelInboundHandler(boolean autoRelease) |
protected |
SimpleChannelInboundHandler(Class<? extends I> inboundMessageType) |
protected |
SimpleChannelInboundHandler(Class<? extends I> inboundMessageType,
boolean autoRelease) |
| Modifier and Type | Method and Description |
|---|---|
boolean |
acceptInboundMessage(Object msg) |
protected void |
beginMessageReceived(ChannelHandlerContext ctx)
Is called before the first
messageReceived(ChannelHandlerContext, Object) of the current
MessageList is handled. |
protected void |
endMessageReceived(ChannelHandlerContext ctx)
Is called after the last
messageReceived(ChannelHandlerContext, Object) of the current
MessageList is handled. |
protected abstract void |
messageReceived(ChannelHandlerContext ctx,
I msg)
Is called for each message of type
I. |
void |
messageReceived(ChannelHandlerContext ctx,
MessageList<Object> msgs)
Calls
ChannelHandlerContext.fireMessageReceived(MessageList) to forward
to the next ChannelInboundHandler in the ChannelPipeline. |
channelActive, channelInactive, channelReadSuspended, channelRegistered, channelUnregistered, channelWritabilityChanged, userEventTriggeredexceptionCaught, handlerAdded, handlerRemovedclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitexceptionCaught, handlerAdded, handlerRemovedprotected SimpleChannelInboundHandler()
protected SimpleChannelInboundHandler(boolean autoRelease)
protected SimpleChannelInboundHandler(Class<? extends I> inboundMessageType)
public boolean acceptInboundMessage(Object msg) throws Exception
Exceptionpublic void messageReceived(ChannelHandlerContext ctx, MessageList<Object> msgs) throws Exception
ChannelInboundHandlerAdapterChannelHandlerContext.fireMessageReceived(MessageList) to forward
to the next ChannelInboundHandler in the ChannelPipeline.
Sub-classes may override this method to change behavior.messageReceived in interface ChannelInboundHandlermessageReceived in class ChannelInboundHandlerAdapterExceptionprotected abstract void messageReceived(ChannelHandlerContext ctx, I msg) throws Exception
I.ctx - the ChannelHandlerContext which this SimpleChannelInboundHandler
belongs tomsg - the message to handleException - is thrown if an error accourprotected void beginMessageReceived(ChannelHandlerContext ctx) throws Exception
messageReceived(ChannelHandlerContext, Object) of the current
MessageList is handled.ctx - the ChannelHandlerContext which is bound to this handlerExceptionprotected void endMessageReceived(ChannelHandlerContext ctx) throws Exception
messageReceived(ChannelHandlerContext, Object) of the current
MessageList is handled.ctx - the ChannelHandlerContext which is bound to this handlerExceptionCopyright © 2008-2013 The Netty Project. All Rights Reserved.