You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@directory.apache.org by Donald <fl...@gmail.com> on 2005/12/06 06:22:11 UTC

[MINA] how could i get a custom MessageDecoder?

hi Trustin:
I find the MessageDecoder in DemuxingProtocolCodecFactory can not
custom a flexible strategy.Now it be used like this:

    super.register( AddMessageDecoder.class );

Buf if i want use different MessageDecoder according to different
connection,like this :
    MyMessageDecoder(ConnectionStrategyManager manager){
                 //....
    }
and when come a message, i use the manager to decide how to decode the
input bytes, how can i do?

Could i regist a Message Decoder like this:

   ConnectionStrategyManager manager = //...;
   super.register(new MyMessageDecoder(manager));

so we can use a flexible singleton messageDecoder in coming message,can we?

thanks!

Donald

Re: [MINA] how could i get a custom MessageDecoder?

Posted by Donald <fl...@gmail.com>.
great! Thanks very much.

Donald

2005/12/6, Trustin Lee <tr...@gmail.com>:
> 2005/12/6, Donald <fl...@gmail.com>:
> > Another question
> > If i set a attribute in a ProtocolSession, can i get it in the
> > IoSession that according to this ProtocolSession?
>
> Yes.
>
> They share an attribute map.
>
> Trustin
> --
> what we call human nature is actually human habit
> --
> http://gleamynode.net/

Re: [MINA] how could i get a custom MessageDecoder?

Posted by Trustin Lee <tr...@gmail.com>.
2005/12/6, Donald <fl...@gmail.com>:
>
> Another question
> If i set a attribute in a ProtocolSession, can i get it in the
> IoSession that according to this ProtocolSession?


Yes.

They share an attribute map.

Trustin
--
what we call human nature is actually human habit
--
http://gleamynode.net/

Re: [MINA] how could i get a custom MessageDecoder?

Posted by Donald <fl...@gmail.com>.
Another question
If i set a attribute in a ProtocolSession, can i get it in the
IoSession that according to this ProtocolSession?

Thanks...
Donald

2005/12/6, Donald <fl...@gmail.com>:
> Oooo...i am so stupid,thanks.^_^
>
> Donald
>
>
> 2005/12/6, Trustin Lee <tr...@gmail.com>:
> > Hi Donald,
> >
> > 2005/12/6, Donald <fl...@gmail.com>:
> > > hi Trustin:
> > > I find the MessageDecoder in DemuxingProtocolCodecFactory can not
> > > custom a flexible strategy.Now it be used like this:
> > >
> > >     super.register( AddMessageDecoder.class );
> > >
> > > Buf if i want use different MessageDecoder according to different
> > > connection,like this :
> > >     MyMessageDecoder(ConnectionStrategyManager manager){
> > >                  //....
> > >     }
> > > and when come a message, i use the manager to decide how to decode the
> > > input bytes, how can i do?
> > >
> > > Could i regist a Message Decoder like this:
> > >
> > >    ConnectionStrategyManager manager = //...;
> > >    super.register(new MyMessageDecoder(manager));
> > >
> > > so we can use a flexible singleton messageDecoder in coming message,can
> > we?
> >
> > Why don't you use a custom session attribute to set the strategy?  Then you
> > could find out what strategy is in action now easily.
> >
> > HTH,
> > Trustin--
> > what we call human nature is actually human habit
> > --
> > http://gleamynode.net/
>

Re: [MINA] how could i get a custom MessageDecoder?

Posted by Donald <fl...@gmail.com>.
Oooo...i am so stupid,thanks.^_^

Donald


2005/12/6, Trustin Lee <tr...@gmail.com>:
> Hi Donald,
>
> 2005/12/6, Donald <fl...@gmail.com>:
> > hi Trustin:
> > I find the MessageDecoder in DemuxingProtocolCodecFactory can not
> > custom a flexible strategy.Now it be used like this:
> >
> >     super.register( AddMessageDecoder.class );
> >
> > Buf if i want use different MessageDecoder according to different
> > connection,like this :
> >     MyMessageDecoder(ConnectionStrategyManager manager){
> >                  //....
> >     }
> > and when come a message, i use the manager to decide how to decode the
> > input bytes, how can i do?
> >
> > Could i regist a Message Decoder like this:
> >
> >    ConnectionStrategyManager manager = //...;
> >    super.register(new MyMessageDecoder(manager));
> >
> > so we can use a flexible singleton messageDecoder in coming message,can
> we?
>
> Why don't you use a custom session attribute to set the strategy?  Then you
> could find out what strategy is in action now easily.
>
> HTH,
> Trustin--
> what we call human nature is actually human habit
> --
> http://gleamynode.net/

Re: [MINA] how could i get a custom MessageDecoder?

Posted by Trustin Lee <tr...@gmail.com>.
Hi Donald,

2005/12/6, Donald <fl...@gmail.com>:
>
> hi Trustin:
> I find the MessageDecoder in DemuxingProtocolCodecFactory can not
> custom a flexible strategy.Now it be used like this:
>
>     super.register( AddMessageDecoder.class );
>
> Buf if i want use different MessageDecoder according to different
> connection,like this :
>     MyMessageDecoder(ConnectionStrategyManager manager){
>                  //....
>     }
> and when come a message, i use the manager to decide how to decode the
> input bytes, how can i do?
>
> Could i regist a Message Decoder like this:
>
>    ConnectionStrategyManager manager = //...;
>    super.register(new MyMessageDecoder(manager));
>
> so we can use a flexible singleton messageDecoder in coming message,can
> we?


Why don't you use a custom session attribute to set the strategy?  Then you
could find out what strategy is in action now easily.

HTH,
Trustin
--
what we call human nature is actually human habit
--
http://gleamynode.net/