本文整理了Java中org.jboss.netty.handler.codec.compression.ZlibDecoder
类的一些代码示例,展示了ZlibDecoder
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ZlibDecoder
类的具体详情如下:
包路径:org.jboss.netty.handler.codec.compression.ZlibDecoder
类名称:ZlibDecoder
[英]Decompresses a ChannelBuffer using the deflate algorithm.
[中]使用deflate算法解压缩ChannelBuffer。
代码示例来源:origin: io.netty/netty
@Override
protected DecoderEmbedder<ChannelBuffer> newContentDecoder(String contentEncoding) throws Exception {
if ("gzip".equalsIgnoreCase(contentEncoding) || "x-gzip".equalsIgnoreCase(contentEncoding)) {
return new DecoderEmbedder<ChannelBuffer>(new ZlibDecoder(ZlibWrapper.GZIP));
}
if ("deflate".equalsIgnoreCase(contentEncoding) || "x-deflate".equalsIgnoreCase(contentEncoding)) {
// To be strict, 'deflate' means ZLIB, but some servers were not implemented correctly.
return new DecoderEmbedder<ChannelBuffer>(new ZlibDecoder(ZlibWrapper.ZLIB_OR_NONE));
}
// 'identity' or unsupported
return null;
}
}
代码示例来源:origin: apache/flume
ZlibEncoder encoder = new ZlibEncoder(compressionLevel);
pipeline.addFirst("deflater", encoder);
pipeline.addFirst("inflater", new ZlibDecoder());
代码示例来源:origin: apache/flume
@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());
}
sslEngineSupplier.get().ifPresent(sslEngine -> {
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;
}
}
代码示例来源:origin: apache/avro
@Override
public SocketChannel newChannel(ChannelPipeline pipeline) {
try {
ZlibEncoder encoder = new ZlibEncoder(6);
pipeline.addFirst("deflater", encoder);
pipeline.addFirst("inflater", new ZlibDecoder());
return super.newChannel(pipeline);
} catch (Exception ex) {
throw new RuntimeException("Cannot create Compression channel", ex);
}
}
}
代码示例来源:origin: apache/flume
@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;
}
}
代码示例来源:origin: apache/avro
@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;
}
}
代码示例来源:origin: MovingBlocks/Terasology
@Override
public ChannelPipeline getPipeline() throws Exception {
JoinStatusImpl joinStatus = new JoinStatusImpl();
ChannelPipeline p = Channels.pipeline();
p.addLast(MetricRecordingHandler.NAME, new MetricRecordingHandler());
p.addLast("lengthFrameDecoder", new LengthFieldBasedFrameDecoder(8388608, 0, 3, 0, 3));
p.addLast("inflateDecoder", new ZlibDecoder());
p.addLast("frameDecoder", new ProtobufVarint32FrameDecoder());
p.addLast("protobufDecoder", new ProtobufDecoder(NetData.NetMessage.getDefaultInstance()));
p.addLast("frameEncoder", new ProtobufVarint32LengthFieldPrepender());
p.addLast("protobufEncoder", new ProtobufEncoder());
p.addLast("authenticationHandler", new ClientHandshakeHandler(joinStatus));
p.addLast("connectionHandler", new ServerInfoRequestHandler());
return p;
}
}
代码示例来源:origin: MovingBlocks/Terasology
@Override
public ChannelPipeline getPipeline() throws Exception {
JoinStatusImpl joinStatus = new JoinStatusImpl();
ChannelPipeline p = pipeline();
p.addLast(MetricRecordingHandler.NAME, new MetricRecordingHandler());
p.addLast("lengthFrameDecoder", new LengthFieldBasedFrameDecoder(8388608, 0, 3, 0, 3));
p.addLast("inflateDecoder", new ZlibDecoder());
p.addLast("frameDecoder", new ProtobufVarint32FrameDecoder());
p.addLast("protobufDecoder", new ProtobufDecoder(NetData.NetMessage.getDefaultInstance()));
p.addLast("frameEncoder", new ProtobufVarint32LengthFieldPrepender());
p.addLast("protobufEncoder", new ProtobufEncoder());
p.addLast("authenticationHandler", new ClientHandshakeHandler(joinStatus));
p.addLast("connectionHandler", new ClientConnectionHandler(joinStatus, networkSystem));
p.addLast("handler", new ClientHandler(networkSystem));
return p;
}
}
代码示例来源:origin: org.apache.flume/flume-ng-sdk
ZlibEncoder encoder = new ZlibEncoder(compressionLevel);
pipeline.addFirst("deflater", encoder);
pipeline.addFirst("inflater", new ZlibDecoder());
代码示例来源:origin: org.apache.flume/flume-ng-core
@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());
}
sslEngineSupplier.get().ifPresent(sslEngine -> {
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;
}
}
代码示例来源:origin: org.apache.james/james-server-protocols-imap4
@Override
public boolean startCompression() {
if (!isCompressionSupported()) {
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;
}
代码示例来源:origin: com.googlecode.protobuf-rpc-pro/protobuf-streamer-pro
public ChannelPipeline getPipeline() throws Exception {
ChannelPipeline p = pipeline();
if ( getSslContext() != null ) {
p.addLast(Handler.SSL, new SslHandler(getSslContext().createClientEngine()) );
}
// clients configure compression if the server has it configured.
if ( isCompress() ) {
p.addLast( Handler.DECOMPRESSOR, new ZlibEncoder(ZlibWrapper.GZIP));
p.addLast( Handler.COMPRESSOR, new ZlibDecoder(ZlibWrapper.GZIP));
}
p.addLast(Handler.FRAME_DECODER, new ProtobufVarint32FrameDecoder());
p.addLast(Handler.PROTOBUF_DECODER, new ProtobufDecoder(StreamProtocol.WirePayload.getDefaultInstance()));
p.addLast(Handler.FRAME_ENCODER, new ProtobufVarint32LengthFieldPrepender());
p.addLast(Handler.PROTOBUF_ENCODER, new ProtobufEncoder());
return p;
}
代码示例来源:origin: com.googlecode.protobuf-rpc-pro/protobuf-streamer-pro
public ChannelPipeline getPipeline() throws Exception {
ChannelPipeline p = pipeline();
if ( getSslContext() != null ) {
p.addLast(Handler.SSL, new SslHandler(getSslContext().createServerEngine()) );
}
// clients configure compression if the server has it configured.
if ( isCompress() ) {
p.addLast( Handler.DECOMPRESSOR, new ZlibEncoder(ZlibWrapper.GZIP));
p.addLast( Handler.COMPRESSOR, new ZlibDecoder(ZlibWrapper.GZIP));
}
p.addLast(Handler.FRAME_DECODER, new ProtobufVarint32FrameDecoder());
p.addLast(Handler.PROTOBUF_DECODER, new ProtobufDecoder(StreamProtocol.WirePayload.getDefaultInstance()));
p.addLast(Handler.FRAME_ENCODER, new ProtobufVarint32LengthFieldPrepender());
p.addLast(Handler.PROTOBUF_ENCODER, new ProtobufEncoder());
StreamingServer<E,F> streamingServer = new StreamingServer<E, F>(serverInfo, pullHandler, pushHandler, logger, chunkSize);
p.addLast(Handler.STREAMING_SERVER, new StreamingServerHandler<E, F>(streamingServer));
return p;
}
内容来源于网络,如有侵权,请联系作者删除!