diff --git a/src/main/java/org/jboss/netty/example/http/HttpClient.java b/src/main/java/org/jboss/netty/example/http/HttpClient.java index e752387396..43592f8117 100644 --- a/src/main/java/org/jboss/netty/example/http/HttpClient.java +++ b/src/main/java/org/jboss/netty/example/http/HttpClient.java @@ -73,8 +73,7 @@ public class HttpClient { Executors.newCachedThreadPool()); ClientBootstrap bootstrap = new ClientBootstrap(factory); - HttpClientPipelineFactory handler = new HttpClientPipelineFactory(new HttpResponseHandler()); - bootstrap.setPipelineFactory(handler); + bootstrap.setPipelineFactory(new HttpClientPipelineFactory()); // Start the connection attempt. ChannelFuture future = bootstrap.connect(new InetSocketAddress(host, port)); diff --git a/src/main/java/org/jboss/netty/example/http/HttpClientPipelineFactory.java b/src/main/java/org/jboss/netty/example/http/HttpClientPipelineFactory.java index fd555850e4..1a3f77b54d 100644 --- a/src/main/java/org/jboss/netty/example/http/HttpClientPipelineFactory.java +++ b/src/main/java/org/jboss/netty/example/http/HttpClientPipelineFactory.java @@ -23,7 +23,6 @@ package org.jboss.netty.example.http; import static org.jboss.netty.channel.Channels.*; -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.HttpRequestEncoder; @@ -34,12 +33,6 @@ import org.jboss.netty.handler.codec.http.HttpResponseDecoder; * @author Andy Taylor (andy.taylor@jboss.org) */ public class HttpClientPipelineFactory implements ChannelPipelineFactory { - private final ChannelHandler handler; - - public HttpClientPipelineFactory(HttpResponseHandler handler) { - this.handler = handler; - } - public ChannelPipeline getPipeline() throws Exception { // Create a default pipeline implementation. ChannelPipeline pipeline = pipeline(); @@ -47,7 +40,7 @@ public class HttpClientPipelineFactory implements ChannelPipelineFactory { // Uncomment the following line if you don't want to handle HttpChunks. //pipeline.addLast("aggregator", new HttpChunkAggregator(1048576)); pipeline.addLast("encoder", new HttpRequestEncoder()); - pipeline.addLast("handler", handler); + pipeline.addLast("handler", new HttpResponseHandler()); return pipeline; } } diff --git a/src/main/java/org/jboss/netty/example/http/HttpServer.java b/src/main/java/org/jboss/netty/example/http/HttpServer.java index 46803bfb34..e7e3bb1f5d 100644 --- a/src/main/java/org/jboss/netty/example/http/HttpServer.java +++ b/src/main/java/org/jboss/netty/example/http/HttpServer.java @@ -41,8 +41,7 @@ public class HttpServer { Executors.newCachedThreadPool()); ServerBootstrap bootstrap = new ServerBootstrap(factory); - HttpServerPipelineFactory pipeline = new HttpServerPipelineFactory(new HttpRequestHandler()); - bootstrap.setPipelineFactory(pipeline); + bootstrap.setPipelineFactory(new HttpServerPipelineFactory()); bootstrap.setOption("child.tcpNoDelay", true); bootstrap.setOption("child.keepAlive", true); diff --git a/src/main/java/org/jboss/netty/example/http/HttpServerPipelineFactory.java b/src/main/java/org/jboss/netty/example/http/HttpServerPipelineFactory.java index bce6485127..4cd1367c55 100644 --- a/src/main/java/org/jboss/netty/example/http/HttpServerPipelineFactory.java +++ b/src/main/java/org/jboss/netty/example/http/HttpServerPipelineFactory.java @@ -23,7 +23,6 @@ package org.jboss.netty.example.http; import static org.jboss.netty.channel.Channels.*; -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.HttpRequestDecoder; @@ -34,12 +33,6 @@ import org.jboss.netty.handler.codec.http.HttpResponseEncoder; * @author Andy Taylor (andy.taylor@jboss.org) */ public class HttpServerPipelineFactory implements ChannelPipelineFactory { - private final ChannelHandler handler; - - public HttpServerPipelineFactory(HttpRequestHandler handler) { - this.handler = handler; - } - public ChannelPipeline getPipeline() throws Exception { // Create a default pipeline implementation. ChannelPipeline pipeline = pipeline(); @@ -48,7 +41,7 @@ public class HttpServerPipelineFactory implements ChannelPipelineFactory { // Uncomment the following line if you don't want to handle HttpChunks. //pipeline.addLast("aggregator", new HttpChunkAggregator(1048576)); pipeline.addLast("encoder", new HttpResponseEncoder()); - pipeline.addLast("handler", handler); + pipeline.addLast("handler", new HttpRequestHandler()); return pipeline; } }