/** * Return the current {@link Channel} bound {@link ChannelOperations} or null if none * * @param ch the current {@link Channel} * * @return the current {@link Channel} bound {@link ChannelOperations} or null if none */ @Nullable @SuppressWarnings("unchecked") public static ChannelOperations<?, ?> get(Channel ch) { return Connection.from(ch) .as(ChannelOperations.class); }
/** * Return the current {@link Channel} bound {@link ChannelOperations} or null if none * * @param ch the current {@link Channel} * * @return the current {@link Channel} bound {@link ChannelOperations} or null if none */ @Nullable @SuppressWarnings("unchecked") public static ChannelOperations<?, ?> get(Channel ch) { return Connection.from(ch) .as(ChannelOperations.class); }
@Override final public void exceptionCaught(ChannelHandlerContext ctx, Throwable err) { Exceptions.throwIfJvmFatal(err); ChannelOperations<?, ?> ops = ChannelOperations.get(ctx.channel()); if (ops != null) { ops.onInboundError(err); } else { listener.onUncaughtException(Connection.from(ctx.channel()), err); } }
@Override final public void exceptionCaught(ChannelHandlerContext ctx, Throwable err) { Exceptions.throwIfJvmFatal(err); ChannelOperations<?, ?> ops = ChannelOperations.get(ctx.channel()); if (ops != null) { ops.onInboundError(err); } else { listener.onUncaughtException(Connection.from(ctx.channel()), err); } }
@Override public void channelActive(ChannelHandlerContext ctx) { ChannelOperations<?, ?> ops = Connection.from(ctx.channel()).as(ChannelOperations.class); if (ops != null) { ops.listener().onStateChange(ops, ConnectionObserver.State.CONFIGURED); } ctx.fireChannelActive(); }
@Override public void channelActive(ChannelHandlerContext ctx) { Connection c = Connection.from(ctx.channel()); listener.onStateChange(c, ConnectionObserver.State.CONNECTED); ChannelOperations<?, ?> ops = opsFactory.create(c, listener, null); if (ops != null) { ops.bind(); listener.onStateChange(ops, ConnectionObserver.State.CONFIGURED); } }
@Override public void channelActive(ChannelHandlerContext ctx) { ChannelOperations<?, ?> ops = Connection.from(ctx.channel()).as(ChannelOperations.class); if (ops != null) { ops.listener().onStateChange(ops, ConnectionObserver.State.CONFIGURED); } ctx.fireChannelActive(); }
@Override public void channelActive(ChannelHandlerContext ctx) { Connection c = Connection.from(ctx.channel()); listener.onStateChange(c, ConnectionObserver.State.CONNECTED); ChannelOperations<?, ?> ops = opsFactory.create(c, listener, null); if (ops != null) { ops.bind(); listener.onStateChange(ops, ConnectionObserver.State.CONFIGURED); } }
@Override public void run() { Object next; HttpRequest nextRequest = null; while ((next = pipelined.peek()) != null) { if (next instanceof HttpRequest) { if (nextRequest != null) { return; } if (!persistentConnection) { discard(); return; } nextRequest = (HttpRequest)next; HttpServerOperations ops = new HttpServerOperations(Connection.from(ctx.channel()), listener, compress, nextRequest, ConnectionInfo.from(ctx.channel(), readForwardHeaders, nextRequest), cookieEncoder, cookieDecoder) .chunkedTransfer(true); ops.bind(); listener.onStateChange(ops, ConnectionObserver.State.CONFIGURED); } ctx.fireChannelRead(pipelined.poll()); } overflow = false; }
@Override final public void channelInactive(ChannelHandlerContext ctx) { try { ChannelOperations<?, ?> ops = ChannelOperations.get(ctx.channel()); if (ops != null) { ops.onInboundClose(); } else { listener.onStateChange(Connection.from(ctx.channel()), ConnectionObserver.State.DISCONNECTING); } } catch (Throwable err) { Exceptions.throwIfFatal(err); exceptionCaught(ctx, err); } }
@Override final public void channelInactive(ChannelHandlerContext ctx) { try { ChannelOperations<?, ?> ops = ChannelOperations.get(ctx.channel()); if (ops != null) { ops.onInboundClose(); } else { listener.onStateChange(Connection.from(ctx.channel()), ConnectionObserver.State.DISCONNECTING); } } catch (Throwable err) { Exceptions.throwIfFatal(err); exceptionCaught(ctx, err); } }
@Override public void run() { Object next; HttpRequest nextRequest = null; while ((next = pipelined.peek()) != null) { if (next instanceof HttpRequest) { if (nextRequest != null) { return; } if (!persistentConnection) { discard(); return; } nextRequest = (HttpRequest)next; HttpServerOperations ops = new HttpServerOperations(Connection.from(ctx.channel()), listener, compress, nextRequest, ConnectionInfo.from(ctx.channel(), readForwardHeaders, nextRequest), cookieEncoder, cookieDecoder) .chunkedTransfer(true); ops.bind(); listener.onStateChange(ops, ConnectionObserver.State.CONFIGURED); } ctx.fireChannelRead(pipelined.poll()); } overflow = false; }
@Override public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception { if (msg instanceof Http2HeadersFrame) { Http2HeadersFrame headersFrame = (Http2HeadersFrame)msg; HttpRequest request; if (headersFrame.isEndStream()) { request = HttpConversionUtil.toFullHttpRequest(-1, headersFrame.headers(), ctx.channel().alloc(), false); } else { request = HttpConversionUtil.toHttpRequest(-1, headersFrame.headers(), false); } HttpToH2Operations ops = new HttpToH2Operations(Connection.from(ctx.channel()), listener, request, headersFrame.headers(), ConnectionInfo.from(ctx.channel() .parent(), readForwardHeaders, request), cookieEncoder, cookieDecoder); ops.bind(); listener.onStateChange(ops, ConnectionObserver.State.CONFIGURED); } ctx.fireChannelRead(msg); }
@Override public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception { if (msg instanceof Http2HeadersFrame) { Http2HeadersFrame headersFrame = (Http2HeadersFrame)msg; HttpRequest request; if (headersFrame.isEndStream()) { request = HttpConversionUtil.toFullHttpRequest(-1, headersFrame.headers(), ctx.channel().alloc(), false); } else { request = HttpConversionUtil.toHttpRequest(-1, headersFrame.headers(), false); } HttpToH2Operations ops = new HttpToH2Operations(Connection.from(ctx.channel()), listener, request, headersFrame.headers(), ConnectionInfo.from(ctx.channel() .parent(), readForwardHeaders, request), cookieEncoder, cookieDecoder); ops.bind(); listener.onStateChange(ops, ConnectionObserver.State.CONFIGURED); } ctx.fireChannelRead(msg); }
overflow = false; HttpServerOperations ops = new HttpServerOperations(Connection.from(ctx.channel()), listener, compress,
overflow = false; HttpServerOperations ops = new HttpServerOperations(Connection.from(ctx.channel()), listener, compress,