Class MarshallingEncoder
- java.lang.Object
-
- org.jboss.netty.handler.codec.oneone.OneToOneEncoder
-
- org.jboss.netty.handler.codec.marshalling.MarshallingEncoder
-
- All Implemented Interfaces:
ChannelDownstreamHandler,ChannelHandler
@Sharable public class MarshallingEncoder extends OneToOneEncoder
OneToOneEncoderimplementation which uses JBoss Marshalling to marshal an Object. Be aware that thisOneToOneEncoderis not compatible with an other client that just use JBoss Marshalling as it includes the size of everyObjectthat gets serialized in front of theObjectitself. Use this withMarshallingDecoderSee JBoss Marshalling website for more informations
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.jboss.netty.channel.ChannelHandler
ChannelHandler.Sharable
-
-
Field Summary
Fields Modifier and Type Field Description private intestimatedLengthprivate static byte[]LENGTH_PLACEHOLDERprivate MarshallerProviderprovider
-
Constructor Summary
Constructors Constructor Description MarshallingEncoder(MarshallerProvider provider)Creates a new encoder with the estimated length of 512 bytes.MarshallingEncoder(MarshallerProvider provider, int estimatedLength)Creates a new encoder.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected java.lang.Objectencode(ChannelHandlerContext ctx, Channel channel, java.lang.Object msg)Transforms the specified message into another message and return the transformed message.-
Methods inherited from class org.jboss.netty.handler.codec.oneone.OneToOneEncoder
doEncode, handleDownstream
-
-
-
-
Field Detail
-
LENGTH_PLACEHOLDER
private static final byte[] LENGTH_PLACEHOLDER
-
provider
private final MarshallerProvider provider
-
estimatedLength
private final int estimatedLength
-
-
Constructor Detail
-
MarshallingEncoder
public MarshallingEncoder(MarshallerProvider provider)
Creates a new encoder with the estimated length of 512 bytes.- Parameters:
provider- theMarshallerProviderto use
-
MarshallingEncoder
public MarshallingEncoder(MarshallerProvider provider, int estimatedLength)
Creates a new encoder.- Parameters:
provider- theMarshallerProviderto useestimatedLength- 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.
-
-
Method Detail
-
encode
protected java.lang.Object encode(ChannelHandlerContext ctx, Channel channel, java.lang.Object msg) throws java.lang.Exception
Description copied from class:OneToOneEncoderTransforms the specified message into another message and return the transformed message. Note that you can not returnnull, unlike you can inOneToOneDecoder.decode(ChannelHandlerContext, Channel, Object); you must return something, at leastChannelBuffers.EMPTY_BUFFER.- Specified by:
encodein classOneToOneEncoder- Throws:
java.lang.Exception
-
-