public interface ICodecPipeline
ICodecExecutor
.
All the methods that change the pipeline should always validate if the change that is about to be made will not break the matching of the inbound and outbound types between codecs in the pipeline.
Special care must be taken when adding or inserting the first codec into the pipeline:
byte[]
or ByteBuffer
byte[]
, ByteBuffer
or IByteBufferHolder
The diagram describing how data are processed thru a pipeline
I/O read I/O write | | +-------------+------------------------------+-------------+ | | CodecPipeline /|\ | | \|/ | | | +--------+--------+ +--------+--------+ | | | First Decoder | | First Encoder | | | +--------+--------+ +--------+--------+ | | | /|\ | | \|/ | | | +--------+--------+ +--------+--------+ | | | Second Decoder | | Second Encoder | | | +--------+--------+ +--------+--------+ | | . /|\ | | . . | | . . | | . . | | \|/ . | | +--------+--------+ +--------+--------+ | | | Last Decoder | | Last Encoder | | | +--------+--------+ +--------+--------+ | | | /|\ | | \|/ | | +-------------+------------------------------+-------------+ | | Handler.read() Session.write()Thread-safe considerations: Any class implementing this interface should be thread safe as it is expected that the internal state of the pipeline can be changed at any time.
Modifier and Type | Method and Description |
---|---|
void |
add(Object key,
IDecoder<?,?> decoder)
Appends a decoder at the last position of this pipeline.
|
void |
add(Object key,
IEncoder<?,?> encoder)
Appends a encoder at the last position of this pipeline.
|
void |
addAfter(Object baseKey,
Object key,
IDecoder<?,?> decoder)
Inserts a decoder after an existing decoder of this pipeline.
|
void |
addAfter(Object baseKey,
Object key,
IEncoder<?,?> encoder)
Inserts a encoder after an existing decoder of this pipeline.
|
void |
addBefore(Object baseKey,
Object key,
IDecoder<?,?> decoder)
Inserts a decoder before an existing decoder of this pipeline.
|
void |
addBefore(Object baseKey,
Object key,
IEncoder<?,?> encoder)
Inserts a encoder before an existing encoder of this pipeline.
|
void |
addFirst(Object key,
IDecoder<?,?> decoder)
Inserts a decoder at the first position of this pipeline.
|
void |
addFirst(Object key,
IEncoder<?,?> encoder)
Inserts a encoder at the first position of this pipeline.
|
List<Object> |
decoderKeys()
Returns a list of keys that identify all decoders in this pipeline.
|
List<Object> |
encoderKeys()
Returns a list of keys that identify all encoders in this pipeline.
|
ICodec<?,?> |
get(Object key)
Returns the codec identified by the specified key in this pipeline.
|
ICodec<?,?> |
remove(Object key)
Removes the codec identified by the specified key from this pipeline.
|
IDecoder<?,?> |
replace(Object oldKey,
Object key,
IDecoder<?,?> decoder)
Replaces the decoder identified by the specified old key with a new
decoder in this pipeline.
|
IEncoder<?,?> |
replace(Object oldKey,
Object key,
IEncoder<?,?> encoder)
Replaces the encoder identified by the specified old key with a new
encoder in this pipeline.
|
void add(Object key, IDecoder<?,?> decoder)
key
- the key under which the decoder should be appendeddecoder
- the decoder to appendIllegalArgumentException
- if a decoder identified by the specified key already exists
in this pipelineIllegalArgumentException
- if the decoder has incompatible the inbound or the outbound
typeNullPointerException
- if any of the arguments is null
void add(Object key, IEncoder<?,?> encoder)
key
- the key under which the encoder should be appendedencoder
- the encoder to appendIllegalArgumentException
- if a encoder identified by the specified key already exists
in this pipelineIllegalArgumentException
- if the encoder has incompatible the inbound or the outbound
typeNullPointerException
- if any of the arguments is null
void addAfter(Object baseKey, Object key, IDecoder<?,?> decoder)
baseKey
- the key identifying the existing decoderkey
- the key under which the decoder should be inserted afterdecoder
- the decoder to insert afterNoSuchElementException
- if the decoder identified by the specified base key does not
exist in this pipelineIllegalArgumentException
- if a decoder identified by the specified key already exists
in this pipelineIllegalArgumentException
- if the decoder has incompatible the inbound or the outbound
typeNullPointerException
- if any of the arguments is null
void addAfter(Object baseKey, Object key, IEncoder<?,?> encoder)
baseKey
- the key identifying the existing encoderkey
- the key under which the encoder should be inserted afterencoder
- the encoder to insert afterNoSuchElementException
- if the encoder identified by the specified base key does not
exist in this pipelineIllegalArgumentException
- if a encoder identified by the specified key already exists
in this pipelineIllegalArgumentException
- if the encoder has incompatible the inbound or the outbound
typeNullPointerException
- if any of the arguments is null
void addFirst(Object key, IDecoder<?,?> decoder)
key
- the key under which the decoder should be inserted firstdecoder
- the decoder to insert firstIllegalArgumentException
- if a decoder identified by the specified key already exists
in this pipelineIllegalArgumentException
- if the decoder has incompatible the inbound or the outbound
typeNullPointerException
- if any of the arguments is null
void addFirst(Object key, IEncoder<?,?> encoder)
key
- the key under which the encoder should be inserted firstencoder
- the encoder to insert firstIllegalArgumentException
- if a encoder identified by the specified key already exists
in this pipelineIllegalArgumentException
- if the encoder has incompatible the inbound or the outbound
typeNullPointerException
- if any of the arguments is null
void addBefore(Object baseKey, Object key, IDecoder<?,?> decoder)
baseKey
- the key identifying the existing decoderkey
- the key under which the decoder should be inserted beforedecoder
- the decoder to insert beforeNoSuchElementException
- if the decoder identified by the specified base key does not
exist in this pipelineIllegalArgumentException
- if a decoder identified by the specified key already exists
in this pipelineIllegalArgumentException
- if the decoder has incompatible the inbound or the outbound
typeNullPointerException
- if any of the arguments is null
void addBefore(Object baseKey, Object key, IEncoder<?,?> encoder)
baseKey
- the key identifying the existing encoderkey
- the key under which the encoder should be inserted beforeencoder
- the encoder to insert beforeNoSuchElementException
- if the encoder identified by the specified base key does not
exist in this pipelineIllegalArgumentException
- if a encoder identified by the specified key already exists
in this pipelineIllegalArgumentException
- if the encoder has incompatible the inbound or the outbound
typeNullPointerException
- if any of the arguments is null
IDecoder<?,?> replace(Object oldKey, Object key, IDecoder<?,?> decoder)
oldKey
- the key of the decoder to be replacedkey
- the key under which the replacement should be addeddecoder
- the decoder which is used as replacementNoSuchElementException
- if the decoder identified by the specified old key does not
exist in this pipelineIllegalArgumentException
- if a decoder identified by the specified key already exists
in this pipeline, except for the decoder to be replacedIllegalArgumentException
- if the decoder has incompatible the inbound or the outbound
typeNullPointerException
- if any of the arguments is null
IEncoder<?,?> replace(Object oldKey, Object key, IEncoder<?,?> encoder)
oldKey
- the key of the encoder to be replacedkey
- the key under which the replacement should be addedencoder
- the encoder which is used as replacementNoSuchElementException
- if the encoder identified by the specified old key does not
exist in this pipelineIllegalArgumentException
- if a encoder identified by the specified key already exists
in this pipeline, except for the encoder to be replacedIllegalArgumentException
- if the encoder has incompatible the inbound or the outbound
typeNullPointerException
- if any of the arguments is null
ICodec<?,?> remove(Object key)
key
- the key under which the codec was storedNoSuchElementException
- if there's no such codec that is identified by the specified
key in this pipelineIllegalArgumentException
- if removing of the codec that is identified by the specified
key would break the matching of the inbound and outbound
types between other codecs in the pipeline.NullPointerException
- if the specified key is null
ICodec<?,?> get(Object key)
key
- the key under which the codec was storednull
if there's no such codec in this pipeline.List<Object> encoderKeys()
Copyright © 2017–2022 SNF4J.ORG. All rights reserved.