Michael Bauroth wrote:
> Hi,
>
> is there probably someone who can hopefully answer this question in a
> short way? ;)
>
> Best Regards
> Michael
>
>
> Michael Bauroth wrote:
>
>> Hi,
>>
>> I've implemented the first decoders and registered it to my
>> DemuxingProtocolCodecFactory. Now happen three questions to me:
>>
>> 1. I don't want to decode all incoming data with this "demuxer".
>> Unfortunately the factory throws an exception when no appropiate
>> decoder was found. Is it correct and "conform", when I ignore this
>> exception in my SessionHandler? Will the decoding process for this
>> ByteBuffer data then continue with the next stage decoder (next in
>> chain)?
Nope, I don't think so. Why don't you implement a fallback
MessageDecoder which just returns the original ByteBuffer? Just register
last and it should work.
>>
>> 2. When you confirm with 1., what do you recommend for the method
>> doDecode in the DemuxingProtocolCodecFactory (see code snippet):
>>
>> <code>
>> if( undecodables == decoders.length )
>> {
>> // Throw an exception if all decoders cannot decode data.
>> String dump = in.getHexDump();
>> in.position( in.limit() ); // Skip data
>> throw new ProtocolDecoderException(
>> "No appropriate message decoder: " + dump );
>> }
>> </code>
>>
>> The line <code>in.getHexDump();</code> leads here in an unneeded extra
>> penalty?
If you have a fallback as I described above this code will never be
executed.
>>
>> 3. I want to use two demuxers one after the other in a chain. The
>> desired behaviour should be, that the second demuxer in a chain uses
>> the generated ProtocolOutput from the previous decoder to work on it
>> instead of (or additionally to) the ByteBuffer parsing. What is the
>> right way to solve this? Must I store the results from the first
>> decoder as a session attribute and reuse it in the second decoder? Or
>> leads this in broken Mina design principles. Have you eventually a
>> better solution for me?
Please clarify. Do you want the second decoder to decode the object
created by the first decoder? Or do you want the second decoder only to
care about messages which couldn't be coded by the first decoder?
/Niklas