本文整理汇总了Java中io.netty.channel.ChannelHandlerAdapter类的典型用法代码示例。如果您正苦于以下问题:Java ChannelHandlerAdapter类的具体用法?Java ChannelHandlerAdapter怎么用?Java ChannelHandlerAdapter使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ChannelHandlerAdapter类属于io.netty.channel包,在下文中一共展示了ChannelHandlerAdapter类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: addByteDecoderWhenNoLeft
import io.netty.channel.ChannelHandlerAdapter; //导入依赖的package包/类
@Test
public void addByteDecoderWhenNoLeft() throws Exception {
channel.pipeline()
.addLast(NettyPipeline.ReactiveBridge, new ChannelHandlerAdapter() {
});
ChannelHandler decoder = new LineBasedFrameDecoder(12);
testContext.addHandlerLast("decoder", decoder)
.addHandlerFirst("decoder$extract",
NettyPipeline.inboundHandler(ADD_EXTRACTOR));
assertEquals(channel.pipeline()
.names(),
Arrays.asList("decoder$extract",
"decoder",
NettyPipeline.ReactiveBridge,
"DefaultChannelPipeline$TailContext#0"));
}
示例2: addByteDecoderWhenNoRight
import io.netty.channel.ChannelHandlerAdapter; //导入依赖的package包/类
@Test
public void addByteDecoderWhenNoRight() throws Exception {
channel.pipeline()
.addLast(NettyPipeline.HttpCodec, new ChannelHandlerAdapter() {
});
ChannelHandler decoder = new LineBasedFrameDecoder(12);
testContext.addHandlerLast("decoder", decoder)
.addHandlerFirst("decoder$extract",
NettyPipeline.inboundHandler(ADD_EXTRACTOR));
assertEquals(channel.pipeline()
.names(),
Arrays.asList(NettyPipeline.HttpCodec,
"decoder$extract",
"decoder",
"DefaultChannelPipeline$TailContext#0"));
}
示例3: addByteDecoderWhenFullReactorPipeline
import io.netty.channel.ChannelHandlerAdapter; //导入依赖的package包/类
@Test
public void addByteDecoderWhenFullReactorPipeline() throws Exception {
channel.pipeline()
.addLast(NettyPipeline.HttpCodec, new HttpServerCodec())
.addLast(NettyPipeline.HttpServerHandler, new ChannelDuplexHandler())
.addLast(NettyPipeline.ReactiveBridge, new ChannelHandlerAdapter() {
});
ChannelHandler decoder = new LineBasedFrameDecoder(12);
testContext.addHandlerLast("decoder", decoder)
.addHandlerFirst("decoder$extract",
NettyPipeline.inboundHandler(ADD_EXTRACTOR));
assertEquals(channel.pipeline()
.names(),
Arrays.asList(NettyPipeline.HttpCodec,
NettyPipeline.HttpServerHandler,
"decoder$extract",
"decoder",
NettyPipeline.ReactiveBridge,
"DefaultChannelPipeline$TailContext#0"));
}
示例4: addNonByteDecoderWhenNoLeft
import io.netty.channel.ChannelHandlerAdapter; //导入依赖的package包/类
@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"));
}
示例5: addNonByteDecoderWhenNoRight
import io.netty.channel.ChannelHandlerAdapter; //导入依赖的package包/类
@Test
public void addNonByteDecoderWhenNoRight() throws Exception {
channel.pipeline()
.addLast(NettyPipeline.HttpCodec, new ChannelHandlerAdapter() {
});
ChannelHandler decoder = new ChannelHandlerAdapter() {
};
testContext.addHandlerLast("decoder", decoder);
assertEquals(channel.pipeline()
.names(),
Arrays.asList(NettyPipeline.HttpCodec,
"decoder",
"DefaultChannelPipeline$TailContext#0"));
}
示例6: addNonByteDecoderWhenFullReactorPipeline
import io.netty.channel.ChannelHandlerAdapter; //导入依赖的package包/类
@Test
public void addNonByteDecoderWhenFullReactorPipeline() throws Exception {
channel.pipeline()
.addLast(NettyPipeline.HttpCodec, new HttpServerCodec())
.addLast(NettyPipeline.HttpServerHandler, new ChannelDuplexHandler())
.addLast(NettyPipeline.ReactiveBridge, new ChannelHandlerAdapter() {
});
ChannelHandler decoder = new ChannelHandlerAdapter() {
};
testContext.addHandlerLast("decoder", decoder);
assertEquals(channel.pipeline()
.names(),
Arrays.asList(NettyPipeline.HttpCodec,
NettyPipeline.HttpServerHandler,
"decoder",
NettyPipeline.ReactiveBridge,
"DefaultChannelPipeline$TailContext#0"));
}
示例7: addByteEncoderWhenNoLeft
import io.netty.channel.ChannelHandlerAdapter; //导入依赖的package包/类
@Test
public void addByteEncoderWhenNoLeft() throws Exception {
channel.pipeline()
.addLast(NettyPipeline.ReactiveBridge, new ChannelHandlerAdapter() {
});
ChannelHandler encoder = new LineBasedFrameDecoder(12);
testContext.addHandlerFirst("encoder", encoder);
assertEquals(channel.pipeline()
.names(),
Arrays.asList("encoder",
NettyPipeline.ReactiveBridge,
"DefaultChannelPipeline$TailContext#0"));
}
示例8: addByteEncoderWhenNoRight
import io.netty.channel.ChannelHandlerAdapter; //导入依赖的package包/类
@Test
public void addByteEncoderWhenNoRight() throws Exception {
channel.pipeline()
.addLast(NettyPipeline.HttpCodec, new ChannelHandlerAdapter() {
});
ChannelHandler encoder = new LineBasedFrameDecoder(12);
testContext.addHandlerFirst("encoder", encoder);
assertEquals(channel.pipeline()
.names(),
Arrays.asList(NettyPipeline.HttpCodec,
"encoder",
"DefaultChannelPipeline$TailContext#0"));
}
示例9: addByteEncoderWhenFullReactorPipeline
import io.netty.channel.ChannelHandlerAdapter; //导入依赖的package包/类
@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"));
}
示例10: addNonByteEncoderWhenNoLeft
import io.netty.channel.ChannelHandlerAdapter; //导入依赖的package包/类
@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"));
}
示例11: addNonByteEncoderWhenNoRight
import io.netty.channel.ChannelHandlerAdapter; //导入依赖的package包/类
@Test
public void addNonByteEncoderWhenNoRight() throws Exception {
channel.pipeline()
.addLast(NettyPipeline.HttpCodec, new ChannelHandlerAdapter() {
});
ChannelHandler encoder = new ChannelHandlerAdapter() {
};
testContext.addHandlerFirst("encoder", encoder);
assertEquals(channel.pipeline()
.names(),
Arrays.asList(NettyPipeline.HttpCodec,
"encoder",
"DefaultChannelPipeline$TailContext#0"));
}
示例12: addNonByteEncoderWhenFullReactorPipeline
import io.netty.channel.ChannelHandlerAdapter; //导入依赖的package包/类
@Test
public void addNonByteEncoderWhenFullReactorPipeline() throws Exception {
channel.pipeline()
.addLast(NettyPipeline.HttpCodec, new HttpServerCodec())
.addLast(NettyPipeline.HttpServerHandler, new ChannelDuplexHandler())
.addLast(NettyPipeline.ReactiveBridge, new ChannelHandlerAdapter() {
});
ChannelHandler encoder = new ChannelHandlerAdapter() {
};
testContext.addHandlerFirst("encoder", encoder);
assertEquals(channel.pipeline()
.names(),
Arrays.asList(NettyPipeline.HttpCodec,
NettyPipeline.HttpServerHandler,
"encoder",
NettyPipeline.ReactiveBridge,
"DefaultChannelPipeline$TailContext#0"));
}
示例13: addSeveralByteEncodersWhenCodec
import io.netty.channel.ChannelHandlerAdapter; //导入依赖的package包/类
@Test
public void addSeveralByteEncodersWhenCodec() throws Exception {
ChannelHandler encoder1 = new LineBasedFrameDecoder(12);
ChannelHandler encoder2 = new LineBasedFrameDecoder(13);
channel.pipeline()
.addLast(NettyPipeline.HttpCodec, new HttpServerCodec())
.addLast(NettyPipeline.HttpServerHandler, new ChannelDuplexHandler())
.addLast(NettyPipeline.ReactiveBridge, new ChannelHandlerAdapter() {
});
testContext.addHandlerFirst("encoder1", encoder1)
.addHandlerFirst("encoder2", encoder2);
assertEquals(channel.pipeline()
.names(),
Arrays.asList(NettyPipeline.HttpCodec,
NettyPipeline.HttpServerHandler,
"encoder2",
"encoder1",
NettyPipeline.ReactiveBridge,
"DefaultChannelPipeline$TailContext#0"));
}
示例14: testConstructorWithProvidedReplacement
import io.netty.channel.ChannelHandlerAdapter; //导入依赖的package包/类
@Test
public void testConstructorWithProvidedReplacement() {
EmbeddedChannel channel = new EmbeddedChannel();
channel.pipeline().addFirst(NettyPipeline.SslHandler, new ChannelHandlerAdapter() {
});
HttpClientOperations ops1 = new HttpClientOperations(channel,
(response, request) -> null, handler);
ops1.followRedirect();
ops1.failOnClientError(false);
ops1.failOnServerError(false);
HttpClientOperations ops2 = new HttpClientOperations(channel, ops1);
assertSame(ops1.channel(), ops2.channel());
assertSame(ops1.started, ops2.started);
assertSame(ops1.redirectedFrom, ops2.redirectedFrom);
assertSame(ops1.isSecure, ops2.isSecure);
assertSame(ops1.nettyRequest, ops2.nettyRequest);
assertSame(ops1.responseState, ops2.responseState);
assertSame(ops1.redirectable, ops2.redirectable);
assertSame(ops1.inboundPrefetch, ops2.inboundPrefetch);
assertSame(ops1.requestHeaders, ops2.requestHeaders);
assertSame(ops1.clientError, ops2.clientError);
assertSame(ops1.serverError, ops2.serverError);
}
示例15: run
import io.netty.channel.ChannelHandlerAdapter; //导入依赖的package包/类
public void run(String host, int port) throws InterruptedException {
NioEventLoopGroup group = new NioEventLoopGroup();
try {
Bootstrap bootstrap = new Bootstrap();
bootstrap.group(group)
.channel(NioSocketChannel.class)
.handler(new ChannelInitializer<SocketChannel>() {
@Override
protected void initChannel(SocketChannel ch) throws Exception {
ch.pipeline().addLast(new ChannelHandlerAdapter() {
@Override
public void channelActive(ChannelHandlerContext ctx) throws Exception {
System.out.println("connection active");
}
});
}
});
ChannelFuture future = bootstrap.connect(host, port).sync();
future.channel().closeFuture().sync();
} finally {
group.shutdownGracefully();
}
}