public interface ICodecExecutor
Thread-safe considerations: All methods in this interface, except
getPipeline()
, are always called by the SNF4J framework in the same
thread.
All new changes done in the associated pipeline should not immediately affect
the encoding and decoding done by the executor. The synchronization between
the pipeline and the executor should be perfomed in the sync methods.
Modifier and Type | Method and Description |
---|---|
void |
addChild(ISession session,
ICodecExecutor executor)
Adds a child codec executor that will be receiving session events
received by this codec executor.
|
List<Object> |
decode(ISession session,
byte[] data)
Decodes bytes from a byte array.
|
List<Object> |
decode(ISession session,
ByteBuffer data)
Decodes bytes from a byte buffer.
|
List<Object> |
encode(ISession session,
byte[] data)
Encodes bytes from a byte array.
|
List<Object> |
encode(ISession session,
ByteBuffer data)
Encodes bytes from a byte buffer.
|
List<Object> |
encode(ISession session,
Object msg)
Encodes a message.
|
void |
event(ISession session,
SessionEvent event)
Signals a session event to all event-driven codecs in the associated
pipeline.
|
IBaseDecoder<?> |
getBaseDecoder()
Gets the base decoder.
|
ICodecPipeline |
getPipeline()
Returns the codec pipeline that is associated with this codec executor.
|
boolean |
hasDecoders()
Informs if the pipeline has decoders that produce outbound object(s).
|
void |
syncDecoders(ISession session)
Informs the codec executor that right now is the best moment to safely
synchronize any pending changes for decoders in the associated
pipeline.
|
void |
syncEncoders(ISession session)
Informs the codec executor that right now is the best moment to safely
synchronize any pending changes for encoders in the associated
pipeline.
|
void |
syncEventDrivenCodecs(ISession session)
Informs the codec executor that right now is the best moment to safely
synchronize any pending changes for event-driven codecs in the associated
pipeline.
|
ICodecPipeline getPipeline()
void syncDecoders(ISession session)
Performance considerations: This method is called every time new data need to be decoded and so it should not perform any heavy tasks.
session
- the session the codec executor is associated withvoid syncEncoders(ISession session)
Performance considerations: This method is called every time new data need to be encoded and so it should not perform any heavy tasks.
session
- the session the codec executor is associated withvoid syncEventDrivenCodecs(ISession session)
Performance considerations: This method is called every time the state of the associated session is changing so it should not perform any heavy tasks.
session
- the session the codec executor is associated withIEventDrivenCodec
IBaseDecoder<?> getBaseDecoder()
The returned value should not be affected by changes in the associated
pipeline that have not been synchronized yet by calling
syncDecoders(org.snf4j.core.session.ISession)
.
Performance considerations: This method is called every time new data need to be decoded and so it should not perform any heavy tasks.
IBaseDecoder
, if the first decoder does not implement it
then null
should be returned.boolean hasDecoders()
The returned value should not be affected by changes in the associated
pipeline that have not been synchronized yet by calling
syncDecoders(org.snf4j.core.session.ISession)
.
Performance considerations: This method is called every time new data need to be decoded and so it should not perform any heavy tasks.
true
if the pipeline has at least one encoder that
produces outbound object(s).List<Object> encode(ISession session, ByteBuffer data) throws Exception
This method should ignore all changes in the associated pipeline that
have not been synchronized yet by calling syncEncoders(org.snf4j.core.session.ISession)
.
session
- the session for which the encoding is performeddata
- the bytes to encodenull
if the
pipeline is empty or has no encoders that produce outbound
object(s)Exception
- if one of the encoders failed during the encodingList<Object> encode(ISession session, byte[] data) throws Exception
This method should ignore all changes in the associated pipeline that
have not been synchronized yet by calling syncEncoders(org.snf4j.core.session.ISession)
.
session
- the session for which the encoding is performeddata
- the bytes to encodenull
if the
pipeline is empty or has no encoders that produce outbound
object(s)Exception
- if one of the encoders failed during the encodingList<Object> encode(ISession session, Object msg) throws Exception
This method should ignore all changes in the associated pipeline that
have not been synchronized yet by calling syncEncoders(org.snf4j.core.session.ISession)
.
session
- the session for which the encoding is performedmsg
- the message to encodenull
if the
pipeline is empty or has no encoders that produce outbound
object(s)Exception
- if one of the encoders failed during the encodingList<Object> decode(ISession session, byte[] data) throws Exception
This method should ignore all changes in the associated pipeline that
have not been synchronized yet by calling syncDecoders(org.snf4j.core.session.ISession)
.
session
- the session for which the decoding is performeddata
- the bytes to decodenull
if the
pipeline is empty or has no decoders that produce outbound
object(s)Exception
- if one of the decoders failed during the decodingList<Object> decode(ISession session, ByteBuffer data) throws Exception
This method should ignore all changes in the associated pipeline that
have not been synchronized yet by calling syncDecoders(org.snf4j.core.session.ISession)
.
session
- the session for which the decoding is performeddata
- the bytes to decodenull
if the
pipeline is empty or has no decoders that produce outbound
object(s)Exception
- if one of the decoders failed during the decodingvoid event(ISession session, SessionEvent event)
session
- the session the codec executor is associated withevent
- the session eventvoid addChild(ISession session, ICodecExecutor executor)
session
- the session the codec executor is associated withexecutor
- a child codec executorCopyright © 2017–2021 SNF4J.ORG. All rights reserved.