Top Description Fields Constructors Methods
io.netty.handler.codec.serialization

public Class ObjectEncoder

extends MessageToByteEncoder<Serializable>
Class Inheritance
Annotations
@Deprecated
@Sharable
Imports
io.netty.buffer.ByteBuf, .ByteBufOutputStream, io.netty.channel.ChannelHandler.Sharable, .ChannelHandlerContext, io.netty.handler.codec.MessageToByteEncoder, java.io.ObjectInputStream, .ObjectOutputStream, .Serializable

Deprecated

This class has been deprecated with no replacement, because serialization can be a security liability

An encoder which serializes a Java object into a ByteBuf.

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.

Security: serialization can be a security liability, and should not be used without defining a list of classes that are allowed to be desirialized. Such a list can be specified with the jdk.serialFilter system property, for instance. See the serialization filtering article for more information.

Field Summary

Modifier and TypeField and Description
private static final byte[]

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
protected void
encode(ChannelHandlerContext ctx, Serializable
the message to encode
msg
,
ByteBuf
the ByteBuf into which the encoded message will be written
out
)

Implements abstract io.netty.handler.codec.MessageToByteEncoder.encode.

Encode a message into a ByteBuf.
Inherited from io.netty.handler.codec.MessageToByteEncoder:
acceptOutboundMessageallocateBufferisPreferDirectwrite

Field Detail

LENGTH_PLACEHOLDERback to summary
private static final byte[] LENGTH_PLACEHOLDER

Constructor Detail

ObjectEncoderback to summary
public ObjectEncoder()

Method Detail

encodeback to summary
protected void encode(ChannelHandlerContext ctx, Serializable msg, ByteBuf out) throws Exception

Implements abstract io.netty.handler.codec.MessageToByteEncoder.encode.

Doc from io.netty.handler.codec.MessageToByteEncoder.encode.

Encode a message into a ByteBuf. This method will be called for each written message that can be handled by this encoder.

Parameters
ctx:ChannelHandlerContext

the ChannelHandlerContext which this MessageToByteEncoder belongs to

msg:Serializable

the message to encode

out:ByteBuf

the ByteBuf into which the encoded message will be written

Annotations
@Override
Exceptions
Exception:
is thrown if an error occurs