Finding a ChannelInitizlizer's place in the world

18 views
Skip to first unread message

Rogan Dawes

unread,
Mar 22, 2018, 2:16:47 AM3/22/18
to Netty discussions
Hi,

When writing my ChannelInitializers, I try not to assume that I am the only ChannelInitializer in the pipeline. In other words, using constructs like ch.pipeline().addFirst() and addLast() may be detrimental, if there are other handlers already added to the pipeline.

My approach is currently to do:

@Override
protected void initChannel(SocketChannel ch) throws Exception {
ChannelPipeline p = ch.pipeline();
String me = p.context(this).name();
p.addAfter(me, null, handler);
                }

is there a better way to find precisely where this ChannelInitializer is in the pipeline, and add its handlers strictly after itself, but before any other handlers that may already be in the pipeline?

Thanks

Rogan

Norman Maurer

unread,
Mar 22, 2018, 2:52:04 AM3/22/18
to ne...@googlegroups.com
This is the only way.

Bye
Norman


--
You received this message because you are subscribed to the Google Groups "Netty discussions" group.
To unsubscribe from this group and stop receiving emails from it, send an email to netty+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/netty/565de195-007c-4b92-b077-2dad2fff8b5d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages