public class SynchronizedProtocolDecoder extends java.lang.Object implements ProtocolDecoder
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.构造器和说明 |
---|
SynchronizedProtocolDecoder(ProtocolDecoder decoder)
Creates a new instance which decorates the specified decoder.
|
限定符和类型 | 方法和说明 |
---|---|
void |
decode(IoSession session,
IoBuffer in,
ProtocolDecoderOutput out)
Decodes binary or protocol-specific content into higher-level message objects.
|
void |
dispose(IoSession session)
Releases all resources related with this decoder.
|
void |
finishDecode(IoSession session,
ProtocolDecoderOutput out)
Invoked when the specified session is closed.
|
ProtocolDecoder |
getDecoder() |
public SynchronizedProtocolDecoder(ProtocolDecoder decoder)
decoder
- The decorated decoderpublic ProtocolDecoder getDecoder()
public void decode(IoSession session, IoBuffer in, ProtocolDecoderOutput out) throws java.lang.Exception
ProtocolDecoder
ProtocolDecoder.decode(IoSession, IoBuffer, ProtocolDecoderOutput)
method with read data, and then the decoder implementation puts decoded
messages into ProtocolDecoderOutput
.decode
在接口中 ProtocolDecoder
session
- The current Sessionin
- the buffer to decodeout
- The ProtocolDecoderOutput
that will receive the decoded messagejava.lang.Exception
- if the read data violated protocol specificationpublic void finishDecode(IoSession session, ProtocolDecoderOutput out) throws java.lang.Exception
ProtocolDecoder.decode(IoSession, IoBuffer, ProtocolDecoderOutput)
method didn't process completely.finishDecode
在接口中 ProtocolDecoder
session
- The current Sessionout
- The ProtocolDecoderOutput
that contains the decoded messagejava.lang.Exception
- if the read data violated protocol specificationpublic void dispose(IoSession session) throws java.lang.Exception
dispose
在接口中 ProtocolDecoder
session
- The current Sessionjava.lang.Exception
- if failed to dispose all resources