OK. Let me give you a little bit more details and see if you can help me
out.
I had a GW server which have to encode and decode 2 differents
protocols(listening on one port). Now I implemented a protocol codec filter
to encode and decode extends AbstractMessageDecoder. However, in decodeBody
and encodeBody functions. I still HAVE to use IF ELSE to judge which
protocols according to heads of my protocols. I really can't figure out how
WITHOUT doing this.


2007/4/25, Yogs <[EMAIL PROTECTED]>:


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