当前位置: 首页>>代码示例>>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;未经允许,请勿转载。