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
AProtocolDecoderwhich deserializesSerializableJava objects usingIoBuffer.getObject(ClassLoader).
-
-
Field Summary
Fields Modifier and Type Field Description private java.util.List<ClassNameMatcher>acceptMatchersThe classes we accept when deserializing a binary blobprivate java.lang.ClassLoaderclassLoaderprivate intmaxObjectSize
-
Constructor Summary
Constructors Constructor Description ObjectSerializationDecoder()Creates a new instance with theClassLoaderof the current thread.ObjectSerializationDecoder(java.lang.ClassLoader classLoader)Creates a new instance with the specifiedClassLoader.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaccept(java.lang.String... patterns)Accept the wildcard specified classes for deserialization, unless they are otherwise rejected.voidaccept(java.util.regex.Pattern pattern)Accept class names that match the supplied pattern for deserialization, unless they are otherwise rejected.voidaccept(ClassNameMatcher classNameMatcher)Accept class names where the supplied ClassNameMatcher matches for deserialization, unless they are otherwise rejected.protected booleandoDecode(IoSession session, IoBuffer in, ProtocolDecoderOutput out)Implement this method to consume the specified cumulative buffer and decode its content into message(s).intgetMaxObjectSize()voidsetMaxObjectSize(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
-
-
-
-
Field Detail
-
classLoader
private final java.lang.ClassLoader classLoader
-
maxObjectSize
private int maxObjectSize
-
acceptMatchers
private final java.util.List<ClassNameMatcher> acceptMatchers
The classes we accept when deserializing a binary blob
-
-
Constructor Detail
-
ObjectSerializationDecoder
public ObjectSerializationDecoder()
Creates a new instance with theClassLoaderof the current thread.
-
ObjectSerializationDecoder
public ObjectSerializationDecoder(java.lang.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 is1048576(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 is1048576(1MB).- Parameters:
maxObjectSize- The maximum size for an object to be decoded
-
doDecode
protected boolean doDecode(IoSession session, IoBuffer in, ProtocolDecoderOutput out) throws java.lang.Exception
Implement this method to consume the specified cumulative buffer and decode its content into message(s).- Specified by:
doDecodein classCumulativeProtocolDecoder- Parameters:
session- The current Sessionin- the cumulative bufferout- TheProtocolDecoderOutputthat will receive the decoded message- Returns:
trueif and only if there's more to decode in the buffer and you want to havedoDecodemethod invoked again. Returnfalseif remaining data is not enough to decode, then this method will be invoked again when more data is cumulated.- Throws:
java.lang.Exception- if cannot decodein.
-
accept
public void accept(ClassNameMatcher classNameMatcher)
Accept class names where the supplied ClassNameMatcher matches for deserialization, unless they are otherwise rejected.- Parameters:
classNameMatcher- the matcher to use
-
accept
public void accept(java.util.regex.Pattern pattern)
Accept class names that match the supplied pattern for deserialization, unless they are otherwise rejected.- Parameters:
pattern- standard Java regexp
-
accept
public void accept(java.lang.String... patterns)
Accept the wildcard specified classes for deserialization, unless they are otherwise rejected.- Parameters:
patterns- Wildcard file name patterns as defined by org.apache.commons.io.FilenameUtils.wildcardMatch(String, String)
-
-