Rename HTTP snoop example classes for disambiguation

This commit is contained in:
Trustin Lee 2012-01-15 00:28:57 +09:00
parent c850bd9231
commit e4a7900b10
7 changed files with 19 additions and 19 deletions

View File

@ -32,13 +32,13 @@ import org.jboss.netty.handler.codec.http.HttpVersion;
/**
* A simple HTTP client that prints out the content of the HTTP response to
* {@link System#out} to test {@link HttpServer}.
* {@link System#out} to test {@link HttpSnoopServer}.
*/
public class HttpClient {
public class HttpSnoopClient {
private final URI uri;
public HttpClient(URI uri) {
public HttpSnoopClient(URI uri) {
this.uri = uri;
}
@ -68,7 +68,7 @@ public class HttpClient {
Executors.newCachedThreadPool()));
// Set up the event pipeline factory.
bootstrap.setPipelineFactory(new HttpClientPipelineFactory(ssl));
bootstrap.setPipelineFactory(new HttpSnoopClientPipelineFactory(ssl));
// Start the connection attempt.
ChannelFuture future = bootstrap.connect(new InetSocketAddress(host, port));
@ -107,12 +107,12 @@ public class HttpClient {
public static void main(String[] args) throws Exception {
if (args.length != 1) {
System.err.println(
"Usage: " + HttpClient.class.getSimpleName() +
"Usage: " + HttpSnoopClient.class.getSimpleName() +
" <URL>");
return;
}
URI uri = new URI(args[0]);
new HttpClient(uri).run();
new HttpSnoopClient(uri).run();
}
}

View File

@ -23,7 +23,7 @@ import org.jboss.netty.handler.codec.http.HttpChunk;
import org.jboss.netty.handler.codec.http.HttpResponse;
import org.jboss.netty.util.CharsetUtil;
public class HttpResponseHandler extends SimpleChannelUpstreamHandler {
public class HttpSnoopClientHandler extends SimpleChannelUpstreamHandler {
private boolean readingChunks;

View File

@ -26,11 +26,11 @@ import org.jboss.netty.handler.codec.http.HttpClientCodec;
import org.jboss.netty.handler.codec.http.HttpContentDecompressor;
import org.jboss.netty.handler.ssl.SslHandler;
public class HttpClientPipelineFactory implements ChannelPipelineFactory {
public class HttpSnoopClientPipelineFactory implements ChannelPipelineFactory {
private final boolean ssl;
public HttpClientPipelineFactory(boolean ssl) {
public HttpSnoopClientPipelineFactory(boolean ssl) {
this.ssl = ssl;
}
@ -55,7 +55,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("handler", new HttpResponseHandler());
pipeline.addLast("handler", new HttpSnoopClientHandler());
return pipeline;
}
}

View File

@ -25,11 +25,11 @@ import org.jboss.netty.channel.socket.nio.NioServerSocketChannelFactory;
* An HTTP server that sends back the content of the received HTTP request
* in a pretty plaintext form.
*/
public class HttpServer {
public class HttpSnoopServer {
private final int port;
public HttpServer(int port) {
public HttpSnoopServer(int port) {
this.port = port;
}
@ -41,7 +41,7 @@ public class HttpServer {
Executors.newCachedThreadPool()));
// Set up the event pipeline factory.
bootstrap.setPipelineFactory(new HttpServerPipelineFactory());
bootstrap.setPipelineFactory(new HttpSnoopServerPipelineFactory());
// Bind and start to accept incoming connections.
bootstrap.bind(new InetSocketAddress(port));
@ -54,7 +54,7 @@ public class HttpServer {
} else {
port = 8080;
}
new HttpServer(port).run();
new HttpSnoopServer(port).run();
}
}

View File

@ -44,7 +44,7 @@ import org.jboss.netty.handler.codec.http.HttpResponse;
import org.jboss.netty.handler.codec.http.QueryStringDecoder;
import org.jboss.netty.util.CharsetUtil;
public class HttpRequestHandler extends SimpleChannelUpstreamHandler {
public class HttpSnoopServerHandler extends SimpleChannelUpstreamHandler {
private HttpRequest request;
private boolean readingChunks;

View File

@ -23,7 +23,7 @@ import org.jboss.netty.handler.codec.http.HttpContentCompressor;
import org.jboss.netty.handler.codec.http.HttpRequestDecoder;
import org.jboss.netty.handler.codec.http.HttpResponseEncoder;
public class HttpServerPipelineFactory implements ChannelPipelineFactory {
public class HttpSnoopServerPipelineFactory implements ChannelPipelineFactory {
public ChannelPipeline getPipeline() throws Exception {
// Create a default pipeline implementation.
ChannelPipeline pipeline = pipeline();
@ -39,7 +39,7 @@ public class HttpServerPipelineFactory implements ChannelPipelineFactory {
pipeline.addLast("encoder", new HttpResponseEncoder());
// Remove the following line if you don't want automatic content compression.
pipeline.addLast("deflater", new HttpContentCompressor());
pipeline.addLast("handler", new HttpRequestHandler());
pipeline.addLast("handler", new HttpSnoopServerHandler());
return pipeline;
}
}

View File

@ -24,7 +24,7 @@ import org.jboss.netty.channel.ChannelPipeline;
import org.jboss.netty.example.factorial.BigIntegerDecoder;
import org.jboss.netty.example.factorial.FactorialServerHandler;
import org.jboss.netty.example.factorial.NumberEncoder;
import org.jboss.netty.example.http.snoop.HttpRequestHandler;
import org.jboss.netty.example.http.snoop.HttpSnoopServerHandler;
import org.jboss.netty.example.securechat.SecureChatSslContextFactory;
import org.jboss.netty.handler.codec.compression.ZlibDecoder;
import org.jboss.netty.handler.codec.compression.ZlibEncoder;
@ -144,7 +144,7 @@ public class PortUnificationServerHandler extends FrameDecoder {
p.addLast("decoder", new HttpRequestDecoder());
p.addLast("encoder", new HttpResponseEncoder());
p.addLast("deflater", new HttpContentCompressor());
p.addLast("handler", new HttpRequestHandler());
p.addLast("handler", new HttpSnoopServerHandler());
p.remove(this);
}