Actually I did the same way by following mina SumUp example. If the server
is used for different protocol(single protocol), it is very portable and I
only need to figure the setup file to use the protocol on the fly. However,
my GW has multiple protocols. I can't figure out how to implement my decoder
classes since in FirstMessageDecoder I don't know what type protocol it is
unless I decode the head of my message.


2007/4/26, Roman Magarshak <[EMAIL PROTECTED]>:

Not quite.
main:
IoAcceptor acceptor = new SocketAcceptor();
SocketAcceptorConfig cfg = new SocketAcceptorConfig();
DemuxingProtocolCodecFactory dpcf=new DemuxingProtocolCodecFactory();
dpcf.register(FirstMessageEncoder.class);
dpcf.register(SecondMessageEncoder.class);
cfg.getFilterChain().addLast("codec",new ProtocolCodecFilter( dpcf) );

the Demuxing is done by by MINA



On Thu, 2007-04-26 at 00:44 +0800, mat wrote:
> 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.
> >
> >
--
Thank you in advance
       Roman.

***********************************************************************************
This email message and any attachments thereto are intended only for use
by the addressee(s) named above, and may contain legally privileged and/or
confidential information. If the reader of this message is not the intended
recipient, or the employee or agent responsible to deliver it to the
intended recipient, you are hereby notified that any dissemination,
distribution or copying of this communication is strictly prohibited. If you
have received this communication in error, please immediately notify the
[EMAIL PROTECTED] and destroy the original message.

***********************************************************************************

Reply via email to