Class ObjectSerializationCodecFactory
java.lang.Object
org.apache.mina.filter.codec.serialization.ObjectSerializationCodecFactory
- All Implemented Interfaces:
ProtocolCodecFactory
A
ProtocolCodecFactory that serializes and deserializes Java objects.
This codec is very useful when you have to prototype your application rapidly
without any specific codec.-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final ObjectSerializationDecoderprivate final ObjectSerializationEncoder -
Constructor Summary
ConstructorsConstructorDescriptionCreates a new instance with theClassLoaderof the current thread.ObjectSerializationCodecFactory(ClassLoader classLoader) Creates a new instance with the specifiedClassLoader. -
Method Summary
Modifier and TypeMethodDescriptiongetDecoder(IoSession session) Returns a new (or reusable) instance ofProtocolDecoderwhich decodes binary or protocol-specific data into message objects.intgetEncoder(IoSession session) Returns a new (or reusable) instance ofProtocolEncoderwhich encodes message objects into binary or protocol-specific data.intvoidsetDecoderMaxObjectSize(int maxObjectSize) Sets the allowed maximum size of the object to be decoded.voidsetEncoderMaxObjectSize(int maxObjectSize) Sets the allowed maximum size of the encoded object.
-
Field Details
-
encoder
-
decoder
-
-
Constructor Details
-
ObjectSerializationCodecFactory
public ObjectSerializationCodecFactory()Creates a new instance with theClassLoaderof the current thread. -
ObjectSerializationCodecFactory
Creates a new instance with the specifiedClassLoader.- Parameters:
classLoader- The class loader to use
-
-
Method Details
-
getEncoder
Returns a new (or reusable) instance ofProtocolEncoderwhich encodes message objects into binary or protocol-specific data.- Specified by:
getEncoderin interfaceProtocolCodecFactory- Parameters:
session- The current session- Returns:
- The encoder instance
-
getDecoder
Returns a new (or reusable) instance ofProtocolDecoderwhich decodes binary or protocol-specific data into message objects.- Specified by:
getDecoderin interfaceProtocolCodecFactory- Parameters:
session- The current session- Returns:
- The decoder instance
-
getEncoderMaxObjectSize
public int getEncoderMaxObjectSize()- Returns:
- the allowed maximum size of the encoded object.
If the size of the encoded object exceeds this value, the encoder
will throw a
IllegalArgumentException. The default value isInteger.MAX_VALUE.This method does the same job with
ObjectSerializationEncoder.getMaxObjectSize().
-
setEncoderMaxObjectSize
public void setEncoderMaxObjectSize(int maxObjectSize) Sets the allowed maximum size of the encoded object. If the size of the encoded object exceeds this value, the encoder will throw aIllegalArgumentException. The default value isInteger.MAX_VALUE.This method does the same job with
ObjectSerializationEncoder.setMaxObjectSize(int).- Parameters:
maxObjectSize- The maximum size of the encoded object
-
getDecoderMaxObjectSize
public int getDecoderMaxObjectSize()- Returns:
- the allowed maximum size of the object to be decoded.
If the size of the object to be decoded exceeds this value, the
decoder will throw a
BufferDataException. The default value is1048576(1MB).This method does the same job with
ObjectSerializationDecoder.getMaxObjectSize().
-
setDecoderMaxObjectSize
public void setDecoderMaxObjectSize(int maxObjectSize) Sets the allowed maximum size of the object to be decoded. If the size of the object to be decoded exceeds this value, the decoder will throw aBufferDataException. The default value is1048576(1MB).This method does the same job with
ObjectSerializationDecoder.setMaxObjectSize(int).- Parameters:
maxObjectSize- The maximum size of the decoded object
-