当前位置: 首页>>代码示例>>Java>>正文


Java SocketChannel.pipeline方法代码示例

本文整理汇总了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()));
  }
 
开发者ID:D3adspaceEnterprises,项目名称:cardea,代码行数:18,代码来源:CardeaServerChannelInitializer.java

示例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);

  }
 
开发者ID:osswangxining,项目名称:iothub,代码行数:19,代码来源:MqttTransportServerInitializer.java

示例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);
}
 
开发者ID:yu199195,项目名称:happylifeplat-transaction,代码行数:9,代码来源:NettyServerHandlerInitializer.java

示例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);
}
 
开发者ID:geeker-lait,项目名称:tasfe-framework,代码行数:8,代码来源:NettyEmbeddedServletInitializer.java

示例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);
}
 
开发者ID:breakEval13,项目名称:NSS,代码行数:9,代码来源:SocksServerInitializer.java

示例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());
}
 
开发者ID:andykuo1,项目名称:candlelight,代码行数:12,代码来源:ClientChannelInitializer.java

示例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);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:28,代码来源:NettyHttpClient.java

示例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);
 }
 
开发者ID:geeker-lait,项目名称:tasfe-framework,代码行数:37,代码来源:HttpChannelInitializer.java

示例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));
}
 
开发者ID:togethwy,项目名称:kurdran,代码行数:9,代码来源:NettyHandlerInitializer.java

示例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);

}
 
开发者ID:polarcoral,项目名称:monica,代码行数:15,代码来源:FileClientInitializer.java

示例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));
	}
 
开发者ID:juebanlin,项目名称:util4j,代码行数:16,代码来源:HttpClientInitHandler.java

示例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));
}
 
开发者ID:intuit,项目名称:karate,代码行数:11,代码来源:FeatureServerInitializer.java

示例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());
}
 
开发者ID:xipki,项目名称:xitk,代码行数:12,代码来源:HttpServer.java

示例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));

}
 
开发者ID:evsinev,项目名称:docker-network-veth,代码行数:13,代码来源:HttpServerInitializer.java

示例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());
}
 
开发者ID:noti0na1,项目名称:HFSN,代码行数:10,代码来源:HttpRedirectInitializer.java


注:本文中的io.netty.channel.socket.SocketChannel.pipeline方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。