You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@mina.apache.org by slowness chen <sl...@gmail.com> on 2007/07/02 05:12:18 UTC

Re: how can I make multiple ProtocolCodecFilters work together?

you have one protocolcodecfilter , e.g. "codec", you can judge which
protococodeclfilter is appropriate according to some conditions, then
replace "codec" with that protococodeclfilter :

session.getFilterChain().remove("codec");
session.getFilterChain().addLast( "codec", new ProtocolCodecFilter( new
MyCodecFactory( )));

On 6/28/07, mat <fo...@gmail.com> wrote:
>
> Can you give more details? Thanks.
>
> On 6/28/07, slowness chen <sl...@gmail.com> wrote:
> >
> > I fixed my problem by replacing the protocolcodecfilter dynamically.
> >
> > On 6/27/07, mat <fo...@gmail.com> wrote:
> > >
> > > I still wonder if we asked the same questions. Actually for that link,
> I
> > > don't understand very well. If you dig out something, can you share
> with
> > > me?
> > > Thanks.
> > >
> > > On 6/27/07, slowness chen <sl...@gmail.com> wrote:
> > > >
> > > > thanks, this link is helpful
> > > >
> > > > On 6/27/07, mat <fo...@gmail.com> wrote:
> > > > >
> > > > > Do we ask the same questions?
> > > > >
> > > > >
> > > >
> > >
> >
> http://www.nabble.com/How-can-I-configure-multiple-decoders-in-MINA--tf3561571.html#a9946908
> > > > >
> > > > >
> > > > > On 6/27/07, slowness chen <sl...@gmail.com> wrote:
> > > > > >
> > > > > > I tried extending from ProtocolCodecFilter :
> > > > > >
> > > > > > public class MyProtocolCodecFilter extends ProtocolCodecFilter{
> > > > > >    public MyProtocolCodecFilter(ProtocolCodecFactory factory) {
> > > > > >        super(factory);
> > > > > >    }
> > > > > >    public void onPreAdd( IoFilterChain parent, String name,
> > > NextFilter
> > > > > > nextFilter ) throws Exception
> > > > > >    {
> > > > > >    }
> > > > > > }
> > > > > >
> > > > > > now the session is set up sucessfully,but only the first
> > > > > > ProtocolCodecFilter
> > > > > > 's "decode" gets called.
> > > > > >
> > > > > > On 6/26/07, Germán Borbolla Flores <gb...@insys-corp.com.mx>
> > > > wrote:
> > > > > > >
> > > > > > > Maybe you could extend from ProtocolCodecFilter and override
> > > > onPreAdd,
> > > > > > > and remove the validation, I think that might just work.
> > > > > > >
> > > > > > > Germán Borbolla Flores wrote:
> > > > > > > > You cannot add more than one ProtocolCodecFilter:
> > > > > > > >
> > > > > > > > --- Taken from ProtocolCodecFilter.java
> > > > > > > >        if( parent.contains( ProtocolCodecFilter.class ) )
> > > > > > > >        {
> > > > > > > >            throw new IllegalStateException( "A filter chain
> > > cannot
> > > > > > > > contain more than one ProtocolCodecFilter." );
> > > > > > > >        }
> > > > > > > >
> > > > > > > > Maybe the exception is not getting caught.
> > > > > > > >
> > > > > > > >
> > > > > > > > slowness chen wrote:
> > > > > > > >> Hey guys,
> > > > > > > >>
> > > > > > > >> I  have multiple ProtocolCodecFilters:
> > > > > > > >>
> > > > > > > >>        SocketAcceptorConfig cfg = new
> SocketAcceptorConfig();
> > > > > > > >>        cfg.getSessionConfig().setReuseAddress( true );
> > > > > > > >>        cfg.getFilterChain().addLast( "codec1", new
> > > > > > ProtocolCodecFilter(
> > > > > > > >> new
> > > > > > > >> MyCodecFactory1( )));
> > > > > > > >>        cfg.getFilterChain().addLast( "codec2", new
> > > > > > ProtocolCodecFilter(
> > > > > > > >> new
> > > > > > > >> MyCodecFactory12( )));
> > > > > > > >>
> > > > > > > >> every filter works fine by itself, but if I use both, the
> > > server
> > > > > > > doesn't
> > > > > > > >> even go to the sessionCreated callback,
> > > > > > > >> and my socket client gets the following error sometimes:
> > > > > > > >>    socket.error: (10053, 'Software caused connection
> abort')
> > > > > > > >> or sometimes receives nothing and return.
> > > > > > > >>
> > > > > > > >> I am quite new to Mina, so any suggest may be helpful.
> > Thanks.
> > > > > > > >>
> > > > > > > >> Best,
> > > > > > > >> Chen
> > > > > > > >>
> > > > > > >
> > > > > >
> > > > >
> > > >
> > >
> >
>