Netty codecs have "protected" method preventing easy reuse outside pipeline

Abraham Menacherry abrahammenacherry at gmail.com
Thu May 19 02:39:07 EDT 2011


Hi Trustin,

I would like to use the decoders/encoders outside the channel/pipeline
context. 
I wanted to add 3 strings to a channelbuffer with each string preceded by a
2 byte length and only then write it to my pipeline which has further
codecs.

So i tried using 

StringEncoder encoder = new StringEncoder()
encoder.encode(null,null,"MyString");
But since it is a protected method, this operation fails. 
    @Override
    protected Object encode(
            ChannelHandlerContext ctx, Channel channel, Object msg) throws
Exception {
        if (!(msg instanceof String)) {
            return msg;
        }
        return copiedBuffer((String) msg, charset);
    }

Now I need to inherit it in a wrapper class of my own to use it. Can these
methods be made public and/or add a new public method added to these codecs
which will not require the ctx and channel, they just do the decode/encode
and give back result.

Thanks and Regards,
Abraham Menacherry

--
View this message in context: http://netty-forums-and-mailing-lists.685743.n2.nabble.com/Netty-codecs-have-protected-method-preventing-easy-reuse-outside-pipeline-tp6380824p6380824.html
Sent from the Netty User Group mailing list archive at Nabble.com.


More information about the netty-users mailing list