Skip to content

Instantly share code, notes, and snippets.

@zeroFruit
Created July 23, 2022 00:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zeroFruit/1671b3ddea7e677cda8bfe2984326957 to your computer and use it in GitHub Desktop.
Save zeroFruit/1671b3ddea7e677cda8bfe2984326957 to your computer and use it in GitHub Desktop.
Channel concept & implementation— el Project (2)
public abstract class AbstractChannelHandlerContext implements ChannelHandlerContext {
AbstractChannelHandlerContext(
String name,
ChannelPipeline pipeline,
EventLoop eventLoop,
Class<? extends ChannelHandler> handlerClass) {
this.name = ObjectUtil.checkNotNull(name, "name");
this.pipeline = pipeline;
this.executionFlag = ChannelHandlerFlag.flag(handlerClass);
this.eventLoop = eventLoop;
}
...
}
final class ChannelHandlerFlag {
static final int FLAG_INBOUND = 0;
static final int FLAG_OUTBOUND = 1;
static final int FLAG_INOUTBOUND = 2;
static int flag(Class<? extends ChannelHandler> clazz) {
if (ChannelInboundHandler.class.isAssignableFrom(clazz)
&& ChannelOutboundHandler.class.isAssignableFrom(clazz)) {
return FLAG_INOUTBOUND;
}
if (ChannelInboundHandler.class.isAssignableFrom(clazz)) {
return FLAG_INBOUND;
}
return FLAG_OUTBOUND;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment