Class SynchronizedProtocolEncoder
java.lang.Object
org.apache.mina.filter.codec.SynchronizedProtocolEncoder
- All Implemented Interfaces:
ProtocolEncoder
A
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.-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionCreates a new instance which decorates the specifiedencoder. -
Method Summary
Modifier and TypeMethodDescriptionvoidReleases all resources related with this encoder.voidencode(IoSession session, Object message, ProtocolEncoderOutput out) Encodes higher-level message objects into binary or protocol-specific data.
-
Field Details
-
encoder
-
-
Constructor Details
-
SynchronizedProtocolEncoder
Creates a new instance which decorates the specifiedencoder.- Parameters:
encoder- The decorated encoder
-
-
Method Details
-
getEncoder
- Returns:
- the encoder this encoder is decorating.
-
encode
Encodes higher-level message objects into binary or protocol-specific data. MINA invokesProtocolEncoder.encode(IoSession, Object, ProtocolEncoderOutput)method with message which is popped from the session write queue, and then the encoder implementation puts encoded messages (typicallyIoBuffers) intoProtocolEncoderOutput.- Specified by:
encodein interfaceProtocolEncoder- Parameters:
session- The current Sessionmessage- the message to encodeout- TheProtocolEncoderOutputthat will receive the encoded message- Throws:
Exception- if the message violated protocol specification
-
dispose
Releases all resources related with this encoder.- Specified by:
disposein interfaceProtocolEncoder- Parameters:
session- The current Session- Throws:
Exception- if failed to dispose all resources
-