public class SynchronizedProtocolEncoder extends Object implements ProtocolEncoder
ProtocolEncoder
implementation which decorates an existing encoder
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. Please use this decorator only when you need to synchronize
on a per-encoder basis instead of on a per-session basis, which is not
common.Constructor and Description |
---|
SynchronizedProtocolEncoder(ProtocolEncoder encoder)
Creates a new instance which decorates the specified encoder.
|
Modifier and Type | Method and Description |
---|---|
void |
dispose(IoSession session)
Releases all resources related with this encoder.
|
void |
encode(IoSession session,
Object message,
ProtocolEncoderOutput out)
Encodes higher-level message objects into binary or protocol-specific data.
|
ProtocolEncoder |
getEncoder() |
public SynchronizedProtocolEncoder(ProtocolEncoder encoder)
encoder
- The decorated encoderpublic ProtocolEncoder getEncoder()
public void encode(IoSession session, Object message, ProtocolEncoderOutput out) throws Exception
ProtocolEncoder.encode(IoSession, Object, ProtocolEncoderOutput)
method with message which is popped from the session write queue, and then
the encoder implementation puts encoded messages (typically IoBuffer
s)
into ProtocolEncoderOutput
.encode
in interface ProtocolEncoder
session
- The current Sessionmessage
- the message to encodeout
- The ProtocolEncoderOutput
that will receive the encoded messageException
- if the message violated protocol specificationpublic void dispose(IoSession session) throws Exception
dispose
in interface ProtocolEncoder
session
- The current SessionException
- if failed to dispose all resourcesCopyright © 2004–2022 Apache MINA Project. All rights reserved.