Package se.cgbystrom.netty.thrift.http

Source Code of se.cgbystrom.netty.thrift.http.ThriftHttpServerPipelineFactory

package se.cgbystrom.netty.thrift.http;

import static org.jboss.netty.channel.Channels.pipeline;

import org.jboss.netty.channel.ChannelHandler;
import org.jboss.netty.channel.ChannelPipeline;
import org.jboss.netty.channel.ChannelPipelineFactory;
import org.jboss.netty.handler.codec.http.HttpChunkAggregator;
import org.jboss.netty.handler.codec.http.HttpRequestDecoder;
import org.jboss.netty.handler.codec.http.HttpResponseEncoder;

import se.cgbystrom.netty.thrift.ThriftHandler;

/**
* Pipeline factory for Thrift Http client
*
* @author Davide Inglima <limacat@gmail.com>
*/
public class ThriftHttpServerPipelineFactory implements ChannelPipelineFactory {

    private final ThriftHandler handler;

    public ThriftHttpServerPipelineFactory(ThriftHandler handler) {
        this.handler = handler;
    }

    @Override
    public ChannelPipeline getPipeline() throws Exception {
        ChannelPipeline pipeline = pipeline();
        pipeline.addLast("requestDecoder", new HttpRequestDecoder());
        pipeline.addLast("responseEncoder", new HttpResponseEncoder());
        pipeline.addLast("aggregator", new HttpChunkAggregator(1048576));
        pipeline.addLast("thriftHandler", (ChannelHandler) handler);
        return pipeline;
    }

}
TOP

Related Classes of se.cgbystrom.netty.thrift.http.ThriftHttpServerPipelineFactory

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.