Class ObjectSerializationDecoder
- java.lang.Object
-
- org.apache.mina.filter.codec.ProtocolDecoderAdapter
-
- org.apache.mina.filter.codec.CumulativeProtocolDecoder
-
- org.apache.mina.filter.codec.serialization.ObjectSerializationDecoder
-
- All Implemented Interfaces:
ProtocolDecoder
public class ObjectSerializationDecoder extends CumulativeProtocolDecoder
AProtocolDecoder
which deserializesSerializable
Java objects usingIoBuffer.getObject(ClassLoader)
.- Author:
- Apache MINA Project
-
-
Constructor Summary
Constructors Constructor Description ObjectSerializationDecoder()
Creates a new instance with theClassLoader
of the current thread.ObjectSerializationDecoder(ClassLoader classLoader)
Creates a new instance with the specifiedClassLoader
.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected boolean
doDecode(IoSession session, IoBuffer in, ProtocolDecoderOutput out)
Implement this method to consume the specified cumulative buffer and decode its content into message(s).int
getMaxObjectSize()
void
setMaxObjectSize(int maxObjectSize)
Sets the allowed maximum size of the object to be decoded.-
Methods inherited from class org.apache.mina.filter.codec.CumulativeProtocolDecoder
decode, dispose, setTransportMetadataFragmentation
-
Methods inherited from class org.apache.mina.filter.codec.ProtocolDecoderAdapter
finishDecode
-
-
-
-
Constructor Detail
-
ObjectSerializationDecoder
public ObjectSerializationDecoder()
Creates a new instance with theClassLoader
of the current thread.
-
ObjectSerializationDecoder
public ObjectSerializationDecoder(ClassLoader classLoader)
Creates a new instance with the specifiedClassLoader
.- Parameters:
classLoader
- The class loader to use
-
-
Method Detail
-
getMaxObjectSize
public int getMaxObjectSize()
- Returns:
- the allowed maximum size of the object to be decoded.
If the size of the object to be decoded exceeds this value, this
decoder will throw a
BufferDataException
. The default value is 1048576 (1MB).
-
setMaxObjectSize
public void setMaxObjectSize(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, this decoder will throw aBufferDataException
. The default value is 1048576 (1MB).- Parameters:
maxObjectSize
- The maximum size for an object to be decoded
-
doDecode
protected boolean doDecode(IoSession session, IoBuffer in, ProtocolDecoderOutput out) throws Exception
Implement this method to consume the specified cumulative buffer and decode its content into message(s).- Specified by:
doDecode
in classCumulativeProtocolDecoder
- Parameters:
session
- The current Sessionin
- the cumulative bufferout
- TheProtocolDecoderOutput
that will receive the decoded message- Returns:
- true if and only if there's more to decode in the buffer and you want to have doDecode method invoked again. Return false if remaining data is not enough to decode, then this method will be invoked again when more data is cumulated.
- Throws:
Exception
- if cannot decode in.
-
-