List of usage examples for io.netty.channel SimpleChannelInboundHandler isSharable
public boolean isSharable()
From source file:io.soliton.protobuf.ChannelInitializers.java
License:Apache License
/** * Returns a new chanel initializer suited to decode and process HTTP * requests.//from w w w . j a v a 2 s . c om * * @param handler the handler implementing the application logic */ public static final ChannelInitializer<Channel> httpServer( final SimpleChannelInboundHandler<HttpRequest> handler) { Preconditions.checkArgument(handler.isSharable()); return new ChannelInitializer<Channel>() { @Override protected void initChannel(Channel channel) throws Exception { ChannelPipeline pipeline = channel.pipeline(); pipeline.addLast("httpCodec", new HttpServerCodec()); pipeline.addLast("aggregator", new HttpObjectAggregator(10 * 1024 * 1024)); pipeline.addLast("httpServerHandler", handler); } }; }