@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(); }
/** * {@inheritDoc} */ @Override public NextAction handleRead(FilterChainContext ctx) throws IOException { // a response is received - pass it to the callback final String responseMessage = ctx.getMessage(); callback.onResponseReceived(ctx.getConnection(), responseMessage); return ctx.getStopAction(); } }
@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 handleRead(FilterChainContext ctx) throws IOException { final GIOPMessage message = ctx.getMessage(); resultFuture.result(message); return ctx.getStopAction(); } }
private FilterChainContext obtainChildFilterChainContext( final PUProtocol protocol, final Connection connection, final FilterChainContext ctx) { final FilterChain filterChain = protocol.getFilterChain(); final FilterChainContext filterChainContext = filterChain.obtainFilterChainContext(connection); final Context context = filterChainContext.getInternalContext(); context.setIoEvent(IOEvent.READ); context.addLifeCycleListener(new InternalProcessingHandler(ctx)); filterChainContext.setAddressHolder(ctx.getAddressHolder()); filterChainContext.setMessage(ctx.getMessage()); return filterChainContext; }
@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(); }
private static FilterChainContext obtainProtocolChainContext( final FilterChainContext ctx, final FilterChain completeProtocolFilterChain) { final FilterChainContext newFilterChainContext = completeProtocolFilterChain.obtainFilterChainContext( ctx.getConnection(), ctx.getStartIdx(), completeProtocolFilterChain.size(), ctx.getFilterIdx()); newFilterChainContext.setAddressHolder(ctx.getAddressHolder()); newFilterChainContext.setMessage(ctx.getMessage()); newFilterChainContext.getInternalContext().setIoEvent(IOEvent.READ); newFilterChainContext.getInternalContext().addLifeCycleListener( new InternalProcessingHandler(ctx)); return newFilterChainContext; }
@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 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(final FilterChainContext ctx) throws IOException { final Object message = ctx.getMessage(); final Connection connection = ctx.getConnection(); final Object address = ctx.getAddress(); if (logger.isLoggable(Level.FINEST)) { logger.log(Level.FINEST, "EchoFilter. connection={0} dstAddress={1} message={2}", new Object[]{connection, address, message}); } if (message instanceof Buffer) { ((Buffer) message).allowBufferDispose(true); } ctx.write(address, message, null); return ctx.getStopAction(); } }
@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 handleRead(FilterChainContext ctx) throws IOException { // Take ADD-service response final AddResponseMessage addResponseMessage = ctx.getMessage(); // do output LOGGER.log(Level.INFO, "Result={0}", addResponseMessage.getResult()); return ctx.getStopAction(); } }
private FilterChainContext obtainChildFilterChainContext( final PUProtocol protocol, final Connection connection, final FilterChainContext ctx) { final FilterChain filterChain = protocol.getFilterChain(); final FilterChainContext filterChainContext = filterChain.obtainFilterChainContext(connection); final Context context = filterChainContext.getInternalContext(); context.setIoEvent(IOEvent.READ); context.addLifeCycleListener(new InternalProcessingHandler(ctx)); filterChainContext.setAddressHolder(ctx.getAddressHolder()); filterChainContext.setMessage(ctx.getMessage()); return filterChainContext; }
@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(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 handleRead(final FilterChainContext ctx) throws IOException { final Object message = ctx.getMessage(); final Connection connection = ctx.getConnection(); final Object address = ctx.getAddress(); if (logger.isLoggable(Level.FINEST)) { logger.log(Level.FINEST, "EchoFilter. connection={0} dstAddress={1} message={2}", new Object[]{connection, address, message}); } if (message instanceof Buffer) { ((Buffer) message).allowBufferDispose(true); } ctx.write(address, message, null); return ctx.getStopAction(); } }
@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 handleRead(FilterChainContext ctx) throws IOException { // Take SUB-service response final SubResponseMessage subResponseMessage = ctx.getMessage(); // do output LOGGER.log(Level.INFO, "Result={0}", subResponseMessage.getResult()); return ctx.getStopAction(); } }
private FilterChainContext obtainChildFilterChainContext( final PUProtocol protocol, final Connection connection, final FilterChainContext ctx) { final FilterChain filterChain = protocol.getFilterChain(); final FilterChainContext filterChainContext = filterChain.obtainFilterChainContext(connection); final Context context = filterChainContext.getInternalContext(); context.setIoEvent(IOEvent.READ); context.addLifeCycleListener(new InternalProcessingHandler(ctx)); filterChainContext.setAddressHolder(ctx.getAddressHolder()); filterChainContext.setMessage(ctx.getMessage()); return filterChainContext; }