當前位置: 首頁>>代碼示例>>Java>>正文


Java ChannelPipeline.addFirst方法代碼示例

本文整理匯總了Java中org.jboss.netty.channel.ChannelPipeline.addFirst方法的典型用法代碼示例。如果您正苦於以下問題:Java ChannelPipeline.addFirst方法的具體用法?Java ChannelPipeline.addFirst怎麽用?Java ChannelPipeline.addFirst使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.jboss.netty.channel.ChannelPipeline的用法示例。


在下文中一共展示了ChannelPipeline.addFirst方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: newChannel

import org.jboss.netty.channel.ChannelPipeline; //導入方法依賴的package包/類
@Override
public SocketChannel newChannel(ChannelPipeline pipeline) {
  try {
    SSLContext sslContext = SSLContext.getInstance("TLS");
    sslContext.init(null, new TrustManager[]{new PermissiveTrustManager()},
                    null);
    SSLEngine sslEngine = sslContext.createSSLEngine();
    sslEngine.setUseClientMode(true);
    // addFirst() will make SSL handling the first stage of decoding
    // and the last stage of encoding
    pipeline.addFirst("ssl", new SslHandler(sslEngine));
    return super.newChannel(pipeline);
  } catch (Exception ex) {
    throw new RuntimeException("Cannot create SSL channel", ex);
  }
}
 
開發者ID:moueimei,項目名稱:flume-release-1.7.0,代碼行數:17,代碼來源:TestAvroSource.java

示例2: getPipeline

import org.jboss.netty.channel.ChannelPipeline; //導入方法依賴的package包/類
@Override
public ChannelPipeline getPipeline() throws Exception {
  ChannelPipeline pipeline = Channels.pipeline();
  ZlibEncoder encoder = new ZlibEncoder(6);
  pipeline.addFirst("deflater", encoder);
  pipeline.addFirst("inflater", new ZlibDecoder());
  return pipeline;
}
 
開發者ID:moueimei,項目名稱:flume-release-1.7.0,代碼行數:9,代碼來源:RpcTestUtils.java

示例3: getPipeline

import org.jboss.netty.channel.ChannelPipeline; //導入方法依賴的package包/類
@Override
public ChannelPipeline getPipeline() throws Exception {
  ChannelPipeline pipeline = Channels.pipeline();
  if (enableCompression) {
    ZlibEncoder encoder = new ZlibEncoder(6);
    pipeline.addFirst("deflater", encoder);
    pipeline.addFirst("inflater", new ZlibDecoder());
  }

  if (enableSsl) {
    SSLEngine sslEngine = createServerSSLContext().createSSLEngine();
    sslEngine.setUseClientMode(false);
    List<String> enabledProtocols = new ArrayList<String>();
    for (String protocol : sslEngine.getEnabledProtocols()) {
      if (!excludeProtocols.contains(protocol)) {
        enabledProtocols.add(protocol);
      }
    }
    sslEngine.setEnabledProtocols(enabledProtocols.toArray(new String[0]));
    logger.info("SSLEngine protocols enabled: " +
        Arrays.asList(sslEngine.getEnabledProtocols()));
    // addFirst() will make SSL handling the first stage of decoding
    // and the last stage of encoding this must be added after
    // adding compression handling above
    pipeline.addFirst("ssl", new SslHandler(sslEngine));
  }

  if (enableIpFilter) {

    logger.info("Setting up ipFilter with the following rule definition: " +
                patternRuleConfigDefinition);
    IpFilterRuleHandler ipFilterHandler = new IpFilterRuleHandler();
    ipFilterHandler.addAll(rules);
    logger.info("Adding ipFilter with " + ipFilterHandler.size() + " rules");

    pipeline.addFirst("ipFilter", ipFilterHandler);
  }

  return pipeline;
}
 
開發者ID:moueimei,項目名稱:flume-release-1.7.0,代碼行數:41,代碼來源:AvroSource.java

示例4: getPipeline

import org.jboss.netty.channel.ChannelPipeline; //導入方法依賴的package包/類
@Override
public ChannelPipeline getPipeline() throws Exception {
   	 ChannelPipeline pipeline = super.getPipeline();
   	 SslHandler handler = serverContext.newHandler();
   	 pipeline.addFirst("ssl handler", handler);
   	 return pipeline;
   }
 
開發者ID:elasticsearchssl,項目名稱:easyssl,代碼行數:8,代碼來源:SSLTransport.java

示例5: newChannel

import org.jboss.netty.channel.ChannelPipeline; //導入方法依賴的package包/類
@Override
public SocketChannel newChannel(ChannelPipeline pipeline) {
  TrustManager[] managers;
  try {
    if (enableCompression) {
      ZlibEncoder encoder = new ZlibEncoder(compressionLevel);
      pipeline.addFirst("deflater", encoder);
      pipeline.addFirst("inflater", new ZlibDecoder());
    }
    if (enableSsl) {
      if (trustAllCerts) {
        logger.warn("No truststore configured, setting TrustManager to accept"
            + " all server certificates");
        managers = new TrustManager[] { new PermissiveTrustManager() };
      } else {
        KeyStore keystore = null;

        if (truststore != null) {
          if (truststorePassword == null) {
            throw new NullPointerException("truststore password is null");
          }
          InputStream truststoreStream = new FileInputStream(truststore);
          keystore = KeyStore.getInstance(truststoreType);
          keystore.load(truststoreStream, truststorePassword.toCharArray());
        }

        TrustManagerFactory tmf = TrustManagerFactory.getInstance("SunX509");
        // null keystore is OK, with SunX509 it defaults to system CA Certs
        // see http://docs.oracle.com/javase/6/docs/technotes/guides/security/jsse/JSSERefGuide.html#X509TrustManager
        tmf.init(keystore);
        managers = tmf.getTrustManagers();
      }

      SSLContext sslContext = SSLContext.getInstance("TLS");
      sslContext.init(null, managers, null);
      SSLEngine sslEngine = sslContext.createSSLEngine();
      sslEngine.setUseClientMode(true);
      List<String> enabledProtocols = new ArrayList<String>();
      for (String protocol : sslEngine.getEnabledProtocols()) {
        if (!excludeProtocols.contains(protocol)) {
          enabledProtocols.add(protocol);
        }
      }
      sslEngine.setEnabledProtocols(enabledProtocols.toArray(new String[0]));
      logger.info("SSLEngine protocols enabled: " +
          Arrays.asList(sslEngine.getEnabledProtocols()));
      // addFirst() will make SSL handling the first stage of decoding
      // and the last stage of encoding this must be added after
      // adding compression handling above
      pipeline.addFirst("ssl", new SslHandler(sslEngine));
    }

    return super.newChannel(pipeline);
  } catch (Exception ex) {
    logger.error("Cannot create SSL channel", ex);
    throw new RuntimeException("Cannot create SSL channel", ex);
  }
}
 
開發者ID:moueimei,項目名稱:flume-release-1.7.0,代碼行數:59,代碼來源:NettyAvroRpcClient.java

示例6: getPipeline

import org.jboss.netty.channel.ChannelPipeline; //導入方法依賴的package包/類
@Override
public ChannelPipeline getPipeline() throws Exception {
   	ChannelPipeline pipeline = super.getPipeline();	 
       pipeline.addFirst("ssl.handler", serverContext.newHandler());
       return pipeline;
   }
 
開發者ID:elasticsearchssl,項目名稱:easyssl,代碼行數:7,代碼來源:HttpsServerTransport.java


注:本文中的org.jboss.netty.channel.ChannelPipeline.addFirst方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。