Fix all remaining checkstyle violations
This commit is contained in:
parent
0007e91923
commit
783a7e5f9a
@ -27,43 +27,43 @@ import io.netty.bootstrap.ClientBootstrap;
|
||||
import io.netty.channel.Channel;
|
||||
import io.netty.channel.ChannelFuture;
|
||||
import io.netty.channel.socket.nio.NioClientSocketChannelFactory;
|
||||
import io.netty.handler.codec.http.QueryStringEncoder;
|
||||
import io.netty.handler.codec.http.CookieEncoder;
|
||||
import io.netty.handler.codec.http.DefaultHttpDataFactory;
|
||||
import io.netty.handler.codec.http.DefaultHttpRequest;
|
||||
import io.netty.handler.codec.http.DiskAttribute;
|
||||
import io.netty.handler.codec.http.DiskFileUpload;
|
||||
import io.netty.handler.codec.http.InterfaceHttpData;
|
||||
import io.netty.handler.codec.http.HttpPostRequestEncoder;
|
||||
import io.netty.handler.codec.http.HttpDataFactory;
|
||||
import io.netty.handler.codec.http.HttpHeaders;
|
||||
import io.netty.handler.codec.http.HttpMethod;
|
||||
import io.netty.handler.codec.http.HttpPostRequestEncoder;
|
||||
import io.netty.handler.codec.http.HttpPostRequestEncoder.ErrorDataEncoderException;
|
||||
import io.netty.handler.codec.http.HttpRequest;
|
||||
import io.netty.handler.codec.http.HttpVersion;
|
||||
import io.netty.handler.codec.http.HttpPostRequestEncoder.ErrorDataEncoderException;
|
||||
import io.netty.handler.codec.http.InterfaceHttpData;
|
||||
import io.netty.handler.codec.http.QueryStringEncoder;
|
||||
|
||||
/**
|
||||
*/
|
||||
public class HttpUploadClient {
|
||||
|
||||
public static void main(String[] args) {
|
||||
if (args.length != 2) {
|
||||
System.err.println(
|
||||
"Usage: " + HttpUploadClient.class.getSimpleName() +
|
||||
" baseURI Filepath");
|
||||
return;
|
||||
}
|
||||
private final String baseUri;
|
||||
private final String filePath;
|
||||
|
||||
String baseURI = args[0];
|
||||
public HttpUploadClient(String baseUri, String filePath) {
|
||||
this.baseUri = baseUri;
|
||||
this.filePath = filePath;
|
||||
}
|
||||
|
||||
public void run() {
|
||||
String postSimple, postFile, get;
|
||||
if (baseURI.endsWith("/")) {
|
||||
postSimple = baseURI + "formpost";
|
||||
postFile = baseURI + "formpostmultipart";
|
||||
get = baseURI + "formget";
|
||||
if (baseUri.endsWith("/")) {
|
||||
postSimple = baseUri + "formpost";
|
||||
postFile = baseUri + "formpostmultipart";
|
||||
get = baseUri + "formget";
|
||||
} else {
|
||||
postSimple = baseURI + "/formpost";
|
||||
postFile = baseURI + "/formpostmultipart";
|
||||
get = baseURI + "/formget";
|
||||
postSimple = baseUri + "/formpost";
|
||||
postFile = baseUri + "/formpostmultipart";
|
||||
get = baseUri + "/formget";
|
||||
}
|
||||
URI uriSimple;
|
||||
try {
|
||||
@ -97,7 +97,7 @@ public class HttpUploadClient {
|
||||
System.err.println("Error: " + e.getMessage());
|
||||
return;
|
||||
}
|
||||
File file = new File(args[1]);
|
||||
File file = new File(filePath);
|
||||
if (! file.canRead()) {
|
||||
System.err.println("A correct path is needed");
|
||||
return;
|
||||
@ -135,7 +135,7 @@ public class HttpUploadClient {
|
||||
return;
|
||||
}
|
||||
// Multipart Post form: factory used
|
||||
formpostmultipart(bootstrap, host, port, uriFile, file, factory, headers, bodylist);
|
||||
formpostmultipart(bootstrap, host, port, uriFile, factory, headers, bodylist);
|
||||
|
||||
// Shut down executor threads to exit.
|
||||
bootstrap.releaseExternalResources();
|
||||
@ -216,13 +216,7 @@ public class HttpUploadClient {
|
||||
|
||||
/**
|
||||
* Standard post without multipart but already support on Factory (memory management)
|
||||
* @param bootstrap
|
||||
* @param host
|
||||
* @param port
|
||||
* @param uriSimple
|
||||
* @param file
|
||||
* @param factory
|
||||
* @param headers
|
||||
*
|
||||
* @return the list of HttpData object (attribute and file) to be reused on next post
|
||||
*/
|
||||
private static List<InterfaceHttpData> formpost(ClientBootstrap bootstrap,
|
||||
@ -311,17 +305,9 @@ public class HttpUploadClient {
|
||||
|
||||
/**
|
||||
* Multipart example
|
||||
* @param bootstrap
|
||||
* @param host
|
||||
* @param port
|
||||
* @param uriFile
|
||||
* @param file
|
||||
* @param factory
|
||||
* @param headers
|
||||
* @param bodylist
|
||||
*/
|
||||
private static void formpostmultipart(ClientBootstrap bootstrap, String host, int port,
|
||||
URI uriFile, File file, HttpDataFactory factory,
|
||||
URI uriFile, HttpDataFactory factory,
|
||||
List<Entry<String, String>> headers, List<InterfaceHttpData> bodylist) {
|
||||
// XXX /formpostmultipart
|
||||
// Start the connection attempt.
|
||||
@ -390,12 +376,19 @@ public class HttpUploadClient {
|
||||
channel.getCloseFuture().awaitUninterruptibly();
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
if (args.length != 2) {
|
||||
System.err.println(
|
||||
"Usage: " + HttpUploadClient.class.getSimpleName() +
|
||||
" baseURI filePath");
|
||||
return;
|
||||
}
|
||||
|
||||
String baseUri = args[0];
|
||||
String filePath = args[1];
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
new HttpUploadClient(baseUri, filePath).run();
|
||||
}
|
||||
|
||||
// use to simulate a big TEXTAREA field in a form
|
||||
private static final String textArea =
|
||||
|
@ -21,10 +21,15 @@ import java.util.concurrent.Executors;
|
||||
import io.netty.bootstrap.ServerBootstrap;
|
||||
import io.netty.channel.socket.nio.NioServerSocketChannelFactory;
|
||||
|
||||
/**
|
||||
*/
|
||||
public class HttpUploadServer {
|
||||
public static void main(String[] args) {
|
||||
|
||||
private final int port;
|
||||
|
||||
public HttpUploadServer(int port) {
|
||||
this.port = port;
|
||||
}
|
||||
|
||||
public void run() {
|
||||
// Configure the server.
|
||||
ServerBootstrap bootstrap = new ServerBootstrap(
|
||||
new NioServerSocketChannelFactory(
|
||||
@ -35,6 +40,16 @@ public class HttpUploadServer {
|
||||
bootstrap.setPipelineFactory(new HttpUploadServerPipelineFactory());
|
||||
|
||||
// Bind and start to accept incoming connections.
|
||||
bootstrap.bind(new InetSocketAddress(8080));
|
||||
bootstrap.bind(new InetSocketAddress(port));
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
int port;
|
||||
if (args.length > 0) {
|
||||
port = Integer.parseInt(args[0]);
|
||||
} else {
|
||||
port = 8080;
|
||||
}
|
||||
new HttpUploadServer(port).run();
|
||||
}
|
||||
}
|
||||
|
@ -32,8 +32,15 @@ import java.util.concurrent.Executors;
|
||||
*/
|
||||
public class SctpClient {
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
private final String host;
|
||||
private final int port;
|
||||
|
||||
public SctpClient(String host, int port) {
|
||||
this.host = host;
|
||||
this.port = port;
|
||||
}
|
||||
|
||||
public void run() {
|
||||
// Configure the client.
|
||||
ClientBootstrap bootstrap = new ClientBootstrap(
|
||||
new SctpClientSocketChannelFactory(
|
||||
@ -57,14 +64,31 @@ public class SctpClient {
|
||||
bootstrap.setOption("sctpNoDelay", true);
|
||||
|
||||
// Start the connection attempt.
|
||||
ChannelFuture future = bootstrap.connect(new InetSocketAddress("localhost", 2955), new InetSocketAddress("localhost", 2956));
|
||||
ChannelFuture future = bootstrap.connect(new InetSocketAddress(host, port));
|
||||
|
||||
// Wait until the connection is closed or the connection attempt fails.
|
||||
future.getChannel().getCloseFuture().awaitUninterruptibly();
|
||||
|
||||
// Please check SctpClientHandler to see, how echo message is sent & received
|
||||
// Please check SctpClientHandler to see, how echo message is sent & received
|
||||
|
||||
// Shut down thread pools to exit.
|
||||
bootstrap.releaseExternalResources();
|
||||
}
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
// Print usage if no argument is specified.
|
||||
if (args.length != 2) {
|
||||
System.err.println(
|
||||
"Usage: " + SctpClient.class.getSimpleName() +
|
||||
" <host> <port>");
|
||||
return;
|
||||
}
|
||||
|
||||
// Parse options.
|
||||
final String host = args[0];
|
||||
final int port = Integer.parseInt(args[1]);
|
||||
final int firstMessageSize;
|
||||
|
||||
new SctpClient(host, port).run();
|
||||
}
|
||||
}
|
||||
|
@ -31,7 +31,13 @@ import java.util.concurrent.Executors;
|
||||
*/
|
||||
public class SctpServer {
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
private final int port;
|
||||
|
||||
public SctpServer(int port) {
|
||||
this.port = port;
|
||||
}
|
||||
|
||||
public void run() {
|
||||
// Configure the server.
|
||||
ServerBootstrap bootstrap = new ServerBootstrap(
|
||||
new SctpServerSocketChannelFactory(
|
||||
@ -54,6 +60,16 @@ public class SctpServer {
|
||||
bootstrap.setOption("child.sctpNoDelay", true);
|
||||
|
||||
// Bind and start to accept incoming connections.
|
||||
bootstrap.bind(new InetSocketAddress("localhost", 2955));
|
||||
bootstrap.bind(new InetSocketAddress(port));
|
||||
}
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
int port;
|
||||
if (args.length > 0) {
|
||||
port = Integer.parseInt(args[0]);
|
||||
} else {
|
||||
port = 2955;
|
||||
}
|
||||
new SctpServer(port).run();
|
||||
}
|
||||
}
|
||||
|
@ -39,10 +39,9 @@ import io.netty.handler.codec.string.StringEncoder;
|
||||
*/
|
||||
public class StdioLogger {
|
||||
|
||||
private static volatile boolean running = true;
|
||||
|
||||
public static void main(String[] args) {
|
||||
private volatile boolean running = true;
|
||||
|
||||
public void run() {
|
||||
final ExecutorService executorService = Executors.newCachedThreadPool();
|
||||
final ClientBootstrap bootstrap = new ClientBootstrap(new IoStreamChannelFactory(executorService));
|
||||
|
||||
@ -64,7 +63,7 @@ public class StdioLogger {
|
||||
e.getChannel().write("Message received: " + message);
|
||||
}
|
||||
if ("exit".equals(message)) {
|
||||
StdioLogger.running = false;
|
||||
running = false;
|
||||
}
|
||||
super.messageReceived(ctx, e);
|
||||
}
|
||||
@ -93,7 +92,9 @@ public class StdioLogger {
|
||||
|
||||
// Shut down all thread pools to exit.
|
||||
bootstrap.releaseExternalResources();
|
||||
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
new StdioLogger().run();
|
||||
}
|
||||
}
|
||||
|
2
pom.xml
2
pom.xml
@ -291,7 +291,7 @@
|
||||
<dependency>
|
||||
<groupId>${project.groupId}</groupId>
|
||||
<artifactId>netty-build</artifactId>
|
||||
<version>2-SNAPSHOT</version>
|
||||
<version>3</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</plugin>
|
||||
|
@ -36,19 +36,5 @@
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<artifactId>maven-jar-plugin</artifactId>
|
||||
<version>2.3.2</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>default-jar</id>
|
||||
<phase>none</phase>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</project>
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user