All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.mengweifeng.nettysupport.ServerPipelineFactory Maven / Gradle / Ivy

package com.mengweifeng.nettysupport;

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

import javax.annotation.Resource;

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 org.springframework.stereotype.Component;

@Component("serverPipelineFactory")
public class ServerPipelineFactory implements ChannelPipelineFactory {

	@Resource
	private ServerHandler serverHandler;

	/**
	 * (non-Javadoc)
	 * 
	 * @see org.jboss.netty.channel.ChannelPipelineFactory#getPipeline()
	 */
	@Override
	public ChannelPipeline getPipeline() throws Exception {
		ChannelPipeline pipeline = pipeline();
		pipeline.addLast("decoder", new HttpRequestDecoder(16384, 32768, 32768));
		pipeline.addLast("aggregator", new HttpChunkAggregator(65536));
		pipeline.addLast("encoder", new HttpResponseEncoder());
		pipeline.addLast("handler", serverHandler);
		return pipeline;
	}
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy