@Override public ChannelHandlerContext context(Class<? extends ChannelHandler> handlerType) { return delegate.context(handlerType); }
@Override public ChannelHandlerContext context(ChannelHandler handler) { return delegate.context(handler); }
@Override protected void removeDecoder(ChannelHandlerContext ctx) throws Exception { ChannelPipeline p = ctx.pipeline(); if (p.context(decoderName) != null) { p.remove(decoderName); } }
private void remove(ChannelHandlerContext ctx) { try { ChannelPipeline pipeline = ctx.pipeline(); if (pipeline.context(this) != null) { pipeline.remove(this); } } finally { initMap.remove(ctx); } } }
protected void removeInternalHandler(ChannelHandlerContext ctx) { // Remove timeout handler if not already removed. ChannelHandlerContext handlerContext = ctx.pipeline().context(INTERNAL_HANDLER_NAME); if (handlerContext != null && ! handlerContext.isRemoved()) { ctx.pipeline().remove(INTERNAL_HANDLER_NAME); } }
@SuppressWarnings("unchecked") private boolean initChannel(ChannelHandlerContext ctx) throws Exception { if (initMap.add(ctx)) { // Guard against re-entrance. try { initChannel((C) ctx.channel()); } catch (Throwable cause) { // Explicitly call exceptionCaught(...) as we removed the handler before calling initChannel(...). // We do so to prevent multiple calls to initChannel(...). exceptionCaught(ctx, cause); } finally { ChannelPipeline pipeline = ctx.pipeline(); if (pipeline.context(this) != null) { pipeline.remove(this); } } return true; } return false; }
private static Http2FrameCodec requireHttp2FrameCodec(ChannelHandlerContext ctx) { ChannelHandlerContext frameCodecCtx = ctx.pipeline().context(Http2FrameCodec.class); if (frameCodecCtx == null) { throw new IllegalArgumentException(Http2FrameCodec.class.getSimpleName() + " was not found in the channel pipeline."); } return (Http2FrameCodec) frameCodecCtx.handler(); } }
@Override public ChannelHandlerContext context( Class<? extends ChannelHandler> handlerType) { return pipeline.context(handlerType); }
@Override public ChannelHandlerContext context(ChannelHandler handler) { return pipeline.context(handler); }
@Override public ChannelHandlerContext context(String name) { return pipeline.context(name); }
public SSLSession sslSession() { if (isSSL()) { ChannelHandlerContext sslHandlerContext = chctx.pipeline().context("ssl"); assert sslHandlerContext != null; SslHandler sslHandler = (SslHandler) sslHandlerContext.handler(); return sslHandler.engine().getSession(); } else { return null; } }
@SuppressWarnings("unchecked") private boolean initChannel(ChannelHandlerContext ctx) throws Exception { if (initMap.add(ctx)) { // Guard against re-entrance. try { initChannel((C) ctx.channel()); } catch (Throwable cause) { // Explicitly call exceptionCaught(...) as we removed the handler before calling initChannel(...). // We do so to prevent multiple calls to initChannel(...). exceptionCaught(ctx, cause); } finally { ChannelPipeline pipeline = ctx.pipeline(); if (pipeline.context(this) != null) { pipeline.remove(this); } } return true; } return false; }
public X509Certificate[] peerCertificateChain() throws SSLPeerUnverifiedException { if (isSSL()) { ChannelHandlerContext sslHandlerContext = chctx.pipeline().context(SslHandler.class); assert sslHandlerContext != null; SslHandler sslHandler = (SslHandler) sslHandlerContext.handler(); return sslHandler.engine().getSession().getPeerCertificateChain(); } else { return null; } }
private String addAfter(ChannelPipeline p, String baseName, ChannelHandler handler) { p.addAfter(baseName, null, handler); return p.context(handler).name(); } }
protected void removeInternalHandler(ChannelHandlerContext ctx) { // Remove timeout handler if not already removed. ChannelHandlerContext handlerContext = ctx.pipeline().context(INTERNAL_HANDLER_NAME); if (handlerContext != null && ! handlerContext.isRemoved()) { ctx.pipeline().remove(INTERNAL_HANDLER_NAME); } }
private String addAfter(final ChannelPipeline p, final String baseName, final String name, final ChannelHandler h) { p.addAfter(baseName, name, h); return p.context(h).name(); } }
public void handle(HttpError httpError, ChannelHandlerContext ctx) { if (httpError.getResponseBytes() != null) { // write byte directly by skipping over HTTP codec ChannelHandlerContext httpCodecContext = ctx.pipeline().context(HttpServerCodec.class); if (httpCodecContext != null) { httpCodecContext.writeAndFlush(Unpooled.wrappedBuffer(httpError.getResponseBytes())).awaitUninterruptibly(); } } if (httpError.getDropConnection() != null && httpError.getDropConnection()) { ctx.close(); } }
@Override protected void channelRead0(ChannelHandlerContext ctx, HttpMessage msg) throws Exception { // If this handler is hit then no upgrade has been attempted and the client is just talking HTTP. // "Directly talking: " + msg.protocolVersion() + " (no upgrade was attempted)"); ChannelPipeline pipeline = ctx.pipeline(); ChannelHandlerContext thisCtx = pipeline.context(this); pipeline.addAfter(thisCtx.name(), null, new JerseyServerHandler(baseUri, container)); pipeline.replace(this, null, new ChunkedWriteHandler()); ctx.fireChannelRead(msg); } });
@Override protected void addCodec(ChannelHandlerContext ctx) throws Exception { ChannelPipeline p = ctx.pipeline(); String name = ctx.name(); Socks4ClientDecoder decoder = new Socks4ClientDecoder(); p.addBefore(name, null, decoder); decoderName = p.context(decoder).name(); encoderName = decoderName + ".encoder"; p.addBefore(name, encoderName, Socks4ClientEncoder.INSTANCE); }
@Override protected void addCodec(ChannelHandlerContext ctx) throws Exception { ChannelPipeline p = ctx.pipeline(); String name = ctx.name(); Socks5InitialResponseDecoder decoder = new Socks5InitialResponseDecoder(); p.addBefore(name, null, decoder); decoderName = p.context(decoder).name(); encoderName = decoderName + ".encoder"; p.addBefore(name, encoderName, Socks5ClientEncoder.DEFAULT); }