Hello,

I try to add encoder on the fly in a IoFiter contains in a connector and it appears it not works. The solution I found is to remove IoFilter and add a new one with all encoders. the replace method on filterChain appears to not woking neither.

Do you know if the on the fly update of IoFilter is a provided case of Mina serial transport?
Is replace method is equivalent to remove and add method?

Best Regards,
Francois.

public void replaceProtocolCodecFactory(IProtocolCodecFactory protocolCodecFactory) {
            //get next filter
            List<Entry> all = this.session.getFilterChain().getAll();
            boolean next = false;
            String nextName = null;
            for (Entry entry : all) {
                if (next){
                    nextName = entry.getName();
}else if (entry.getName().equals(protocolCodecFactory.getName())){
                        next = true;
                }
            }
            //remove old codec if exists
this.session.getFilterChain().remove(protocolCodecFactory.getName());
            //add codec at the right place
            if (nextName != null){
this.session.getFilterChain().addBefore(nextName, protocolCodecFactory.getName(), new ProtocolCodecFilter(protocolCodecFactory));
            }else{
this.session.getFilterChain().addLast(protocolCodecFactory.getName(), new ProtocolCodecFilter(protocolCodecFactory));
            }
    }

Mina 2.0.0-M5

Reply via email to