I'm using Netty to develop a TCP server. I understand that the usual usage is to create a ServerBootstrap and pass an Initializer object to the childHandler() method. In the Initializer there is an initChannel method where we set up the pipeline with a bunch of addLast commands, adding things like DelimiterBasedFrameDecoder, StringEncoder, etc. This assumes that we know a priori that we will always get text/string messages.
However, I would like to implement a capability like what exists in python Twisted Protocols like LineReceiver where we can switch back and forth between raw mode and line mode. Yes one way to do that is to remove and add items from the pipeline dynamically. But I'm wondering if there is any good reason why I couldn't just use a minimal pipeline that uses a basic ChannelInitializer where the handler is just an extension of ChannelInboundHandlerAdapter. This way the channelRead method in the handler just processes the raw bytes (in ByteBuf). If I want to use line mode, isn't it possible for me to use DelimiterBasedFrameDecoder, StringEncoder, etc inside the channelRead method, i.e, call those directly and use them outside the context of the pipeline? Is there any good reason why I should NOT do this?