List of usage examples for io.netty.channel ChannelPipeline addLast
ChannelPipeline addLast(ChannelHandler... handlers);
From source file:com.digisky.innerproxy.server.HttpServerInitializer.java
License:Apache License
@Override public void initChannel(SocketChannel ch) { ChannelPipeline p = ch.pipeline(); if (sslCtx != null) { p.addLast(sslCtx.newHandler(ch.alloc())); }/*w ww. j a va2 s . c o m*/ p.addLast(new HttpRequestDecoder()); // Uncomment the following line if you don't want to handle HttpChunks. p.addLast(new HttpObjectAggregator(1048576)); p.addLast(new HttpResponseEncoder()); // Remove the following line if you don't want automatic content compression. //p.addLast(new HttpContentCompressor()); p.addLast(new InnerProxyHttpServerHandler()); }
From source file:com.digisky.outerproxy.server.HttpServerInitializer.java
License:Apache License
@Override public void initChannel(SocketChannel ch) { ChannelPipeline p = ch.pipeline(); if (sslCtx != null) { p.addLast(sslCtx.newHandler(ch.alloc())); }/* w w w . j ava2 s . c o m*/ p.addLast(new HttpRequestDecoder()); // Uncomment the following line if you don't want to handle HttpChunks. p.addLast(new HttpObjectAggregator(1048576)); p.addLast(new HttpResponseEncoder()); // Remove the following line if you don't want automatic content compression. //p.addLast(new HttpContentCompressor()); p.addLast(new OuterProxyHttpServerHandler()); }
From source file:com.dlc.server.DLCHttpServerInitializer.java
@Override public void initChannel(SocketChannel ch) { ChannelPipeline p = ch.pipeline(); if (sslCtx != null) { p.addLast(sslCtx.newHandler(ch.alloc())); }//from w w w. j a va 2s. c o m p.addLast(new HttpServerCodec()); p.addLast("controller", handler); }
From source file:com.dwarf.netty.guide.factorial.FactorialClientInitializer.java
License:Apache License
@Override public void initChannel(SocketChannel ch) { ChannelPipeline pipeline = ch.pipeline(); if (sslCtx != null) { pipeline.addLast(sslCtx.newHandler(ch.alloc(), FactorialClient.HOST, FactorialClient.PORT)); }/* ww w . ja v a 2 s.c o m*/ // Enable stream compression (you can remove these two if unnecessary) /*pipeline.addLast(ZlibCodecFactory.newZlibEncoder(ZlibWrapper.GZIP)); pipeline.addLast(ZlibCodecFactory.newZlibDecoder(ZlibWrapper.GZIP));*/ // Add the number codec first, pipeline.addLast(new BigIntegerDecoder()); pipeline.addLast(new NumberEncoder()); // and then business logic. pipeline.addLast(new FactorialClientHandler()); }
From source file:com.dwarf.netty.guide.factorial.FactorialServerInitializer.java
License:Apache License
@Override public void initChannel(SocketChannel ch) { ChannelPipeline pipeline = ch.pipeline(); if (sslCtx != null) { pipeline.addLast(sslCtx.newHandler(ch.alloc())); }//from w w w. ja va 2 s . c o m // Enable stream compression (you can remove these two if unnecessary) /*pipeline.addLast(ZlibCodecFactory.newZlibEncoder(ZlibWrapper.GZIP)); pipeline.addLast(ZlibCodecFactory.newZlibDecoder(ZlibWrapper.GZIP));*/ // Add the number codec first, pipeline.addLast(new BigIntegerDecoder()); pipeline.addLast(new NumberEncoder()); // and then business logic. // Please note we create a handler for every new channel // because it has stateful properties. pipeline.addLast(new FactorialServerHandler()); }
From source file:com.dwarf.netty.guide.http.snoop.HttpSnoopClientInitializer.java
License:Apache License
@Override public void initChannel(SocketChannel ch) { ChannelPipeline p = ch.pipeline(); // Enable HTTPS if necessary. if (sslCtx != null) { p.addLast(sslCtx.newHandler(ch.alloc())); }/* w w w .j ava 2 s . co m*/ //p.addLast(new HttpClientCodec()); p.addLast(new HttpRequestEncoder()); p.addLast(new HttpResponseDecoder()); // Remove the following line if you don't want automatic content decompression. p.addLast(new HttpContentDecompressor()); // Uncomment the following line if you don't want to handle HttpContents. //p.addLast(new HttpObjectAggregator(1048576)); p.addLast(new HttpSnoopClientHandler()); }
From source file:com.dwarf.netty.guide.worldclock.WorldClockClientInitializer.java
License:Apache License
@Override public void initChannel(SocketChannel ch) { ChannelPipeline p = ch.pipeline(); if (sslCtx != null) { p.addLast(sslCtx.newHandler(ch.alloc(), WorldClockClient.HOST, WorldClockClient.PORT)); }//from ww w . j a va 2 s. c o m p.addLast(new ProtobufVarint32FrameDecoder()); p.addLast(new ProtobufDecoder(WorldClockProtocol.LocalTimes.getDefaultInstance())); p.addLast(new ProtobufVarint32LengthFieldPrepender()); p.addLast(new ProtobufEncoder()); p.addLast(new WorldClockClientHandler()); }
From source file:com.dwarf.netty.guide.worldclock.WorldClockServerInitializer.java
License:Apache License
@Override public void initChannel(SocketChannel ch) throws Exception { ChannelPipeline p = ch.pipeline(); if (sslCtx != null) { p.addLast(sslCtx.newHandler(ch.alloc())); }// w w w . ja v a2 s. co m p.addLast(new ProtobufVarint32FrameDecoder()); p.addLast(new ProtobufDecoder(WorldClockProtocol.Locations.getDefaultInstance())); p.addLast(new ProtobufVarint32LengthFieldPrepender()); p.addLast(new ProtobufEncoder()); p.addLast(new WorldClockServerHandler()); }
From source file:com.eightkdata.mongowp.mongoserver.MongoServer.java
License:Open Source License
private void buildChildHandlerPipeline(ChannelPipeline pipeline) { pipeline.addLast(new LengthFieldBasedFrameDecoder(ByteOrder.LITTLE_ENDIAN, MongoWP.MAX_MESSAGE_SIZE_BYTES, 0, MongoWP.MESSAGE_LENGTH_FIELD_BYTES, -MongoWP.MESSAGE_LENGTH_FIELD_BYTES, MongoWP.MESSAGE_LENGTH_FIELD_BYTES, true)); pipeline.addLast(new RequestMessageByteHandler()); pipeline.addLast(new LengthFieldPrependerLittleEndian(MongoWP.MESSAGE_LENGTH_FIELD_BYTES, true)); pipeline.addLast(new ReplyMessageObjectHandler(this)); pipeline.addLast(new RequestMessageObjectHandler(requestProcessor)); }
From source file:com.eightkdata.mongowp.server.wp.NettyMongoServer.java
License:Open Source License
private void buildChildHandlerPipeline(ChannelPipeline pipeline) { pipeline.addLast(new LengthFieldBasedFrameDecoder(ByteOrder.LITTLE_ENDIAN, MongoConstants.MAX_MESSAGE_SIZE_BYTES, 0, MongoConstants.MESSAGE_LENGTH_FIELD_BYTES, -MongoConstants.MESSAGE_LENGTH_FIELD_BYTES, MongoConstants.MESSAGE_LENGTH_FIELD_BYTES, true)); pipeline.addLast(requestMessageByteHandler.get()); pipeline.addLast(lengthFieldPrependerLittleEndian); pipeline.addLast(replyMessageObjectHandler.get()); pipeline.addLast(requestMessageObjectHandler); }