public class CompatibleObjectEncoder extends OneToOneEncoder
ChannelBuffer
(interoperability version).
This encoder is interoperable with the standard Java object streams such as
ObjectInputStream and ObjectOutputStream.
ChannelHandler.Sharable| Modifier and Type | Field and Description |
|---|---|
private java.util.concurrent.atomic.AtomicReference<ChannelBuffer> |
buffer |
private java.io.ObjectOutputStream |
oout |
private int |
resetInterval |
private int |
writtenObjects |
| 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 |
|---|---|
private ChannelBuffer |
buffer(ChannelHandlerContext ctx) |
protected java.lang.Object |
encode(ChannelHandlerContext context,
Channel channel,
java.lang.Object msg)
Transforms the specified message into another message and return the
transformed message.
|
protected java.io.ObjectOutputStream |
newObjectOutputStream(java.io.OutputStream out)
Creates a new
ObjectOutputStream which wraps the specified
OutputStream. |
doEncode, handleDownstreamprivate final java.util.concurrent.atomic.AtomicReference<ChannelBuffer> buffer
private final int resetInterval
private volatile java.io.ObjectOutputStream oout
private int writtenObjects
public 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 java.io.ObjectOutputStream newObjectOutputStream(java.io.OutputStream out)
throws java.lang.Exception
ObjectOutputStream which wraps the specified
OutputStream. Override this method to use a subclass of the
ObjectOutputStream.java.lang.Exceptionprotected java.lang.Object encode(ChannelHandlerContext context, Channel channel, java.lang.Object msg) throws java.lang.Exception
OneToOneEncodernull, unlike
you can in OneToOneDecoder.decode(ChannelHandlerContext, Channel, Object);
you must return something, at least ChannelBuffers.EMPTY_BUFFER.encode in class OneToOneEncoderjava.lang.Exceptionprivate ChannelBuffer buffer(ChannelHandlerContext ctx) throws java.lang.Exception
java.lang.Exception