本文整理匯總了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();
}
}