本文整理了Java中io.netty.channel.socket.SocketChannel.pipeline()
方法的一些代码示例,展示了SocketChannel.pipeline()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。SocketChannel.pipeline()
方法的具体详情如下:
包路径:io.netty.channel.socket.SocketChannel
类名称:SocketChannel
方法名:pipeline
暂无
代码示例来源:origin: apache/zookeeper
@Override
protected void initChannel(SocketChannel ch) throws Exception {
ChannelPipeline pipeline = ch.pipeline();
if (secure) {
initSSL(pipeline);
}
pipeline.addLast("servercnxnfactory", channelHandler);
}
});
代码示例来源:origin: spring-projects/spring-framework
@Override
protected void initChannel(SocketChannel channel) throws Exception {
configureChannel(channel.config());
ChannelPipeline pipeline = channel.pipeline();
if (isSecure) {
Assert.notNull(sslContext, "sslContext should not be null");
pipeline.addLast(sslContext.newHandler(channel.alloc(), uri.getHost(), uri.getPort()));
}
pipeline.addLast(new HttpClientCodec());
pipeline.addLast(new HttpObjectAggregator(maxResponseSize));
if (readTimeout > 0) {
pipeline.addLast(new ReadTimeoutHandler(readTimeout,
TimeUnit.MILLISECONDS));
}
}
});
代码示例来源:origin: jersey/jersey
@Override
protected void initChannel(SocketChannel ch) throws Exception {
ChannelPipeline p = ch.pipeline();
// Enable HTTPS if necessary.
if ("https".equals(requestUri.getScheme())) {
// making client authentication optional for now; it could be extracted to configurable property
JdkSslContext jdkSslContext = new JdkSslContext(client.getSslContext(), true, ClientAuth.NONE);
p.addLast(jdkSslContext.newHandler(ch.alloc()));
}
// http proxy
Configuration config = jerseyRequest.getConfiguration();
final Object proxyUri = config.getProperties().get(ClientProperties.PROXY_URI);
if (proxyUri != null) {
final URI u = getProxyUri(proxyUri);
final String userName = ClientProperties.getValue(
config.getProperties(), ClientProperties.PROXY_USERNAME, String.class);
final String password = ClientProperties.getValue(
config.getProperties(), ClientProperties.PROXY_PASSWORD, String.class);
p.addLast(new HttpProxyHandler(new InetSocketAddress(u.getHost(),
u.getPort() == -1 ? 8080 : u.getPort()),
userName, password));
}
p.addLast(new HttpClientCodec());
p.addLast(new ChunkedWriteHandler());
p.addLast(new HttpContentDecompressor());
p.addLast(new JerseyClientHandler(NettyConnector.this, jerseyRequest, jerseyCallback, settableFuture));
}
});
代码示例来源:origin: line/armeria
@Override
public void initChannel(SocketChannel ch) throws Exception {
final ChannelPipeline p = ch.pipeline();
final Http2Connection conn = new DefaultHttp2Connection(false);
final HttpToHttp2ConnectionHandler connHandler = new HttpToHttp2ConnectionHandlerBuilder()
.connection(conn)
.frameListener(new DelegatingDecompressorFrameListener(
conn,
new InboundHttp2ToHttpAdapterBuilder(conn)
.maxContentLength(Integer.MAX_VALUE)
.propagateSettings(true).build()))
.build();
clientHandler = new THttp2ClientHandler(ch.eventLoop());
if (sslCtx != null) {
p.addLast(sslCtx.newHandler(p.channel().alloc()));
p.addLast(connHandler);
configureEndOfPipeline(p);
} else {
final Http1ClientCodec sourceCodec = new Http1ClientCodec();
final HttpClientUpgradeHandler upgradeHandler = new HttpClientUpgradeHandler(
sourceCodec, new Http2ClientUpgradeCodec(connHandler), 65536);
p.addLast(sourceCodec, upgradeHandler, new UpgradeRequestHandler());
}
}
代码示例来源:origin: jersey/jersey
/**
* Configure the pipeline for TLS NPN negotiation to HTTP/2.
*/
private void configureSsl(SocketChannel ch) {
ch.pipeline().addLast(sslCtx.newHandler(ch.alloc()), new HttpVersionChooser(baseUri, container));
}
代码示例来源:origin: weibocom/motan
@Override
public void initChannel(SocketChannel ch) throws Exception {
ch.pipeline().addLast("http-decoder", new HttpRequestDecoder());
ch.pipeline().addLast("http-aggregator", new HttpObjectAggregator(maxContentLength));
ch.pipeline().addLast("http-encoder", new HttpResponseEncoder());
ch.pipeline().addLast("http-chunked", new ChunkedWriteHandler());
ch.pipeline().addLast("serverHandler", handler);
}
}).option(ChannelOption.SO_BACKLOG, 1024).childOption(ChannelOption.SO_KEEPALIVE, false);
代码示例来源:origin: atomix/atomix
@Override
protected void initChannel(SocketChannel channel) throws Exception {
channel.pipeline().addLast("ssl", sslContext.newHandler(channel.alloc()))
.addLast("handshake", new ServerHandshakeHandlerAdapter());
}
}
代码示例来源:origin: mpusher/mpush
@Override
public void initChannel(SocketChannel ch) throws Exception {
ch.pipeline().addLast("decoder", new PacketDecoder());
ch.pipeline().addLast("encoder", PacketEncoder.INSTANCE);
ch.pipeline().addLast("handler", new ConnClientChannelHandler());
}
});
代码示例来源:origin: ballerina-platform/ballerina-lang
@Override
protected void initChannel(SocketChannel ch) {
ChannelPipeline p = ch.pipeline();
if (sslCtx != null) {
p.addLast(sslCtx.newHandler(ch.alloc(), host, port));
}
p.addLast(
new HttpClientCodec(),
new HttpObjectAggregator(8192),
WebSocketClientCompressionHandler.INSTANCE,
handler
);
}
});
代码示例来源:origin: mpusher/mpush
@Override
public void initChannel(SocketChannel ch) throws Exception {
ch.pipeline().addLast("decoder", new HttpResponseDecoder());
ch.pipeline().addLast("aggregator", new HttpObjectAggregator(maxContentLength));
ch.pipeline().addLast("encoder", new HttpRequestEncoder());
ch.pipeline().addLast("handler", new HttpClientHandler(NettyHttpClient.this));
}
});
代码示例来源:origin: org.springframework/spring-web
@Override
protected void initChannel(SocketChannel channel) throws Exception {
configureChannel(channel.config());
ChannelPipeline pipeline = channel.pipeline();
if (isSecure) {
Assert.notNull(sslContext, "sslContext should not be null");
pipeline.addLast(sslContext.newHandler(channel.alloc(), uri.getHost(), uri.getPort()));
}
pipeline.addLast(new HttpClientCodec());
pipeline.addLast(new HttpObjectAggregator(maxResponseSize));
if (readTimeout > 0) {
pipeline.addLast(new ReadTimeoutHandler(readTimeout,
TimeUnit.MILLISECONDS));
}
}
});
代码示例来源:origin: ffay/lanproxy
@Override
public void initChannel(SocketChannel ch) throws Exception {
ch.pipeline().addLast(new RealServerChannelHandler());
}
});
代码示例来源:origin: alipay/sofa-rpc
/**
* Configure the pipeline for TLS NPN negotiation to HTTP/2.
*/
private void configureSsl(SocketChannel ch) {
SslContext sslCtx = SslContextBuilder.build();
ChannelPipeline pipeline = ch.pipeline();
pipeline.addLast(sslCtx.newHandler(ch.alloc()));
// We must wait for the handshake to finish and the protocol to be negotiated before configuring
// the HTTP/2 components of the pipeline.
pipeline.addLast(new ApplicationProtocolNegotiationHandler("") {
@Override
protected void configurePipeline(ChannelHandlerContext ctx, String protocol) {
if (ApplicationProtocolNames.HTTP_2.equals(protocol)) {
ChannelPipeline p = ctx.pipeline();
p.addLast(connectionHandler);
configureEndOfPipeline(p);
return;
}
ctx.close();
throw new IllegalStateException("unknown protocol: " + protocol);
}
});
}
代码示例来源:origin: ffay/lanproxy
@Override
public void initChannel(SocketChannel ch) throws Exception {
ch.pipeline().addLast(new ProxyMessageDecoder(MAX_FRAME_LENGTH, LENGTH_FIELD_OFFSET, LENGTH_FIELD_LENGTH, LENGTH_ADJUSTMENT, INITIAL_BYTES_TO_STRIP));
ch.pipeline().addLast(new ProxyMessageEncoder());
ch.pipeline().addLast(new IdleCheckHandler(IdleCheckHandler.READ_IDLE_TIME, IdleCheckHandler.WRITE_IDLE_TIME, 0));
ch.pipeline().addLast(new ServerChannelHandler());
}
});
代码示例来源:origin: alipay/sofa-rpc
/**
* Configure the pipeline for TLS NPN negotiation to HTTP/2.
*/
private void configureSsl(SocketChannel ch) {
SslContext sslCtx = SslContextBuilder.build();
ChannelPipeline pipeline = ch.pipeline();
pipeline.addLast(sslCtx.newHandler(ch.alloc()));
// We must wait for the handshake to finish and the protocol to be negotiated before configuring
// the HTTP/2 components of the pipeline.
pipeline.addLast(new ApplicationProtocolNegotiationHandler("") {
@Override
protected void configurePipeline(ChannelHandlerContext ctx, String protocol) {
if (ApplicationProtocolNames.HTTP_2.equals(protocol)) {
ChannelPipeline p = ctx.pipeline();
p.addLast(connectionHandler);
configureEndOfPipeline(p);
return;
}
ctx.close();
throw new IllegalStateException("unknown protocol: " + protocol);
}
});
}
代码示例来源:origin: testcontainers/testcontainers-java
@Override
protected void initChannel(final SocketChannel channel) throws Exception {
channel.pipeline().addLast(new HttpClientCodec());
channel.pipeline().addLast(new HttpContentDecompressor());
}
});
代码示例来源:origin: relayrides/pushy
@Override
protected void initChannel(final SocketChannel channel) {
final SslHandler sslHandler = sslContext.newHandler(channel.alloc());
channel.pipeline().addLast(sslHandler);
channel.pipeline().addLast(ConnectionNegotiationErrorHandler.INSTANCE);
sslHandler.handshakeFuture().addListener(new GenericFutureListener<Future<Channel>>() {
@Override
public void operationComplete(final Future<Channel> handshakeFuture) throws Exception {
if (handshakeFuture.isSuccess()) {
BaseHttp2Server.this.addHandlersToPipeline(sslHandler.engine().getSession(), channel.pipeline());
channel.pipeline().remove(ConnectionNegotiationErrorHandler.INSTANCE);
BaseHttp2Server.this.allChannels.add(channel);
} else {
log.debug("TLS handshake failed.", handshakeFuture.cause());
}
}
});
}
});
代码示例来源:origin: apache/incubator-shardingsphere
@Override
protected void initChannel(final SocketChannel socketChannel) {
ChannelPipeline pipeline = socketChannel.pipeline();
// TODO load database type from yaml or startup arguments
pipeline.addLast(PacketCodecFactory.newInstance(DatabaseType.MySQL));
pipeline.addLast(FrontendHandlerFactory.createFrontendHandlerInstance(DatabaseType.MySQL));
}
}
代码示例来源:origin: atomix/atomix
@Override
protected void initChannel(SocketChannel channel) throws Exception {
channel.pipeline().addLast("ssl", sslContext.newHandler(channel.alloc(), address.host(), address.port()))
.addLast("handshake", new ClientHandshakeHandlerAdapter(future));
}
}
代码示例来源:origin: apache/incubator-shardingsphere
@Override
protected void initChannel(final SocketChannel socketChannel) {
ChannelPipeline pipeline = socketChannel.pipeline();
// TODO load database type from yaml or startup arguments
pipeline.addLast(PacketCodecFactory.newInstance(DatabaseType.PostgreSQL));
pipeline.addLast(FrontendHandlerFactory.createFrontendHandlerInstance(DatabaseType.PostgreSQL));
}
}
内容来源于网络,如有侵权,请联系作者删除!