org.apache.mina.filter.codec.serialization

Class ObjectSerializationEncoder

Implemented Interfaces:
ProtocolEncoder

public class ObjectSerializationEncoder
extends ProtocolEncoderAdapter

A ProtocolEncoder which serializes Serializable Java objects using ByteBuffer.putObject(Object).

Constructor Summary

ObjectSerializationEncoder()
Creates a new instance.

Method Summary

void
encode(IoSession session, Object message, ProtocolEncoderOutput out)
Encodes higher-level message objects into binary or protocol-specific data.
int
getMaxObjectSize()
Returns the allowed maximum size of the encoded object.
void
setMaxObjectSize(int maxObjectSize)
Sets the allowed maximum size of the encoded object.

Methods inherited from class org.apache.mina.filter.codec.ProtocolEncoderAdapter

dispose

Constructor Details

ObjectSerializationEncoder

public ObjectSerializationEncoder()
Creates a new instance.

Method Details

encode

public void encode(IoSession session,
                   Object message,
                   ProtocolEncoderOutput out)
            throws Exception
Encodes higher-level message objects into binary or protocol-specific data. MINA invokes ProtocolEncoder.encode(IoSession,Object,ProtocolEncoderOutput) method with message which is popped from the session write queue, and then the encoder implementation puts encoded ByteBuffers into ProtocolEncoderOutput.
Specified by:
encode in interface ProtocolEncoder

getMaxObjectSize

public int getMaxObjectSize()
Returns the allowed maximum size of the encoded object. If the size of the encoded object exceeds this value, this encoder will throw a IllegalArgumentException. The default value is Integer.MAX_VALUE.

setMaxObjectSize

public void setMaxObjectSize(int maxObjectSize)
Sets the allowed maximum size of the encoded object. If the size of the encoded object exceeds this value, this encoder will throw a IllegalArgumentException. The default value is Integer.MAX_VALUE.