本文整理汇总了Java中org.jboss.netty.handler.codec.compression.ZlibDecoder类的典型用法代码示例。如果您正苦于以下问题:Java ZlibDecoder类的具体用法?Java ZlibDecoder怎么用?Java ZlibDecoder使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ZlibDecoder类属于org.jboss.netty.handler.codec.compression包,在下文中一共展示了ZlibDecoder类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: startCompression
import org.jboss.netty.handler.codec.compression.ZlibDecoder; //导入依赖的package包/类
/**
* @see org.apache.james.imap.api.process.ImapSession#startCompression()
*/
public boolean startCompression() {
if (isCompressionSupported() == false)
return false;
channel.setReadable(false);
ZlibDecoder decoder = new ZlibDecoder(ZlibWrapper.NONE);
ZlibEncoder encoder = new ZlibEncoder(ZlibWrapper.NONE, 5);
// Check if we have the SslHandler in the pipeline already
// if so we need to move the compress encoder and decoder
// behind it in the chain
// See JAMES-1186
if (channel.getPipeline().get(SSL_HANDLER) == null) {
channel.getPipeline().addFirst(ZLIB_DECODER, decoder);
channel.getPipeline().addFirst(ZLIB_ENCODER, encoder);
} else {
channel.getPipeline().addAfter(SSL_HANDLER, ZLIB_DECODER, decoder);
channel.getPipeline().addAfter(SSL_HANDLER, ZLIB_ENCODER, encoder);
}
channel.setReadable(true);
return true;
}
开发者ID:twachan,项目名称:James,代码行数:28,代码来源:NettyImapSession.java
示例2: getPipeline
import org.jboss.netty.handler.codec.compression.ZlibDecoder; //导入依赖的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.handler.codec.compression.ZlibDecoder; //导入依赖的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: newChannel
import org.jboss.netty.handler.codec.compression.ZlibDecoder; //导入依赖的package包/类
@Override
public SocketChannel newChannel(ChannelPipeline pipeline) {
try {
ZlibEncoder encoder = new ZlibEncoder(compressionLevel);
pipeline.addFirst("deflater", encoder);
pipeline.addFirst("inflater", new ZlibDecoder());
return super.newChannel(pipeline);
} catch (Exception ex) {
throw new RuntimeException("Cannot create Compression channel", ex);
}
}
开发者ID:moueimei,项目名称:flume-release-1.7.0,代码行数:13,代码来源:TestAvroSource.java
示例5: emit
import org.jboss.netty.handler.codec.compression.ZlibDecoder; //导入依赖的package包/类
@Override
public void emit() {
// TODO Auto-generated method stub
// Server服务启动器
try {
bossExecutor = Executors.newCachedThreadPool();
workerExecutor = Executors.newCachedThreadPool();
bootstrap = new ServerBootstrap(
new NioServerSocketChannelFactory(
bossExecutor,workerExecutor));
final NettyServerHandler nettyServerHandler = new NettyServerHandler(
this);
// 设置一个处理客户端消息和各种消息事件的类(Handler)
bootstrap.setPipelineFactory(new ChannelPipelineFactory() {
@Override
public ChannelPipeline getPipeline() throws Exception {
ChannelPipeline pipeline = Channels.pipeline();
if(isExtract){
pipeline.addLast("zlibDecoder", new ZlibDecoder(ZlibWrapper.GZIP));
}
pipeline.addLast(
"decoder",
new DelimiterBasedFrameDecoder(Integer.MAX_VALUE,
false, true, ChannelBuffers.copiedBuffer(
delimiter,
Charset.forName(encoding))));
pipeline.addLast("handler", nettyServerHandler);
return pipeline;
}
});
bootstrap.setOption("child.receiveBufferSize", receiveBufferSize);
bootstrap.setOption("child.keepAlive", true);
bootstrap.setOption("child.tcpNoDelay", true);
bootstrap.bind(new InetSocketAddress(InetAddress.getByName(host),
port));
} catch (Exception e) {
logger.error(e.getMessage());
System.exit(1);
}
}
开发者ID:DTStack,项目名称:jlogstash-input-plugin,代码行数:41,代码来源:Netty.java
示例6: decode
import org.jboss.netty.handler.codec.compression.ZlibDecoder; //导入依赖的package包/类
private void decode(ChannelHandlerContext context, ChannelBuffer buffer, SocketAddress remoteAddress) throws Exception {
ChannelPipeline pipeline = context.getPipeline();
if (detectSsl && SslHandler.isEncrypted(buffer)) {
SSLEngine engine = SSL_SERVER_CONTEXT.getValue().createSSLEngine();
engine.setUseClientMode(false);
pipeline.addLast("ssl", new SslHandler(engine));
pipeline.addLast("streamer", new ChunkedWriteHandler());
pipeline.addLast("unificationWOSsl", new PortUnificationServerHandler(delegatingHttpRequestHandler, null, false, detectGzip));
}
else {
int magic1 = buffer.getUnsignedByte(buffer.readerIndex());
int magic2 = buffer.getUnsignedByte(buffer.readerIndex() + 1);
if (detectGzip && magic1 == 31 && magic2 == 139) {
pipeline.addLast("gzipDeflater", new ZlibEncoder(ZlibWrapper.GZIP));
pipeline.addLast("gzipInflater", new ZlibDecoder(ZlibWrapper.GZIP));
pipeline.addLast("unificationWOGzip", new PortUnificationServerHandler(delegatingHttpRequestHandler, null, detectSsl, false));
}
else {
pipeline.addLast("decoder", new HttpRequestDecoder());
pipeline.addLast("aggregator", new HttpChunkAggregator(1048576));
pipeline.addLast("encoder", new HttpResponseEncoder());
pipeline.addLast("deflater", new HttpContentCompressor());
pipeline.addLast("handler", delegatingHttpRequestHandler);
}
}
// must be after new channels handlers addition (netty bug?)
pipeline.remove(this);
Channels.fireMessageReceived(context, buffer, remoteAddress);
}
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:30,代码来源:PortUnificationServerHandler.java
示例7: newChannel
import org.jboss.netty.handler.codec.compression.ZlibDecoder; //导入依赖的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
注:本文中的org.jboss.netty.handler.codec.compression.ZlibDecoder类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论