本文整理汇总了Java中io.netty.channel.socket.SocketChannel.pipeline方法的典型用法代码示例。如果您正苦于以下问题:Java SocketChannel.pipeline方法的具体用法?Java SocketChannel.pipeline怎么用?Java SocketChannel.pipeline使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类io.netty.channel.socket.SocketChannel
的用法示例。
在下文中一共展示了SocketChannel.pipeline方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: initChannel
import io.netty.channel.socket.SocketChannel; //导入方法依赖的package包/类
@Override
protected void initChannel(SocketChannel socketChannel) throws Exception {
Backend backend = this.backendManager.getBackendBalancing().getBackend();
if (backend == null) {
throw new OutOfBackendsException();
}
/*SelfSignedCertificate ssc = new SelfSignedCertificate();
SslContext sslCtx = SslContextBuilder.forServer(ssc.certificate(), ssc.privateKey())
.build();*/
ChannelPipeline pipeline = socketChannel.pipeline();
//pipeline.addLast(sslCtx.newHandler(socketChannel.alloc()));
//pipeline.addLast(new LoggingHandler(LogLevel.INFO));
pipeline.addLast(new CardeaServerFrontEndHandler(backend.getHost(), backend.getPort()));
}
示例2: initChannel
import io.netty.channel.socket.SocketChannel; //导入方法依赖的package包/类
@Override
public void initChannel(SocketChannel ch) {
ChannelPipeline pipeline = ch.pipeline();
SslHandler sslHandler = null;
if (sslHandlerProvider != null) {
sslHandler = sslHandlerProvider.getSslHandler();
pipeline.addLast(sslHandler);
}
pipeline.addLast("decoder", new MqttDecoder(MAX_PAYLOAD_SIZE));
pipeline.addLast("encoder", MqttEncoder.INSTANCE);
MqttTransportHandler handler = new MqttTransportHandler(msgProducer, deviceService, authService, assetService,
assetAuthService, relationService, sslHandler);
pipeline.addLast(handler);
// ch.closeFuture().addListener(handler);
}
示例3: initChannel
import io.netty.channel.socket.SocketChannel; //导入方法依赖的package包/类
@Override
protected void initChannel(SocketChannel ch) throws Exception {
final ChannelPipeline pipeline = ch.pipeline();
NettyPipelineInit.serializePipeline(serializeProtocolEnum, pipeline);
pipeline.addLast("timeout",
new IdleStateHandler(nettyConfig.getHeartTime(), nettyConfig.getHeartTime(), nettyConfig.getHeartTime(), TimeUnit.SECONDS));
pipeline.addLast(nettyServerMessageHandler);
}
示例4: initChannel
import io.netty.channel.socket.SocketChannel; //导入方法依赖的package包/类
@Override
protected void initChannel(SocketChannel ch) throws Exception {
ChannelPipeline p = ch.pipeline();
p.addLast("codec", new HttpServerCodec(4096, 8192, 8192, false));
p.addLast("servletInput", new ServletContentHandler(servletContext));
p.addLast(servletExecutor, "filterChain", requestDispatcherHandler);
}
示例5: initChannel
import io.netty.channel.socket.SocketChannel; //导入方法依赖的package包/类
@Override
public void initChannel(SocketChannel socketChannel) throws Exception {
ChannelPipeline p = socketChannel.pipeline();
p.addLast(new SocksInitRequestDecoder());
p.addLast(socksMessageEncoder);
p.addLast(socksServerHandler);
p.addLast(trafficHandler);
}
示例6: initChannel
import io.netty.channel.socket.SocketChannel; //导入方法依赖的package包/类
@Override
protected void initChannel(SocketChannel ch) throws Exception
{
ChannelPipeline pipeline = ch.pipeline();
pipeline.addLast(new DelimiterBasedFrameDecoder(8192, Delimiters.lineDelimiter()));
pipeline.addLast(new MessageDecoder());
pipeline.addLast(new MessageEncoder());
pipeline.addLast(new ClientHandler());
}
示例7: prepare
import io.netty.channel.socket.SocketChannel; //导入方法依赖的package包/类
@Override public void prepare(final Benchmark benchmark) {
this.concurrencyLevel = benchmark.concurrencyLevel;
this.targetBacklog = benchmark.targetBacklog;
ChannelInitializer<SocketChannel> channelInitializer = new ChannelInitializer<SocketChannel>() {
@Override public void initChannel(SocketChannel channel) throws Exception {
ChannelPipeline pipeline = channel.pipeline();
if (benchmark.tls) {
SslClient sslClient = SslClient.localhost();
SSLEngine engine = sslClient.sslContext.createSSLEngine();
engine.setUseClientMode(true);
pipeline.addLast("ssl", new SslHandler(engine));
}
pipeline.addLast("codec", new HttpClientCodec());
pipeline.addLast("inflater", new HttpContentDecompressor());
pipeline.addLast("handler", new HttpChannel(channel));
}
};
bootstrap = new Bootstrap();
bootstrap.group(new NioEventLoopGroup(concurrencyLevel))
.option(ChannelOption.ALLOCATOR, PooledByteBufAllocator.DEFAULT)
.channel(NioSocketChannel.class)
.handler(channelInitializer);
}
示例8: initChannel
import io.netty.channel.socket.SocketChannel; //导入方法依赖的package包/类
@Override
protected void initChannel(SocketChannel ch) throws Exception {
ChannelPipeline pipeline = ch.pipeline();
// SSL的安全链接
if (ServerConfig.isSsl()) {
SSLContext sslcontext = SSLContext.getInstance("TLS");
KeyManagerFactory kmf = KeyManagerFactory.getInstance("SunX509");
KeyStore ks = KeyStore.getInstance("JKS");
String keyStorePath = ServerConfig.getKeyStorePath();
String keyStorePassword = ServerConfig.getKeyStorePassword();
ks.load(new FileInputStream(keyStorePath), keyStorePassword.toCharArray());
String keyPassword = ServerConfig.getKeyPassword();
kmf.init(ks, keyPassword.toCharArray());
sslcontext.init(kmf.getKeyManagers(), null, null);
SSLEngine sslEngine = sslcontext.createSSLEngine();
sslEngine.setUseClientMode(false);
sslEngine.setNeedClientAuth(false);
/**
* 务必放在第一位
*/
pipeline.addLast(new SslHandler(sslEngine));
logger.info("initChannel: addLast SslHandler");
/**
* Generates a temporary self-signed certificate for testing purposes.
*/
/*SelfSignedCertificate ssc = new SelfSignedCertificate();
SslContext sslCtx = SslContextBuilder.forServer(ssc.certificate(), ssc.privateKey()).build();
//SslContext sslCtx = SslContext.newServerContext(ssc.certificate(), ssc.privateKey());
if (sslCtx != null) {
pipeline.addLast(sslCtx.newHandler(ch.alloc()));
}*/
}
// Register HTTP handler chain.
this.appendHttpPipeline(pipeline);
}
示例9: initChannel
import io.netty.channel.socket.SocketChannel; //导入方法依赖的package包/类
@Override
protected void initChannel(SocketChannel socketChannel) throws Exception {
ChannelPipeline cp = socketChannel.pipeline();
cp.addLast(new HttpServerCodec()); //添加服务端http编、解码器
cp.addLast(new HttpObjectAggregator(512*1024)); //http消息聚合
cp.addLast(new HttpContentCompressor()); //开启压缩
cp.addLast(new HttpServerHandler(kurdran));
}
示例10: initChannel
import io.netty.channel.socket.SocketChannel; //导入方法依赖的package包/类
@Override
public void initChannel(SocketChannel ch) {
ChannelPipeline pipeline = ch.pipeline();
if (sslCtx != null) {
pipeline.addLast(sslCtx.newHandler(ch.alloc(), ip, port));
}
pipeline.addLast(DECODER);
pipeline.addLast(ENCODER);
// and then business logic.
pipeline.addLast(CLIENT_HANDLER);
}
示例11: initChannel
import io.netty.channel.socket.SocketChannel; //导入方法依赖的package包/类
@Override
protected void initChannel(SocketChannel ch) throws Exception {
ChannelPipeline p = ch.pipeline();
if(sslCtx!=null)
{
p.addLast(new SslHandler(sslCtx.newEngine(ch.alloc())));
}
p.addLast(new HttpResponseDecoder());
//限制contentLength
p.addLast(new HttpObjectAggregator(65536));
p.addLast(new HttpRequestEncoder());
//大文件传输处理
// p.addLast(new ChunkedWriteHandler());
p.addLast(new DefaultListenerHandler<HttpResponse>(listener));
}
示例12: initChannel
import io.netty.channel.socket.SocketChannel; //导入方法依赖的package包/类
@Override
public void initChannel(SocketChannel ch) {
ChannelPipeline p = ch.pipeline();
if (sslCtx != null) {
p.addLast(sslCtx.newHandler(ch.alloc()));
}
p.addLast(new HttpServerCodec());
p.addLast(new HttpObjectAggregator(1048576));
p.addLast(new FeatureServerHandler(provider));
}
示例13: initChannel
import io.netty.channel.socket.SocketChannel; //导入方法依赖的package包/类
@Override
public void initChannel(SocketChannel ch) {
ChannelPipeline pipeline = ch.pipeline();
if (sslContext != null) {
pipeline.addLast("ssl", sslContext.newHandler(ch.alloc()));
}
pipeline.addLast(new HttpServerCodec())
.addLast(new HttpObjectAggregator(65536))
.addLast(new ChunkedWriteHandler())
.addLast(new NettyHttpServerHandler());
}
示例14: initChannel
import io.netty.channel.socket.SocketChannel; //导入方法依赖的package包/类
@Override
public void initChannel(SocketChannel aChannel) throws Exception {
ChannelPipeline pipeline = aChannel.pipeline();
pipeline.addLast("encoder" , new HttpResponseEncoder());
pipeline.addLast("decoder" , new HttpRequestDecoder(4096, 8192, 8192, false));
pipeline.addLast("aggregator" , new HttpObjectAggregator(MAX_CONTENT_LENGTH)); // handle HttpContents
pipeline.addLast("chunked", new ChunkedWriteHandler());
// pipeline.addLast("handler" , new HttpServerHandler(requestListener));
pipeline.addLast("handler" , new HttpServerHandler(requestListener));
}
示例15: initChannel
import io.netty.channel.socket.SocketChannel; //导入方法依赖的package包/类
@Override
public void initChannel(SocketChannel ch) {
ChannelPipeline pipeline = ch.pipeline();
//pipeline.addLast("http-compressor", new HttpContentCompressor());
pipeline.addLast("http-codec", new HttpServerCodec());
pipeline.addLast("http-aggregator", new HttpObjectAggregator(65536));
pipeline.addLast("http-chunked", new ChunkedWriteHandler());
pipeline.addLast("http-handler", new HttpRedirectHandler());
}