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

Christian Migowski chrismfwrd at gmail.com
Thu May 19 02:52:25 EDT 2011


Hello,

why don't you implement your logic (en/decode) into a public method
(with the signature as you like it) and call this method in the
"official" encode/decode methods? Seems much more reasonable to me
than requesting an API change for your usecase.

regards,
christian


On Thu, May 19, 2011 at 8:39 AM, Abraham Menacherry
<abrahammenacherry at gmail.com> wrote:
> 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.
> _______________________________________________
> netty-users mailing list
> netty-users at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/netty-users
>



More information about the netty-users mailing list