public class DefaultCodecExecutor extends Object implements ICodecExecutor
ICodecExecutor
.Constructor and Description |
---|
DefaultCodecExecutor() |
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.
|
public final void syncDecoders(ISession session)
ICodecExecutor
Performance considerations: This method is called every time new data need to be decoded and so it should not perform any heavy tasks.
syncDecoders
in interface ICodecExecutor
session
- the session the codec executor is associated withpublic final void syncEncoders(ISession session)
ICodecExecutor
Performance considerations: This method is called every time new data need to be encoded and so it should not perform any heavy tasks.
syncEncoders
in interface ICodecExecutor
session
- the session the codec executor is associated withpublic void syncEventDrivenCodecs(ISession session)
ICodecExecutor
Performance considerations: This method is called every time the state of the associated session is changing so it should not perform any heavy tasks.
syncEventDrivenCodecs
in interface ICodecExecutor
session
- the session the codec executor is associated withIEventDrivenCodec
public final ICodecPipeline getPipeline()
ICodecExecutor
getPipeline
in interface ICodecExecutor
public boolean hasDecoders()
ICodecExecutor
The returned value should not be affected by changes in the associated
pipeline that have not been synchronized yet by calling
ICodecExecutor.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.
hasDecoders
in interface ICodecExecutor
true
if the pipeline has at least one encoder that
produces outbound object(s).public List<Object> encode(ISession session, ByteBuffer data) throws Exception
ICodecExecutor
This method should ignore all changes in the associated pipeline that
have not been synchronized yet by calling ICodecExecutor.syncEncoders(org.snf4j.core.session.ISession)
.
encode
in interface ICodecExecutor
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 encodingpublic List<Object> encode(ISession session, byte[] data) throws Exception
ICodecExecutor
This method should ignore all changes in the associated pipeline that
have not been synchronized yet by calling ICodecExecutor.syncEncoders(org.snf4j.core.session.ISession)
.
encode
in interface ICodecExecutor
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 encodingpublic List<Object> encode(ISession session, Object msg) throws Exception
ICodecExecutor
This method should ignore all changes in the associated pipeline that
have not been synchronized yet by calling ICodecExecutor.syncEncoders(org.snf4j.core.session.ISession)
.
encode
in interface ICodecExecutor
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 encodingpublic List<Object> decode(ISession session, byte[] data) throws Exception
ICodecExecutor
This method should ignore all changes in the associated pipeline that
have not been synchronized yet by calling ICodecExecutor.syncDecoders(org.snf4j.core.session.ISession)
.
decode
in interface ICodecExecutor
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 decodingpublic List<Object> decode(ISession session, ByteBuffer data) throws Exception
ICodecExecutor
This method should ignore all changes in the associated pipeline that
have not been synchronized yet by calling ICodecExecutor.syncDecoders(org.snf4j.core.session.ISession)
.
decode
in interface ICodecExecutor
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 decodingpublic final IBaseDecoder<?> getBaseDecoder()
ICodecExecutor
The returned value should not be affected by changes in the associated
pipeline that have not been synchronized yet by calling
ICodecExecutor.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.
getBaseDecoder
in interface ICodecExecutor
IBaseDecoder
, if the first decoder does not implement it
then null
should be returned.public void event(ISession session, SessionEvent event)
ICodecExecutor
event
in interface ICodecExecutor
session
- the session the codec executor is associated withevent
- the session eventpublic void addChild(ISession session, ICodecExecutor executor)
ICodecExecutor
addChild
in interface ICodecExecutor
session
- the session the codec executor is associated withexecutor
- a child codec executorCopyright © 2017–2021 SNF4J.ORG. All rights reserved.