Package org.apache.mina.filter.codec
Class SynchronizedProtocolDecoder
- java.lang.Object
-
- org.apache.mina.filter.codec.SynchronizedProtocolDecoder
-
- All Implemented Interfaces:
ProtocolDecoder
public class SynchronizedProtocolDecoder extends java.lang.Object implements ProtocolDecoder
AProtocolDecoderimplementation which decorates an existing decoder to be thread-safe. Please be careful if you're going to use this decorator because it can be a root of performance degradation in a multi-thread environment. Also, by default, appropriate synchronization is done on a per-session basis byProtocolCodecFilter. Please use this decorator only when you need to synchronize on a per-decoder basis, which is not common.
-
-
Constructor Summary
Constructors Constructor Description SynchronizedProtocolDecoder(ProtocolDecoder decoder)Creates a new instance which decorates the specified decoder.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voiddecode(IoSession session, ByteBuffer in, ProtocolDecoderOutput out)Decodes binary or protocol-specific content into higher-level message objects.voiddispose(IoSession session)Releases all resources related with this decoder.voidfinishDecode(IoSession session, ProtocolDecoderOutput out)Invoked when the specified session is closed.ProtocolDecodergetDecoder()Returns the decoder this decoder is decorating.
-
-
-
Constructor Detail
-
SynchronizedProtocolDecoder
public SynchronizedProtocolDecoder(ProtocolDecoder decoder)
Creates a new instance which decorates the specified decoder.
-
-
Method Detail
-
getDecoder
public ProtocolDecoder getDecoder()
Returns the decoder this decoder is decorating.
-
decode
public void decode(IoSession session, ByteBuffer in, ProtocolDecoderOutput out) throws java.lang.Exception
Description copied from interface:ProtocolDecoderDecodes binary or protocol-specific content into higher-level message objects. MINA invokesProtocolDecoder.decode(IoSession, ByteBuffer, ProtocolDecoderOutput)method with read data, and then the decoder implementation puts decoded messages intoProtocolDecoderOutput.- Specified by:
decodein interfaceProtocolDecoder- Throws:
java.lang.Exception- if the read data violated protocol specification
-
finishDecode
public void finishDecode(IoSession session, ProtocolDecoderOutput out) throws java.lang.Exception
Description copied from interface:ProtocolDecoderInvoked when the specified session is closed. This method is useful when you deal with the protocol which doesn't specify the length of a message such as HTTP response without content-length header. Implement this method to process the remaining data thatProtocolDecoder.decode(IoSession, ByteBuffer, ProtocolDecoderOutput)method didn't process completely.- Specified by:
finishDecodein interfaceProtocolDecoder- Throws:
java.lang.Exception- if the read data violated protocol specification
-
dispose
public void dispose(IoSession session) throws java.lang.Exception
Description copied from interface:ProtocolDecoderReleases all resources related with this decoder.- Specified by:
disposein interfaceProtocolDecoder- Throws:
java.lang.Exception- if failed to dispose all resources
-
-