public class ObjectEncoder
extends io.netty.channel.ChannelOutboundHandlerAdapter
ChannelBuffer
.
Please note that the serialized form this encoder produces is not
compatible with the standard ObjectInputStream
. Please use
ObjectDecoder
or ObjectDecoderInputStream
to ensure the
interoperability with this encoder.
Modifier and Type | Class and Description |
---|---|
static class |
ObjectEncoder.FailedWriteException |
Constructor and Description |
---|
ObjectEncoder()
Creates a new encoder with the estimated length of 512 bytes.
|
ObjectEncoder(int estimatedLength,
boolean preferDirect)
Creates a new encoder.
|
Modifier and Type | Method and Description |
---|---|
protected io.netty.buffer.ByteBuf |
allocateBuffer(io.netty.channel.ChannelHandlerContext ctx,
int estimatedSize,
boolean preferDirect) |
void |
write(io.netty.channel.ChannelHandlerContext ctx,
Object msg,
io.netty.channel.ChannelPromise promise) |
bind, close, connect, deregister, disconnect, flush, read
ensureNotSharable, exceptionCaught, handlerAdded, handlerRemoved, isSharable
public ObjectEncoder()
public ObjectEncoder(int estimatedLength, boolean preferDirect)
estimatedLength
- the estimated byte length of the serialized form of an object.
If the length of the serialized form exceeds this value, the
internal buffer will be expanded automatically at the cost of
memory bandwidth. If this value is too big, it will also waste
memory bandwidth. To avoid unnecessary memory copy or allocation
cost, please specify the properly estimated value.public void write(io.netty.channel.ChannelHandlerContext ctx, Object msg, io.netty.channel.ChannelPromise promise) throws Exception
write
in interface io.netty.channel.ChannelOutboundHandler
write
in class io.netty.channel.ChannelOutboundHandlerAdapter
Exception
Copyright © 2019. All rights reserved.