public abstract class ByteToMessageCodec<I> extends ChannelDuplexHandler
ByteToMessageDecoder
and MessageToByteEncoder
.
Be aware that sub-classes of ByteToMessageCodec
MUST NOT
annotated with @Sharable
.ChannelHandler.Sharable
Modifier | Constructor and Description |
---|---|
protected |
ByteToMessageCodec()
see
ByteToMessageCodec(boolean) with true as boolean parameter. |
protected |
ByteToMessageCodec(boolean preferDirect)
Create a new instance which will try to detect the types to match out of the type parameter of the class.
|
protected |
ByteToMessageCodec(Class<? extends I> outboundMessageType)
see
ByteToMessageCodec(Class, boolean) with true as boolean value. |
protected |
ByteToMessageCodec(Class<? extends I> outboundMessageType,
boolean preferDirect)
Create a new instance
|
bind, close, connect, deregister, disconnect, flush, read
channelActive, channelRegistered, channelUnregistered, channelWritabilityChanged, exceptionCaught, userEventTriggered
ensureNotSharable, isSharable
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
exceptionCaught
protected ByteToMessageCodec()
ByteToMessageCodec(boolean)
with true
as boolean parameter.protected ByteToMessageCodec(Class<? extends I> outboundMessageType)
ByteToMessageCodec(Class, boolean)
with true
as boolean value.protected ByteToMessageCodec(boolean preferDirect)
public boolean acceptOutboundMessage(Object msg) throws Exception
true
if and only if the specified message can be encoded by this codec.msg
- the messageException
public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception
ChannelInboundHandlerAdapter
ChannelHandlerContext.fireChannelRead(Object)
to forward
to the next ChannelInboundHandler
in the ChannelPipeline
.
Sub-classes may override this method to change behavior.channelRead
in interface ChannelInboundHandler
channelRead
in class ChannelInboundHandlerAdapter
Exception
public void write(ChannelHandlerContext ctx, Object msg, ChannelPromise promise) throws Exception
ChannelDuplexHandler
ChannelOutboundInvoker.write(Object, ChannelPromise)
to forward
to the next ChannelOutboundHandler
in the ChannelPipeline
.
Sub-classes may override this method to change behavior.write
in interface ChannelOutboundHandler
write
in class ChannelDuplexHandler
ctx
- the ChannelHandlerContext
for which the write operation is mademsg
- the message to writepromise
- the ChannelPromise
to notify once the operation completesException
- thrown if an error occurspublic void channelReadComplete(ChannelHandlerContext ctx) throws Exception
ChannelInboundHandlerAdapter
ChannelHandlerContext.fireChannelReadComplete()
to forward
to the next ChannelInboundHandler
in the ChannelPipeline
.
Sub-classes may override this method to change behavior.channelReadComplete
in interface ChannelInboundHandler
channelReadComplete
in class ChannelInboundHandlerAdapter
Exception
public void channelInactive(ChannelHandlerContext ctx) throws Exception
ChannelInboundHandlerAdapter
ChannelHandlerContext.fireChannelInactive()
to forward
to the next ChannelInboundHandler
in the ChannelPipeline
.
Sub-classes may override this method to change behavior.channelInactive
in interface ChannelInboundHandler
channelInactive
in class ChannelInboundHandlerAdapter
Exception
public void handlerAdded(ChannelHandlerContext ctx) throws Exception
ChannelHandlerAdapter
handlerAdded
in interface ChannelHandler
handlerAdded
in class ChannelHandlerAdapter
Exception
public void handlerRemoved(ChannelHandlerContext ctx) throws Exception
ChannelHandlerAdapter
handlerRemoved
in interface ChannelHandler
handlerRemoved
in class ChannelHandlerAdapter
Exception
protected abstract void encode(ChannelHandlerContext ctx, I msg, ByteBuf out) throws Exception
Exception
MessageToByteEncoder.encode(ChannelHandlerContext, Object, ByteBuf)
protected abstract void decode(ChannelHandlerContext ctx, ByteBuf in, List<Object> out) throws Exception
Exception
ByteToMessageDecoder.decode(ChannelHandlerContext, ByteBuf, List)
protected void decodeLast(ChannelHandlerContext ctx, ByteBuf in, List<Object> out) throws Exception
Copyright © 2008–2017 The Netty Project. All rights reserved.