Class SynchronizedProtocolDecoder
java.lang.Object
org.apache.mina.filter.codec.SynchronizedProtocolDecoder
- All Implemented Interfaces:
ProtocolDecoder
A
ProtocolDecoder implementation 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 by ProtocolCodecFilter. Please use this
decorator only when you need to synchronize on a per-decoder basis, which
is not common.-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionCreates a new instance which decorates the specifieddecoder. -
Method Summary
Modifier and TypeMethodDescriptionvoiddecode(IoSession session, IoBuffer in, ProtocolDecoderOutput out) Decodes binary or protocol-specific content into higher-level message objects.voidReleases all resources related with this decoder.voidfinishDecode(IoSession session, ProtocolDecoderOutput out) Invoked when the specifiedsessionis closed.
-
Field Details
-
decoder
-
-
Constructor Details
-
SynchronizedProtocolDecoder
Creates a new instance which decorates the specifieddecoder.- Parameters:
decoder- The decorated decoder
-
-
Method Details
-
getDecoder
- Returns:
- the decoder this decoder is decorating.
-
decode
Decodes binary or protocol-specific content into higher-level message objects. MINA invokesProtocolDecoder.decode(IoSession, IoBuffer, ProtocolDecoderOutput)method with read data, and then the decoder implementation puts decoded messages intoProtocolDecoderOutput.- Specified by:
decodein interfaceProtocolDecoder- Parameters:
session- The current Sessionin- the buffer to decodeout- TheProtocolDecoderOutputthat will receive the decoded message- Throws:
Exception- if the read data violated protocol specification
-
finishDecode
Invoked when the specifiedsessionis closed. This method is useful when you deal with the protocol which doesn't specify the length of a message such as HTTP response withoutcontent-lengthheader. Implement this method to process the remaining data thatProtocolDecoder.decode(IoSession, IoBuffer, ProtocolDecoderOutput)method didn't process completely.- Specified by:
finishDecodein interfaceProtocolDecoder- Parameters:
session- The current Sessionout- TheProtocolDecoderOutputthat contains the decoded message- Throws:
Exception- if the read data violated protocol specification
-
dispose
Releases all resources related with this decoder.- Specified by:
disposein interfaceProtocolDecoder- Parameters:
session- The current Session- Throws:
Exception- if failed to dispose all resources
-