當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。