public class CompatibleMarshallingDecoder extends ReplayingDecoder<java.lang.Void>
ReplayingDecoder其使用Unmarshaller读取对象出的ByteBuf 。
如果你可以,你应该使用MarshallingDecoder 。
ByteToMessageDecoder.CumulatorChannelHandler.Sharable| Modifier and Type | Field and Description |
|---|---|
protected int |
maxObjectSize |
protected UnmarshallerProvider |
provider |
COMPOSITE_CUMULATOR, MERGE_CUMULATOR| Constructor and Description |
|---|
CompatibleMarshallingDecoder(UnmarshallerProvider provider, int maxObjectSize)
创建一个新的 CompatibleMarshallingDecoder实例。
|
| Modifier and Type | Method and Description |
|---|---|
protected void |
decode(ChannelHandlerContext ctx, ByteBuf buffer, java.util.List<java.lang.Object> out)
解码从一个 ByteBuf到另一个。
|
protected void |
decodeLast(ChannelHandlerContext ctx, ByteBuf buffer, java.util.List<java.lang.Object> out)
最后一次被称为 ChannelHandlerContext无效时。
|
void |
exceptionCaught(ChannelHandlerContext ctx, java.lang.Throwable cause)
|
callDecode, checkpoint, checkpoint, state, stateactualReadableBytes, channelInactive, channelRead, channelReadComplete, discardSomeReadBytes, handlerRemoved, handlerRemoved0, internalBuffer, isSingleDecode, setCumulator, setDiscardAfterReads, setSingleDecode, userEventTriggeredchannelActive, channelRegistered, channelUnregistered, channelWritabilityChangedensureNotSharable, handlerAdded, isSharableclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waithandlerAddedprotected final UnmarshallerProvider provider
protected final int maxObjectSize
public CompatibleMarshallingDecoder(UnmarshallerProvider provider, int maxObjectSize)
CompatibleMarshallingDecoder的新实例。
provider - UnmarshallerProvider用于获得Unmarshaller的Channel
maxObjectSize -所述的最大尺寸(以字节为单位) Object解组。
一旦超过这个尺寸, Channel就会关闭。
使用Integer.MAX_VALUE的Integer.MAX_VALUE来禁用它。
如果您确定收到的对象永远不会很大并且发送方是可信任的,那么您应该只这样做,因为这会打开由于OutOfMemoryError而导致的DOS攻击的OutOfMemoryError 。
protected void decode(ChannelHandlerContext ctx, ByteBuf buffer, java.util.List<java.lang.Object> out) throws java.lang.Exception
ByteToMessageDecoder
decode在课程
ByteToMessageDecoder
ctx - ByteToMessageDecoder属于的ChannelHandlerContext
buffer - 从中读取数据的ByteBuf
out - 应该添加解码消息的
List
java.lang.Exception - 如果发生错误则抛出
protected void decodeLast(ChannelHandlerContext ctx, ByteBuf buffer, java.util.List<java.lang.Object> out) throws java.lang.Exception
ByteToMessageDecoder
ChannelHandlerContext处于非活动状态时称为最后一次。
这意味着ByteToMessageDecoder.channelInactive(ChannelHandlerContext)被触发。
默认情况下,这将只是调用ByteToMessageDecoder.decode(ChannelHandlerContext, ByteBuf, List),但子类可能会覆盖此一些特殊的清理操作。
decodeLast在课堂上
ByteToMessageDecoder
java.lang.Exception
public void exceptionCaught(ChannelHandlerContext ctx, java.lang.Throwable cause) throws java.lang.Exception
ChannelInboundHandlerAdapter
ChannelHandlerContext.fireExceptionCaught(Throwable)转发到ChannelPipeline中的下一个ChannelHandler 。
子类可以重写此方法来更改行为。
exceptionCaught在界面
ChannelHandler
exceptionCaught ,界面
ChannelInboundHandler
exceptionCaught在课程
ChannelInboundHandlerAdapter
java.lang.Exception
Copyright © 2008–2018 The Netty Project. All rights reserved.