Package org.apache.mina.filter.codec
Class SynchronizedProtocolEncoder
- java.lang.Object
-
- org.apache.mina.filter.codec.SynchronizedProtocolEncoder
-
- All Implemented Interfaces:
ProtocolEncoder
public class SynchronizedProtocolEncoder extends java.lang.Object implements ProtocolEncoder
AProtocolEncoder
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 Summary
Constructors Constructor Description SynchronizedProtocolEncoder(ProtocolEncoder encoder)
Creates a new instance which decorates the specified encoder.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
dispose(IoSession session)
Releases all resources related with this encoder.void
encode(IoSession session, java.lang.Object message, ProtocolEncoderOutput out)
Encodes higher-level message objects into binary or protocol-specific data.ProtocolEncoder
getEncoder()
Returns the encoder this encoder is decorating.
-
-
-
Constructor Detail
-
SynchronizedProtocolEncoder
public SynchronizedProtocolEncoder(ProtocolEncoder encoder)
Creates a new instance which decorates the specified encoder.
-
-
Method Detail
-
getEncoder
public ProtocolEncoder getEncoder()
Returns the encoder this encoder is decorating.
-
encode
public void encode(IoSession session, java.lang.Object message, ProtocolEncoderOutput out) throws java.lang.Exception
Description copied from interface:ProtocolEncoder
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 encodedByteBuffer
s intoProtocolEncoderOutput
.- Specified by:
encode
in interfaceProtocolEncoder
- Throws:
java.lang.Exception
- if the message violated protocol specification
-
dispose
public void dispose(IoSession session) throws java.lang.Exception
Description copied from interface:ProtocolEncoder
Releases all resources related with this encoder.- Specified by:
dispose
in interfaceProtocolEncoder
- Throws:
java.lang.Exception
- if failed to dispose all resources
-
-