public class CompatibleObjectEncoder extends MessageToByteEncoder<Serializable>
ByteBuf
(interoperability version).
This encoder is interoperable with the standard Java object streams such as
ObjectInputStream and ObjectOutputStream.
| Constructor and Description |
|---|
CompatibleObjectEncoder()
Creates a new instance with the reset interval of
16. |
CompatibleObjectEncoder(int resetInterval)
Creates a new instance.
|
| Modifier and Type | Method and Description |
|---|---|
protected void |
encode(io.netty.channel.ChannelHandlerContext ctx,
Serializable msg,
io.netty.buffer.ByteBuf out)
Encode a message into a
ByteBuf. |
protected ObjectOutputStream |
newObjectOutputStream(OutputStream out)
Creates a new
ObjectOutputStream which wraps the specified
OutputStream. |
acceptOutboundMessage, allocateBuffer, isPreferDirect, writebind, close, connect, deregister, disconnect, flush, readensureNotSharable, exceptionCaught, handlerAdded, handlerRemoved, isSharablepublic CompatibleObjectEncoder()
16.public CompatibleObjectEncoder(int resetInterval)
resetInterval - the number of objects between ObjectOutputStream.reset().
0 will disable resetting the stream, but the remote
peer will be at the risk of getting OutOfMemoryError in
the long term.protected ObjectOutputStream newObjectOutputStream(OutputStream out) throws Exception
ObjectOutputStream which wraps the specified
OutputStream. Override this method to use a subclass of the
ObjectOutputStream.Exceptionprotected void encode(io.netty.channel.ChannelHandlerContext ctx,
Serializable msg,
io.netty.buffer.ByteBuf out)
throws Exception
MessageToByteEncoderByteBuf. This method will be called for each written message that can be handled
by this encoder.encode in class MessageToByteEncoder<Serializable>ctx - the ChannelHandlerContext which this MessageToByteEncoder belongs tomsg - the message to encodeout - the ByteBuf into which the encoded message will be writtenException - is thrown if an error occursCopyright © 2008–2019 The Netty Project. All rights reserved.