Yes Trustin is right, I am talking about DemuxingProtocolCodecFactory

You can pass an extra byte for message type and create a message object,
decoder, encoder,handler per message type. 
This will completely remove IF ELSE or SWITCH in your codec.

It creates a lot of classes but its better than IF ELSE or SWITCH. This
makes code maintainable. because in my blocking server implementation, i had
a dedicated serving thread on server and in its run method I had a SWITCH
with multiple CASES. And the run method is now 2K lines of code, and I find
it difficult to maintain and difficult to add new message type in the
system. 

So now in my non blocking implementation using MINA, I have Massage Object,
Message Encoder, Message Decoder, and Message Handler per message type. So I
have added total 60 new classes, for my 15 different types of messages. 

Does this make sense Trustin ? Is this the correct way to use MINA's
DemuxingProtocolCodecFactory?

Thanks in Advance 

Regards,
Yogs




mat-29 wrote:
> 
> In my case, i have to use IF ELSE to judge which protocol, right?
> 
> 2007/4/25, Trustin Lee <[EMAIL PROTECTED]>:
>>
>> On 4/25/07, mat <[EMAIL PROTECTED]> wrote:
>> > Really? However my server is listening on one port. How messageDecoder
>> class
>> > knows different type of messages? Can you explain? Thanks.
>>
>> It seems like Yogs is talking about creating multiple MessageDecoder
>> classes?  You can register multiple MessageDecoders and
>> MessageEncoders to DemuxingProtocolCodecFactory.
>>
>> HTH,
>> Trustin
>> --
>> what we call human nature is actually human habit
>> --
>> http://gleamynode.net/
>> --
>> PGP Key ID: 0x0255ECA6
>>
> 
> 

-- 
View this message in context: 
http://www.nabble.com/How-can-I-configure-multiple-decoders-in-MINA--tf3561571.html#a10183671
Sent from the mina dev mailing list archive at Nabble.com.

Reply via email to