Search in sources :

Example 21 with ChannelHandler

use of io.netty.channel.ChannelHandler in project LogHub by fbacchella.

the class ClientFactory method addHandlers.

@Override
public void addHandlers(ChannelConsumer<Bootstrap, Channel, SA> source) {
    ChannelHandler handler = new ChannelInitializer<CC>() {

        @Override
        public void initChannel(CC ch) throws Exception {
            try {
                source.addHandlers(ch.pipeline());
            } catch (Exception e) {
                logger.error("Netty handler failed: {}", e.getMessage());
                logger.throwing(Level.DEBUG, e);
            }
        }
    };
    bootstrap.handler(handler);
}
Also used : ChannelHandler(io.netty.channel.ChannelHandler) ChannelInitializer(io.netty.channel.ChannelInitializer)

Example 22 with ChannelHandler

use of io.netty.channel.ChannelHandler in project reactor-netty by reactor.

the class NettyContextTest method addByteEncoderWhenFullReactorPipeline.

@Test
public void addByteEncoderWhenFullReactorPipeline() throws Exception {
    channel.pipeline().addLast(NettyPipeline.HttpCodec, new HttpServerCodec()).addLast(NettyPipeline.HttpServerHandler, new ChannelDuplexHandler()).addLast(NettyPipeline.ReactiveBridge, new ChannelHandlerAdapter() {
    });
    ChannelHandler encoder = new LineBasedFrameDecoder(12);
    testContext.addHandlerFirst("encoder", encoder);
    assertEquals(channel.pipeline().names(), Arrays.asList(NettyPipeline.HttpCodec, NettyPipeline.HttpServerHandler, "encoder", NettyPipeline.ReactiveBridge, "DefaultChannelPipeline$TailContext#0"));
}
Also used : ChannelHandlerAdapter(io.netty.channel.ChannelHandlerAdapter) ChannelDuplexHandler(io.netty.channel.ChannelDuplexHandler) HttpServerCodec(io.netty.handler.codec.http.HttpServerCodec) LineBasedFrameDecoder(io.netty.handler.codec.LineBasedFrameDecoder) ChannelHandler(io.netty.channel.ChannelHandler) Test(org.junit.Test)

Example 23 with ChannelHandler

use of io.netty.channel.ChannelHandler in project reactor-netty by reactor.

the class NettyContextTest method addNonByteEncoderWhenNoLeft.

@Test
public void addNonByteEncoderWhenNoLeft() throws Exception {
    channel.pipeline().addLast(NettyPipeline.ReactiveBridge, new ChannelHandlerAdapter() {
    });
    ChannelHandler encoder = new ChannelHandlerAdapter() {
    };
    testContext.addHandlerFirst("encoder", encoder);
    assertEquals(channel.pipeline().names(), Arrays.asList("encoder", NettyPipeline.ReactiveBridge, "DefaultChannelPipeline$TailContext#0"));
}
Also used : ChannelHandlerAdapter(io.netty.channel.ChannelHandlerAdapter) ChannelHandler(io.netty.channel.ChannelHandler) Test(org.junit.Test)

Example 24 with ChannelHandler

use of io.netty.channel.ChannelHandler in project reactor-netty by reactor.

the class NettyContextTest method addNonByteDecoderWhenNoLeft.

@Test
public void addNonByteDecoderWhenNoLeft() throws Exception {
    channel.pipeline().addLast(NettyPipeline.ReactiveBridge, new ChannelHandlerAdapter() {
    });
    ChannelHandler decoder = new ChannelHandlerAdapter() {
    };
    testContext.addHandlerLast("decoder", decoder);
    assertEquals(channel.pipeline().names(), Arrays.asList("decoder", NettyPipeline.ReactiveBridge, "DefaultChannelPipeline$TailContext#0"));
}
Also used : ChannelHandlerAdapter(io.netty.channel.ChannelHandlerAdapter) ChannelHandler(io.netty.channel.ChannelHandler) Test(org.junit.Test)

Example 25 with ChannelHandler

use of io.netty.channel.ChannelHandler in project reactor-netty by reactor.

the class NettyContextTest method addNonByteDecoderWhenEmptyPipeline.

@Test
public void addNonByteDecoderWhenEmptyPipeline() throws Exception {
    ChannelHandler decoder = new ChannelHandlerAdapter() {
    };
    testContext.addHandlerLast("decoder", decoder);
    assertEquals(channel.pipeline().names(), Arrays.asList("decoder", "DefaultChannelPipeline$TailContext#0"));
}
Also used : ChannelHandlerAdapter(io.netty.channel.ChannelHandlerAdapter) ChannelHandler(io.netty.channel.ChannelHandler) Test(org.junit.Test)

Aggregations

ChannelHandler (io.netty.channel.ChannelHandler)186 Test (org.junit.Test)88 ChannelHandlerContext (io.netty.channel.ChannelHandlerContext)44 Channel (io.netty.channel.Channel)26 ChannelPipeline (io.netty.channel.ChannelPipeline)25 SslHandler (io.netty.handler.ssl.SslHandler)25 EmbeddedChannel (io.netty.channel.embedded.EmbeddedChannel)22 FilterChainMatchingHandler (io.grpc.xds.FilterChainMatchingProtocolNegotiators.FilterChainMatchingHandler)20 ChannelFuture (io.netty.channel.ChannelFuture)20 ChannelInboundHandlerAdapter (io.netty.channel.ChannelInboundHandlerAdapter)20 FilterChainSelector (io.grpc.xds.FilterChainMatchingProtocolNegotiators.FilterChainMatchingHandler.FilterChainSelector)19 ChannelHandlerAdapter (io.netty.channel.ChannelHandlerAdapter)18 DownstreamTlsContext (io.grpc.xds.EnvoyServerProtoData.DownstreamTlsContext)17 FilterChain (io.grpc.xds.EnvoyServerProtoData.FilterChain)17 InetSocketAddress (java.net.InetSocketAddress)16 Test (org.junit.jupiter.api.Test)16 LineBasedFrameDecoder (io.netty.handler.codec.LineBasedFrameDecoder)12 AtomicReference (java.util.concurrent.atomic.AtomicReference)12 Bootstrap (io.netty.bootstrap.Bootstrap)11 ArrayList (java.util.ArrayList)11