Package org.teiid.transport
Class ObjectEncoder
- java.lang.Object
-
- io.netty.channel.ChannelHandlerAdapter
-
- io.netty.channel.ChannelOutboundHandlerAdapter
-
- org.teiid.transport.ObjectEncoder
-
- All Implemented Interfaces:
io.netty.channel.ChannelHandler
,io.netty.channel.ChannelOutboundHandler
public class ObjectEncoder extends io.netty.channel.ChannelOutboundHandlerAdapter
An encoder which serializes a Java object into a message.Please note that the serialized form this encoder produces is not compatible with the standard
ObjectInputStream
. Please useObjectDecoder
orObjectDecoderInputStream
to ensure the interoperability with this encoder.- Version:
- $Rev:231 $, $Date:2008-06-12 16:44:50 +0900 (목, 12 6월 2008) $
- Author:
- The Netty Project (netty-dev@lists.jboss.org), Trustin Lee (tlee@redhat.com)
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
ObjectEncoder.FailedWriteException
-
Constructor Summary
Constructors Constructor Description ObjectEncoder()
Creates a new encoder with the estimated length of 512 bytes.ObjectEncoder(int estimatedLength, boolean preferDirect)
Creates a new encoder.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method 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)
-
Methods inherited from class io.netty.channel.ChannelOutboundHandlerAdapter
bind, close, connect, deregister, disconnect, flush, read
-
Methods inherited from class io.netty.channel.ChannelHandlerAdapter
ensureNotSharable, exceptionCaught, handlerAdded, handlerRemoved, isSharable
-
-
-
-
Constructor Detail
-
ObjectEncoder
public ObjectEncoder()
Creates a new encoder with the estimated length of 512 bytes.
-
ObjectEncoder
public ObjectEncoder(int estimatedLength, boolean preferDirect)
Creates a new encoder.- Parameters:
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.
-
-
Method Detail
-
write
public void write(io.netty.channel.ChannelHandlerContext ctx, Object msg, io.netty.channel.ChannelPromise promise) throws Exception
- Specified by:
write
in interfaceio.netty.channel.ChannelOutboundHandler
- Overrides:
write
in classio.netty.channel.ChannelOutboundHandlerAdapter
- Throws:
Exception
-
-