@Override public NextAction handleRead(FilterChainContext ctx) throws IOException { Connection<?> connection = ctx.getConnection(); GrizzlyChannel channel = GrizzlyChannel.getOrAddChannel(connection, url, handler); try { handler.received(channel, ctx.getMessage()); } catch (RemotingException e) { throw new IOException(StringUtils.toString(e)); } finally { GrizzlyChannel.removeChannelIfDisconnected(connection); } return ctx.getInvokeAction(); }
@Override public NextAction handleConnect(FilterChainContext ctx) throws IOException { Connection<?> connection = ctx.getConnection(); GrizzlyChannel channel = GrizzlyChannel.getOrAddChannel(connection, url, handler); try { handler.connected(channel); } catch (RemotingException e) { throw new IOException(StringUtils.toString(e)); } finally { GrizzlyChannel.removeChannelIfDisconnected(connection); } return ctx.getInvokeAction(); }
@Override public NextAction handleRead(FilterChainContext context) throws IOException { Object message = context.getMessage(); Connection<?> connection = context.getConnection(); Channel channel = GrizzlyChannel.getOrAddChannel(connection, url, handler); try { return context.getStopAction(); } else { if (savedReadIndex == frame.readerIndex()) { context.setMessage(msg); return context.getInvokeAction(); } else { return context.getInvokeAction(); return context.getInvokeAction();
@Override public NextAction handleRead(final FilterChainContext ctx) throws IOException { final Object message = ctx.getMessage(); // If the input message is not HttpContent or it's last HttpContent message - // pass the message to a next filter if (!(message instanceof HttpContent) || ((HttpContent) message).isLast()) { return ctx.getInvokeAction(); } // if it's HttpContent chunk (not last) - save it and stop filter chain processing. return ctx.getStopAction(message); } }
@Override public NextAction handleEvent(final FilterChainContext ctx, final FilterChainEvent event) throws IOException { if (event.type() == SSLSwitchingEvent.class) { final SSLSwitchingEvent se = (SSLSwitchingEvent) event; final boolean isSecure = se.isSecure(); CONNECTION_IS_SECURE.set(se.getConnection(), isSecure); // if enabling security - create SSLEngine here, because default // Grizzly SSLFilter will use host/port info from the Connection, rather // than request URL. Specifically this doesn't work with CONNECT tunnels. if (isSecure && SSLUtils.getSSLEngine(ctx.getConnection()) == null) { // if SSLEngine is not yet set for the connection - initialize it final SSLEngine sslEngine = getClientSSLEngineConfigurator() .createSSLEngine(se.getHost(), se.getPort() == -1 ? 443 : se.getPort() ); sslEngine.beginHandshake(); SSLUtils.setSSLEngine(ctx.getConnection(), sslEngine); } return ctx.getStopAction(); } return ctx.getInvokeAction(); }
@Override public NextAction handleWrite(final FilterChainContext ctx) throws IOException { final Object input = ctx.getMessage(); if (!(input instanceof List)) { return ctx.getInvokeAction(); } final List<String> inputStringList = ctx.getMessage(); final Buffer output = encode(ctx.getMemoryManager(), inputStringList); ctx.setMessage(output); return ctx.getInvokeAction(); }
@Override public NextAction handleEvent(final FilterChainContext ctx, final FilterChainEvent event) throws IOException { if (event.type() == GracefulCloseEvent.class) { // Connection was closed. // This event is fired only for responses, which don't have // associated transfer-encoding or content-length. // We have to complete such a request-response processing gracefully. final GracefulCloseEvent closeEvent = (GracefulCloseEvent) event; final HttpResponsePacket response = closeEvent.getHttpTxContext().responsePacket; response.getProcessingState().getHttpContext().attach(ctx); onHttpPacketParsed(response, ctx); return ctx.getStopAction(); } return ctx.getInvokeAction(); }
@Override public NextAction handleWrite(FilterChainContext ctx) throws IOException { Connection<?> connection = ctx.getConnection(); GrizzlyChannel channel = GrizzlyChannel.getOrAddChannel(connection, url, handler); try { handler.sent(channel, ctx.getMessage()); } catch (RemotingException e) { throw new IOException(StringUtils.toString(e)); } finally { GrizzlyChannel.removeChannelIfDisconnected(connection); } return ctx.getInvokeAction(); }
@Override public NextAction handleRead(FilterChainContext context) throws IOException { Object message = context.getMessage(); Connection<?> connection = context.getConnection(); Channel channel = GrizzlyChannel.getOrAddChannel(connection, url, handler); try { return context.getStopAction(); } else { if (savedReadIndex == frame.readerIndex()) { context.setMessage(msg); return context.getInvokeAction(); } else { return context.getInvokeAction(); return context.getInvokeAction();
@Override public NextAction handleRead(final FilterChainContext ctx) throws IOException { final Object message = ctx.getMessage(); // If the input message is not HttpContent or it's last HttpContent message - // pass the message to a next filter if (!(message instanceof HttpContent) || ((HttpContent) message).isLast()) { return ctx.getInvokeAction(); } // if it's HttpContent chunk (not last) - save it and stop filter chain processing. return ctx.getStopAction(message); } }
@Override public NextAction handleClose(FilterChainContext ctx) throws IOException { Connection<?> connection = ctx.getConnection(); GrizzlyChannel channel = GrizzlyChannel.getOrAddChannel(connection, url, handler); try { handler.disconnected(channel); } catch (RemotingException e) { throw new IOException(StringUtils.toString(e)); } finally { GrizzlyChannel.removeChannelIfDisconnected(connection); } return ctx.getInvokeAction(); }
@Override public NextAction handleEvent(FilterChainContext ctx, FilterChainEvent event) throws IOException { if (event.type() == SSLSwitchingEvent.class) { final SSLSwitchingEvent se = (SSLSwitchingEvent) event; CONNECTION_IS_SECURE.set(se.connection, se.secure); return ctx.getStopAction(); } return ctx.getInvokeAction(); }
@Override public NextAction handleWrite(FilterChainContext ctx) throws IOException { Connection<?> connection = ctx.getConnection(); GrizzlyChannel channel = GrizzlyChannel.getOrAddChannel(connection, url, handler); try { handler.sent(channel, ctx.getMessage()); } catch (RemotingException e) { throw new IOException(StringUtils.toString(e)); } finally { GrizzlyChannel.removeChannelIfDisconnected(connection); } return ctx.getInvokeAction(); }
@Override public NextAction handleWrite(FilterChainContext context) throws IOException { Connection<?> connection = context.getConnection(); GrizzlyChannel channel = GrizzlyChannel.getOrAddChannel(connection, url, handler); try { ChannelBuffer channelBuffer = ChannelBuffers.dynamicBuffer(1024); // Do not need to close Object msg = context.getMessage(); codec.encode(channel, channelBuffer, msg); GrizzlyChannel.removeChannelIfDisconnected(connection); Buffer buffer = connection.getTransport().getMemoryManager().allocate(channelBuffer.readableBytes()); buffer.put(channelBuffer.toByteBuffer()); buffer.flip(); buffer.allowBufferDispose(true); context.setMessage(buffer); } finally { GrizzlyChannel.removeChannelIfDisconnected(connection); } return context.getInvokeAction(); }
@Override public NextAction handleRead(final FilterChainContext ctx) throws IOException { final Object message = ctx.getMessage(); // If the input message is not HttpContent or it's last HttpContent message - // pass the message to a next filter if (!(message instanceof HttpContent) || ((HttpContent) message).isLast()) { return ctx.getInvokeAction(); } // if it's HttpContent chunk (not last) - save it and stop filter chain processing. return ctx.getStopAction(message); } }
@Override public NextAction handleConnect(FilterChainContext ctx) throws IOException { Connection<?> connection = ctx.getConnection(); GrizzlyChannel channel = GrizzlyChannel.getOrAddChannel(connection, url, handler); try { handler.connected(channel); } catch (RemotingException e) { throw new IOException(StringUtils.toString(e)); } finally { GrizzlyChannel.removeChannelIfDisconnected(connection); } return ctx.getInvokeAction(); }
@Override public NextAction handleRead(FilterChainContext ctx) throws IOException { Connection<?> connection = ctx.getConnection(); GrizzlyChannel channel = GrizzlyChannel.getOrAddChannel(connection, url, handler); try { handler.received(channel, ctx.getMessage()); } catch (RemotingException e) { throw new IOException(StringUtils.toString(e)); } finally { GrizzlyChannel.removeChannelIfDisconnected(connection); } return ctx.getInvokeAction(); }
@Override public NextAction handleWrite(FilterChainContext context) throws IOException { Connection<?> connection = context.getConnection(); GrizzlyChannel channel = GrizzlyChannel.getOrAddChannel(connection, url, handler); try { ChannelBuffer channelBuffer = ChannelBuffers.dynamicBuffer(1024); // Do not need to close Object msg = context.getMessage(); codec.encode(channel, channelBuffer, msg); GrizzlyChannel.removeChannelIfDisconnected(connection); Buffer buffer = connection.getTransport().getMemoryManager().allocate(channelBuffer.readableBytes()); buffer.put(channelBuffer.toByteBuffer()); buffer.flip(); buffer.allowBufferDispose(true); context.setMessage(buffer); } finally { GrizzlyChannel.removeChannelIfDisconnected(connection); } return context.getInvokeAction(); }
@Override public NextAction handleRead(final FilterChainContext ctx) throws IOException { final Object message = ctx.getMessage(); // If the input message is not HttpContent or it's last HttpContent message - // pass the message to a next filter if (!(message instanceof HttpContent) || ((HttpContent) message).isLast()) { return ctx.getInvokeAction(); } // if it's HttpContent chunk (not last) - save it and stop filter chain processing. return ctx.getStopAction(message); } }
@Override public NextAction handleClose(FilterChainContext ctx) throws IOException { Connection<?> connection = ctx.getConnection(); GrizzlyChannel channel = GrizzlyChannel.getOrAddChannel(connection, url, handler); try { handler.disconnected(channel); } catch (RemotingException e) { throw new IOException(StringUtils.toString(e)); } finally { GrizzlyChannel.removeChannelIfDisconnected(connection); } return ctx.getInvokeAction(); }