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

public Class MarshallingEncoder

extends MessageToByteEncoder<Object>
Class Inheritance
Annotations
@Sharable
Imports
io.netty.buffer.ByteBuf, io.netty.channel.ChannelHandler.Sharable, .ChannelHandlerContext, io.netty.handler.codec.MessageToByteEncoder, org.jboss.marshalling.Marshaller

MessageToByteEncoder implementation which uses JBoss Marshalling to marshal an Object. Be aware that this encoder is not compatible with an other client that just use JBoss Marshalling as it includes the size of every Object that gets serialized in front of the Object itself. Use this with MarshallingDecoder See JBoss Marshalling website for more information

Field Summary

Modifier and TypeField and Description
private static final byte[]
private final MarshallerProvider

Constructor Summary

AccessConstructor and Description
public
MarshallingEncoder(MarshallerProvider provider)

Creates a new encoder.

Method Summary

Modifier and TypeMethod and Description
protected void
encode(ChannelHandlerContext ctx, Object
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
providerback to summary
private final MarshallerProvider provider

Constructor Detail

MarshallingEncoderback to summary
public MarshallingEncoder(MarshallerProvider provider)

Creates a new encoder.

Parameters
provider:MarshallerProvider

the MarshallerProvider to use

Method Detail

encodeback to summary
protected void encode(ChannelHandlerContext ctx, Object 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:Object

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