Finish the refactoring of bootstrap
This commit is contained in:
parent
4ce85827ed
commit
ec1339d775
@ -15,7 +15,7 @@
|
||||
*/
|
||||
package io.netty.example.discard;
|
||||
|
||||
import io.netty.bootstrap.Bootstrap;
|
||||
import io.netty.bootstrap.ClientBootstrap;
|
||||
import io.netty.channel.ChannelFuture;
|
||||
import io.netty.channel.socket.nio.NioEventLoopGroup;
|
||||
import io.netty.channel.socket.nio.NioSocketChannel;
|
||||
@ -36,10 +36,10 @@ public class DiscardClient {
|
||||
}
|
||||
|
||||
public void run() throws Exception {
|
||||
Bootstrap b = new Bootstrap();
|
||||
ClientBootstrap b = new ClientBootstrap();
|
||||
try {
|
||||
b.group(new NioEventLoopGroup())
|
||||
.channel(new NioSocketChannel())
|
||||
.channel(NioSocketChannel.class)
|
||||
.remoteAddress(host, port)
|
||||
.handler(new DiscardClientHandler(firstMessageSize));
|
||||
|
||||
|
@ -37,7 +37,7 @@ public class DiscardServer {
|
||||
ServerBootstrap b = new ServerBootstrap();
|
||||
try {
|
||||
b.group(new NioEventLoopGroup(), new NioEventLoopGroup())
|
||||
.channel(new NioServerSocketChannel())
|
||||
.channel(NioServerSocketChannel.class)
|
||||
.localAddress(port)
|
||||
.childHandler(new ChannelInitializer<SocketChannel>() {
|
||||
@Override
|
||||
|
@ -15,7 +15,7 @@
|
||||
*/
|
||||
package io.netty.example.echo;
|
||||
|
||||
import io.netty.bootstrap.Bootstrap;
|
||||
import io.netty.bootstrap.ClientBootstrap;
|
||||
import io.netty.channel.ChannelFuture;
|
||||
import io.netty.channel.ChannelInitializer;
|
||||
import io.netty.channel.ChannelOption;
|
||||
@ -47,10 +47,10 @@ public class EchoClient {
|
||||
|
||||
public void run() throws Exception {
|
||||
// Configure the client.
|
||||
Bootstrap b = new Bootstrap();
|
||||
ClientBootstrap b = new ClientBootstrap();
|
||||
try {
|
||||
b.group(new NioEventLoopGroup())
|
||||
.channel(new NioSocketChannel())
|
||||
.channel(NioSocketChannel.class)
|
||||
.option(ChannelOption.TCP_NODELAY, true)
|
||||
.remoteAddress(new InetSocketAddress(host, port))
|
||||
.handler(new ChannelInitializer<SocketChannel>() {
|
||||
|
@ -43,7 +43,7 @@ public class EchoServer {
|
||||
ServerBootstrap b = new ServerBootstrap();
|
||||
try {
|
||||
b.group(new NioEventLoopGroup(), new NioEventLoopGroup())
|
||||
.channel(new NioServerSocketChannel())
|
||||
.channel(NioServerSocketChannel.class)
|
||||
.option(ChannelOption.SO_BACKLOG, 100)
|
||||
.localAddress(new InetSocketAddress(port))
|
||||
.childOption(ChannelOption.TCP_NODELAY, true)
|
||||
|
@ -15,7 +15,7 @@
|
||||
*/
|
||||
package io.netty.example.factorial;
|
||||
|
||||
import io.netty.bootstrap.Bootstrap;
|
||||
import io.netty.bootstrap.ClientBootstrap;
|
||||
import io.netty.channel.ChannelFuture;
|
||||
import io.netty.channel.socket.nio.NioEventLoopGroup;
|
||||
import io.netty.channel.socket.nio.NioSocketChannel;
|
||||
@ -37,10 +37,10 @@ public class FactorialClient {
|
||||
}
|
||||
|
||||
public void run() throws Exception {
|
||||
Bootstrap b = new Bootstrap();
|
||||
ClientBootstrap b = new ClientBootstrap();
|
||||
try {
|
||||
b.group(new NioEventLoopGroup())
|
||||
.channel(new NioSocketChannel())
|
||||
.channel(NioSocketChannel.class)
|
||||
.remoteAddress(host, port)
|
||||
.handler(new FactorialClientInitializer(count));
|
||||
|
||||
|
@ -35,7 +35,7 @@ public class FactorialServer {
|
||||
ServerBootstrap b = new ServerBootstrap();
|
||||
try {
|
||||
b.group(new NioEventLoopGroup(), new NioEventLoopGroup())
|
||||
.channel(new NioServerSocketChannel())
|
||||
.channel(NioServerSocketChannel.class)
|
||||
.localAddress(port)
|
||||
.childHandler(new FactorialServerInitializer());
|
||||
|
||||
|
@ -31,7 +31,7 @@ public class HttpStaticFileServer {
|
||||
ServerBootstrap b = new ServerBootstrap();
|
||||
try {
|
||||
b.group(new NioEventLoopGroup(), new NioEventLoopGroup())
|
||||
.channel(new NioServerSocketChannel())
|
||||
.channel(NioServerSocketChannel.class)
|
||||
.localAddress(port)
|
||||
.childHandler(new HttpStaticFileServerInitializer());
|
||||
|
||||
|
@ -15,7 +15,7 @@
|
||||
*/
|
||||
package io.netty.example.http.snoop;
|
||||
|
||||
import io.netty.bootstrap.Bootstrap;
|
||||
import io.netty.bootstrap.ClientBootstrap;
|
||||
import io.netty.channel.Channel;
|
||||
import io.netty.channel.socket.nio.NioEventLoopGroup;
|
||||
import io.netty.channel.socket.nio.NioSocketChannel;
|
||||
@ -62,10 +62,10 @@ public class HttpSnoopClient {
|
||||
boolean ssl = scheme.equalsIgnoreCase("https");
|
||||
|
||||
// Configure the client.
|
||||
Bootstrap b = new Bootstrap();
|
||||
ClientBootstrap b = new ClientBootstrap();
|
||||
try {
|
||||
b.group(new NioEventLoopGroup())
|
||||
.channel(new NioSocketChannel())
|
||||
.channel(NioSocketChannel.class)
|
||||
.handler(new HttpSnoopClientInitializer(ssl))
|
||||
.remoteAddress(new InetSocketAddress(host, port));
|
||||
|
||||
|
@ -40,7 +40,7 @@ public class HttpSnoopServer {
|
||||
|
||||
try {
|
||||
b.group(new NioEventLoopGroup(), new NioEventLoopGroup())
|
||||
.channel(new NioServerSocketChannel())
|
||||
.channel(NioServerSocketChannel.class)
|
||||
.childHandler(new HttpSnoopServerInitializer())
|
||||
.localAddress(new InetSocketAddress(port));
|
||||
|
||||
|
@ -36,7 +36,7 @@ public class AutobahnServer {
|
||||
ServerBootstrap b = new ServerBootstrap();
|
||||
try {
|
||||
b.group(new NioEventLoopGroup(), new NioEventLoopGroup())
|
||||
.channel(new NioServerSocketChannel())
|
||||
.channel(NioServerSocketChannel.class)
|
||||
.localAddress(port)
|
||||
.childHandler(new AutobahnServerInitializer());
|
||||
|
||||
|
@ -36,7 +36,7 @@
|
||||
//THE SOFTWARE.
|
||||
package io.netty.example.http.websocketx.client;
|
||||
|
||||
import io.netty.bootstrap.Bootstrap;
|
||||
import io.netty.bootstrap.ClientBootstrap;
|
||||
import io.netty.buffer.Unpooled;
|
||||
import io.netty.channel.Channel;
|
||||
import io.netty.channel.ChannelInitializer;
|
||||
@ -65,7 +65,7 @@ public class WebSocketClient {
|
||||
}
|
||||
|
||||
public void run() throws Exception {
|
||||
Bootstrap b = new Bootstrap();
|
||||
ClientBootstrap b = new ClientBootstrap();
|
||||
try {
|
||||
|
||||
String protocol = uri.getScheme();
|
||||
@ -84,7 +84,7 @@ public class WebSocketClient {
|
||||
uri, WebSocketVersion.V13, null, false, customHeaders);
|
||||
|
||||
b.group(new NioEventLoopGroup())
|
||||
.channel(new NioSocketChannel())
|
||||
.channel(NioSocketChannel.class)
|
||||
.remoteAddress(uri.getHost(), uri.getPort())
|
||||
.handler(new ChannelInitializer<SocketChannel>() {
|
||||
@Override
|
||||
|
@ -51,7 +51,7 @@ public class WebSocketServer {
|
||||
ServerBootstrap b = new ServerBootstrap();
|
||||
try {
|
||||
b.group(new NioEventLoopGroup(), new NioEventLoopGroup())
|
||||
.channel(new NioServerSocketChannel())
|
||||
.channel(NioServerSocketChannel.class)
|
||||
.localAddress(port)
|
||||
.childHandler(new WebSocketServerInitializer());
|
||||
|
||||
|
@ -50,7 +50,7 @@ public class WebSocketSslServer {
|
||||
ServerBootstrap b = new ServerBootstrap();
|
||||
try {
|
||||
b.group(new NioEventLoopGroup(), new NioEventLoopGroup())
|
||||
.channel(new NioServerSocketChannel())
|
||||
.channel(NioServerSocketChannel.class)
|
||||
.localAddress(port)
|
||||
.childHandler(new WebSocketSslServerInitializer());
|
||||
|
||||
|
@ -15,7 +15,7 @@
|
||||
*/
|
||||
package io.netty.example.localecho;
|
||||
|
||||
import io.netty.bootstrap.Bootstrap;
|
||||
import io.netty.bootstrap.ClientBootstrap;
|
||||
import io.netty.bootstrap.ServerBootstrap;
|
||||
import io.netty.channel.Channel;
|
||||
import io.netty.channel.ChannelFuture;
|
||||
@ -43,14 +43,14 @@ public class LocalEcho {
|
||||
// Address to bind on / connect to.
|
||||
final LocalAddress addr = new LocalAddress(port);
|
||||
|
||||
Bootstrap cb = new Bootstrap();
|
||||
ClientBootstrap cb = new ClientBootstrap();
|
||||
ServerBootstrap sb = new ServerBootstrap();
|
||||
try {
|
||||
// Note that we can use any event loop to ensure certain local channels
|
||||
// are handled by the same event loop thread which drives a certain socket channel
|
||||
// to reduce the communication latency between socket channels and local channels.
|
||||
sb.group(new LocalEventLoopGroup())
|
||||
.channel(new LocalServerChannel())
|
||||
.channel(LocalServerChannel.class)
|
||||
.localAddress(addr)
|
||||
.handler(new ChannelInitializer<LocalServerChannel>() {
|
||||
@Override
|
||||
@ -68,7 +68,7 @@ public class LocalEcho {
|
||||
});
|
||||
|
||||
cb.group(new NioEventLoopGroup()) // NIO event loops are also OK
|
||||
.channel(new LocalChannel())
|
||||
.channel(LocalChannel.class)
|
||||
.remoteAddress(addr)
|
||||
.handler(new ChannelInitializer<LocalChannel>() {
|
||||
@Override
|
||||
|
@ -15,7 +15,7 @@
|
||||
*/
|
||||
package io.netty.example.localtime;
|
||||
|
||||
import io.netty.bootstrap.Bootstrap;
|
||||
import io.netty.bootstrap.ClientBootstrap;
|
||||
import io.netty.channel.Channel;
|
||||
import io.netty.channel.socket.nio.NioEventLoopGroup;
|
||||
import io.netty.channel.socket.nio.NioSocketChannel;
|
||||
@ -43,10 +43,10 @@ public class LocalTimeClient {
|
||||
}
|
||||
|
||||
public void run() throws Exception {
|
||||
Bootstrap b = new Bootstrap();
|
||||
ClientBootstrap b = new ClientBootstrap();
|
||||
try {
|
||||
b.group(new NioEventLoopGroup())
|
||||
.channel(new NioSocketChannel())
|
||||
.channel(NioSocketChannel.class)
|
||||
.remoteAddress(host, port)
|
||||
.handler(new LocalTimeClientInitializer());
|
||||
|
||||
|
@ -35,7 +35,7 @@ public class LocalTimeServer {
|
||||
ServerBootstrap b = new ServerBootstrap();
|
||||
try {
|
||||
b.group(new NioEventLoopGroup(), new NioEventLoopGroup())
|
||||
.channel(new NioServerSocketChannel())
|
||||
.channel(NioServerSocketChannel.class)
|
||||
.localAddress(port)
|
||||
.childHandler(new LocalTimeServerInitializer());
|
||||
|
||||
|
@ -15,7 +15,7 @@
|
||||
*/
|
||||
package io.netty.example.objectecho;
|
||||
|
||||
import io.netty.bootstrap.Bootstrap;
|
||||
import io.netty.bootstrap.ClientBootstrap;
|
||||
import io.netty.channel.ChannelInitializer;
|
||||
import io.netty.channel.socket.SocketChannel;
|
||||
import io.netty.channel.socket.nio.NioEventLoopGroup;
|
||||
@ -41,10 +41,10 @@ public class ObjectEchoClient {
|
||||
}
|
||||
|
||||
public void run() throws Exception {
|
||||
Bootstrap b = new Bootstrap();
|
||||
ClientBootstrap b = new ClientBootstrap();
|
||||
try {
|
||||
b.group(new NioEventLoopGroup())
|
||||
.channel(new NioSocketChannel())
|
||||
.channel(NioSocketChannel.class)
|
||||
.remoteAddress(host, port)
|
||||
.handler(new ChannelInitializer<SocketChannel>() {
|
||||
@Override
|
||||
|
@ -40,7 +40,7 @@ public class ObjectEchoServer {
|
||||
ServerBootstrap b = new ServerBootstrap();
|
||||
try {
|
||||
b.group(new NioEventLoopGroup(), new NioEventLoopGroup())
|
||||
.channel(new NioServerSocketChannel())
|
||||
.channel(NioServerSocketChannel.class)
|
||||
.localAddress(port)
|
||||
.childHandler(new ChannelInitializer<SocketChannel>() {
|
||||
@Override
|
||||
|
@ -40,7 +40,7 @@ public class PortUnificationServer {
|
||||
ServerBootstrap b = new ServerBootstrap();
|
||||
try {
|
||||
b.group(new NioEventLoopGroup(), new NioEventLoopGroup())
|
||||
.channel(new NioServerSocketChannel())
|
||||
.channel(NioServerSocketChannel.class)
|
||||
.localAddress(port)
|
||||
.childHandler(new ChannelInitializer<SocketChannel>() {
|
||||
@Override
|
||||
|
@ -40,7 +40,7 @@ public class HexDumpProxy {
|
||||
ServerBootstrap b = new ServerBootstrap();
|
||||
try {
|
||||
b.group(new NioEventLoopGroup(), new NioEventLoopGroup())
|
||||
.channel(new NioServerSocketChannel())
|
||||
.channel(NioServerSocketChannel.class)
|
||||
.localAddress(localPort)
|
||||
.childHandler(new HexDumpProxyInitializer(remoteHost, remotePort));
|
||||
|
||||
|
@ -15,7 +15,7 @@
|
||||
*/
|
||||
package io.netty.example.proxy;
|
||||
|
||||
import io.netty.bootstrap.Bootstrap;
|
||||
import io.netty.bootstrap.ClientBootstrap;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.channel.Channel;
|
||||
import io.netty.channel.ChannelFuture;
|
||||
@ -43,9 +43,9 @@ public class HexDumpProxyFrontendHandler extends ChannelInboundByteHandlerAdapte
|
||||
final Channel inboundChannel = ctx.channel();
|
||||
|
||||
// Start the connection attempt.
|
||||
Bootstrap b = new Bootstrap();
|
||||
ClientBootstrap b = new ClientBootstrap();
|
||||
b.group(inboundChannel.eventLoop())
|
||||
.channel(new NioSocketChannel())
|
||||
.channel(NioSocketChannel.class)
|
||||
.remoteAddress(remoteHost, remotePort)
|
||||
.handler(new HexDumpProxyBackendHandler(inboundChannel));
|
||||
|
||||
|
@ -15,7 +15,7 @@
|
||||
*/
|
||||
package io.netty.example.qotm;
|
||||
|
||||
import io.netty.bootstrap.Bootstrap;
|
||||
import io.netty.bootstrap.ClientBootstrap;
|
||||
import io.netty.buffer.Unpooled;
|
||||
import io.netty.channel.Channel;
|
||||
import io.netty.channel.ChannelOption;
|
||||
@ -41,10 +41,10 @@ public class QuoteOfTheMomentClient {
|
||||
}
|
||||
|
||||
public void run() throws Exception {
|
||||
Bootstrap b = new Bootstrap();
|
||||
ClientBootstrap b = new ClientBootstrap();
|
||||
try {
|
||||
b.group(new NioEventLoopGroup())
|
||||
.channel(new NioDatagramChannel())
|
||||
.channel(NioDatagramChannel.class)
|
||||
.localAddress(new InetSocketAddress(0))
|
||||
.option(ChannelOption.SO_BROADCAST, true)
|
||||
.handler(new QuoteOfTheMomentClientHandler());
|
||||
|
@ -15,7 +15,7 @@
|
||||
*/
|
||||
package io.netty.example.qotm;
|
||||
|
||||
import io.netty.bootstrap.Bootstrap;
|
||||
import io.netty.bootstrap.ClientBootstrap;
|
||||
import io.netty.channel.ChannelOption;
|
||||
import io.netty.channel.socket.nio.NioDatagramChannel;
|
||||
import io.netty.channel.socket.nio.NioEventLoopGroup;
|
||||
@ -37,10 +37,10 @@ public class QuoteOfTheMomentServer {
|
||||
}
|
||||
|
||||
public void run() throws Exception {
|
||||
Bootstrap b = new Bootstrap();
|
||||
ClientBootstrap b = new ClientBootstrap();
|
||||
try {
|
||||
b.group(new NioEventLoopGroup())
|
||||
.channel(new NioDatagramChannel())
|
||||
.channel(NioDatagramChannel.class)
|
||||
.localAddress(new InetSocketAddress(port))
|
||||
.option(ChannelOption.SO_BROADCAST, true)
|
||||
.handler(new QuoteOfTheMomentServerHandler());
|
||||
|
@ -16,6 +16,7 @@
|
||||
package io.netty.example.sctp;
|
||||
|
||||
import io.netty.bootstrap.Bootstrap;
|
||||
import io.netty.bootstrap.ClientBootstrap;
|
||||
import io.netty.channel.ChannelFuture;
|
||||
import io.netty.channel.ChannelInitializer;
|
||||
import io.netty.channel.ChannelOption;
|
||||
@ -51,10 +52,10 @@ public class SctpEchoClient {
|
||||
|
||||
public void run() throws Exception {
|
||||
// Configure the client.
|
||||
Bootstrap b = new Bootstrap();
|
||||
ClientBootstrap b = new ClientBootstrap();
|
||||
try {
|
||||
b.group(new NioEventLoopGroup())
|
||||
.channel(new NioSctpChannel())
|
||||
.channel(NioSctpChannel.class)
|
||||
.option(ChannelOption.SCTP_NODELAY, true)
|
||||
.remoteAddress(new InetSocketAddress(host, port))
|
||||
.handler(new ChannelInitializer<SctpChannel>() {
|
||||
|
@ -45,7 +45,7 @@ public class SctpEchoServer {
|
||||
ServerBootstrap b = new ServerBootstrap();
|
||||
try {
|
||||
b.group(new NioEventLoopGroup(), new NioEventLoopGroup())
|
||||
.channel(new NioSctpServerChannel())
|
||||
.channel(NioSctpServerChannel.class)
|
||||
.option(ChannelOption.SO_BACKLOG, 100)
|
||||
.localAddress(new InetSocketAddress(port))
|
||||
.childOption(ChannelOption.SCTP_NODELAY, true)
|
||||
|
@ -15,7 +15,7 @@
|
||||
*/
|
||||
package io.netty.example.securechat;
|
||||
|
||||
import io.netty.bootstrap.Bootstrap;
|
||||
import io.netty.bootstrap.ClientBootstrap;
|
||||
import io.netty.channel.Channel;
|
||||
import io.netty.channel.ChannelFuture;
|
||||
import io.netty.channel.socket.nio.NioEventLoopGroup;
|
||||
@ -39,10 +39,10 @@ public class SecureChatClient {
|
||||
}
|
||||
|
||||
public void run() throws Exception {
|
||||
Bootstrap b = new Bootstrap();
|
||||
ClientBootstrap b = new ClientBootstrap();
|
||||
try {
|
||||
b.group(new NioEventLoopGroup())
|
||||
.channel(new NioSocketChannel())
|
||||
.channel(NioSocketChannel.class)
|
||||
.remoteAddress(host, port)
|
||||
.handler(new SecureChatClientInitializer());
|
||||
|
||||
|
@ -35,7 +35,7 @@ public class SecureChatServer {
|
||||
ServerBootstrap b = new ServerBootstrap();
|
||||
try {
|
||||
b.group(new NioEventLoopGroup(), new NioEventLoopGroup())
|
||||
.channel(new NioServerSocketChannel())
|
||||
.channel(NioServerSocketChannel.class)
|
||||
.localAddress(port)
|
||||
.childHandler(new SecureChatServerInitializer());
|
||||
|
||||
|
@ -15,7 +15,7 @@
|
||||
*/
|
||||
package io.netty.example.telnet;
|
||||
|
||||
import io.netty.bootstrap.Bootstrap;
|
||||
import io.netty.bootstrap.ClientBootstrap;
|
||||
import io.netty.channel.Channel;
|
||||
import io.netty.channel.ChannelFuture;
|
||||
import io.netty.channel.socket.nio.NioEventLoopGroup;
|
||||
@ -38,10 +38,10 @@ public class TelnetClient {
|
||||
}
|
||||
|
||||
public void run() throws Exception {
|
||||
Bootstrap b = new Bootstrap();
|
||||
ClientBootstrap b = new ClientBootstrap();
|
||||
try {
|
||||
b.group(new NioEventLoopGroup())
|
||||
.channel(new NioSocketChannel())
|
||||
.channel(NioSocketChannel.class)
|
||||
.remoteAddress(host, port)
|
||||
.handler(new TelnetClientInitializer());
|
||||
|
||||
|
@ -34,7 +34,7 @@ public class TelnetServer {
|
||||
ServerBootstrap b = new ServerBootstrap();
|
||||
try {
|
||||
b.group(new NioEventLoopGroup(), new NioEventLoopGroup())
|
||||
.channel(new NioServerSocketChannel())
|
||||
.channel(NioServerSocketChannel.class)
|
||||
.localAddress(port)
|
||||
.childHandler(new TelnetServerPipelineFactory());
|
||||
|
||||
|
@ -15,7 +15,7 @@
|
||||
*/
|
||||
package io.netty.example.uptime;
|
||||
|
||||
import io.netty.bootstrap.Bootstrap;
|
||||
import io.netty.bootstrap.ClientBootstrap;
|
||||
import io.netty.channel.ChannelInitializer;
|
||||
import io.netty.channel.EventLoopGroup;
|
||||
import io.netty.channel.socket.SocketChannel;
|
||||
@ -50,16 +50,16 @@ public class UptimeClient {
|
||||
}
|
||||
|
||||
public void run() {
|
||||
configureBootstrap(new Bootstrap()).connect();
|
||||
configureBootstrap(new ClientBootstrap()).connect();
|
||||
}
|
||||
|
||||
private Bootstrap configureBootstrap(Bootstrap b) {
|
||||
private ClientBootstrap configureBootstrap(ClientBootstrap b) {
|
||||
return configureBootstrap(b, new NioEventLoopGroup());
|
||||
}
|
||||
|
||||
Bootstrap configureBootstrap(Bootstrap b, EventLoopGroup g) {
|
||||
ClientBootstrap configureBootstrap(ClientBootstrap b, EventLoopGroup g) {
|
||||
b.group(g)
|
||||
.channel(new NioSocketChannel())
|
||||
.channel(NioSocketChannel.class)
|
||||
.remoteAddress(host, port)
|
||||
.handler(new ChannelInitializer<SocketChannel>() {
|
||||
@Override
|
||||
|
@ -15,7 +15,7 @@
|
||||
*/
|
||||
package io.netty.example.uptime;
|
||||
|
||||
import io.netty.bootstrap.Bootstrap;
|
||||
import io.netty.bootstrap.ClientBootstrap;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.channel.ChannelHandler.Sharable;
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
@ -84,7 +84,7 @@ public class UptimeClientHandler extends ChannelInboundByteHandlerAdapter {
|
||||
@Override
|
||||
public void run() {
|
||||
println("Reconnecting to: " + ctx.channel().remoteAddress());
|
||||
client.configureBootstrap(new Bootstrap(), loop).connect();
|
||||
client.configureBootstrap(new ClientBootstrap(), loop).connect();
|
||||
}
|
||||
}, UptimeClient.RECONNECT_DELAY, TimeUnit.SECONDS);
|
||||
}
|
||||
|
@ -15,7 +15,7 @@
|
||||
*/
|
||||
package io.netty.testsuite.transport.socket;
|
||||
|
||||
import io.netty.bootstrap.Bootstrap;
|
||||
import io.netty.bootstrap.ClientBootstrap;
|
||||
import io.netty.logging.InternalLogger;
|
||||
import io.netty.logging.InternalLoggerFactory;
|
||||
import io.netty.testsuite.transport.socket.SocketTestPermutation.Factory;
|
||||
@ -32,19 +32,19 @@ import org.junit.rules.TestName;
|
||||
|
||||
public abstract class AbstractClientSocketTest {
|
||||
|
||||
private static final List<Factory<Bootstrap>> COMBO = SocketTestPermutation.clientSocket();
|
||||
private static final List<Factory<ClientBootstrap>> COMBO = SocketTestPermutation.clientSocket();
|
||||
|
||||
@Rule
|
||||
public final TestName testName = new TestName();
|
||||
|
||||
protected final InternalLogger logger = InternalLoggerFactory.getInstance(getClass());
|
||||
|
||||
protected volatile Bootstrap cb;
|
||||
protected volatile ClientBootstrap cb;
|
||||
protected volatile InetSocketAddress addr;
|
||||
|
||||
protected void run() throws Throwable {
|
||||
int i = 0;
|
||||
for (Factory<Bootstrap> e: COMBO) {
|
||||
for (Factory<ClientBootstrap> e: COMBO) {
|
||||
cb = e.newInstance();
|
||||
addr = new InetSocketAddress(
|
||||
NetworkConstants.LOCALHOST, TestUtils.getFreePort());
|
||||
@ -54,7 +54,7 @@ public abstract class AbstractClientSocketTest {
|
||||
"Running: %s %d of %d", testName.getMethodName(), ++ i, COMBO.size()));
|
||||
try {
|
||||
Method m = getClass().getDeclaredMethod(
|
||||
testName.getMethodName(), Bootstrap.class);
|
||||
testName.getMethodName(), ClientBootstrap.class);
|
||||
m.invoke(this, cb);
|
||||
} catch (InvocationTargetException ex) {
|
||||
throw ex.getCause();
|
||||
|
@ -16,6 +16,7 @@
|
||||
package io.netty.testsuite.transport.socket;
|
||||
|
||||
import io.netty.bootstrap.Bootstrap;
|
||||
import io.netty.bootstrap.ClientBootstrap;
|
||||
import io.netty.logging.InternalLogger;
|
||||
import io.netty.logging.InternalLoggerFactory;
|
||||
import io.netty.testsuite.transport.socket.SocketTestPermutation.Factory;
|
||||
@ -33,7 +34,7 @@ import org.junit.rules.TestName;
|
||||
|
||||
public abstract class AbstractDatagramTest {
|
||||
|
||||
private static final List<Entry<Factory<Bootstrap>, Factory<Bootstrap>>> COMBO =
|
||||
private static final List<Entry<Factory<ClientBootstrap>, Factory<ClientBootstrap>>> COMBO =
|
||||
SocketTestPermutation.datagram();
|
||||
|
||||
@Rule
|
||||
@ -41,13 +42,13 @@ public abstract class AbstractDatagramTest {
|
||||
|
||||
protected final InternalLogger logger = InternalLoggerFactory.getInstance(getClass());
|
||||
|
||||
protected volatile Bootstrap sb;
|
||||
protected volatile Bootstrap cb;
|
||||
protected volatile ClientBootstrap sb;
|
||||
protected volatile ClientBootstrap cb;
|
||||
protected volatile InetSocketAddress addr;
|
||||
|
||||
protected void run() throws Throwable {
|
||||
int i = 0;
|
||||
for (Entry<Factory<Bootstrap>, Factory<Bootstrap>> e: COMBO) {
|
||||
for (Entry<Factory<ClientBootstrap>, Factory<ClientBootstrap>> e: COMBO) {
|
||||
sb = e.getKey().newInstance();
|
||||
cb = e.getValue().newInstance();
|
||||
addr = new InetSocketAddress(
|
||||
|
@ -15,7 +15,7 @@
|
||||
*/
|
||||
package io.netty.testsuite.transport.socket;
|
||||
|
||||
import io.netty.bootstrap.Bootstrap;
|
||||
import io.netty.bootstrap.ClientBootstrap;
|
||||
import io.netty.bootstrap.ServerBootstrap;
|
||||
import io.netty.logging.InternalLogger;
|
||||
import io.netty.logging.InternalLoggerFactory;
|
||||
@ -34,7 +34,7 @@ import org.junit.rules.TestName;
|
||||
|
||||
public abstract class AbstractSocketTest {
|
||||
|
||||
private static final List<Entry<Factory<ServerBootstrap>, Factory<Bootstrap>>> COMBO =
|
||||
private static final List<Entry<Factory<ServerBootstrap>, Factory<ClientBootstrap>>> COMBO =
|
||||
SocketTestPermutation.socket();
|
||||
|
||||
@Rule
|
||||
@ -43,13 +43,13 @@ public abstract class AbstractSocketTest {
|
||||
protected final InternalLogger logger = InternalLoggerFactory.getInstance(getClass());
|
||||
|
||||
protected volatile ServerBootstrap sb;
|
||||
protected volatile Bootstrap cb;
|
||||
protected volatile ClientBootstrap cb;
|
||||
protected volatile InetSocketAddress addr;
|
||||
protected volatile Factory<Bootstrap> currentBootstrap;
|
||||
protected volatile Factory<ClientBootstrap> currentBootstrap;
|
||||
|
||||
protected void run() throws Throwable {
|
||||
int i = 0;
|
||||
for (Entry<Factory<ServerBootstrap>, Factory<Bootstrap>> e: COMBO) {
|
||||
for (Entry<Factory<ServerBootstrap>, Factory<ClientBootstrap>> e: COMBO) {
|
||||
currentBootstrap = e.getValue();
|
||||
sb = e.getKey().newInstance();
|
||||
cb = e.getValue().newInstance();
|
||||
@ -62,7 +62,7 @@ public abstract class AbstractSocketTest {
|
||||
"Running: %s %d of %d", testName.getMethodName(), ++ i, COMBO.size()));
|
||||
try {
|
||||
Method m = getClass().getDeclaredMethod(
|
||||
testName.getMethodName(), ServerBootstrap.class, Bootstrap.class);
|
||||
testName.getMethodName(), ServerBootstrap.class, ClientBootstrap.class);
|
||||
m.invoke(this, sb, cb);
|
||||
} catch (InvocationTargetException ex) {
|
||||
throw ex.getCause();
|
||||
|
@ -16,7 +16,7 @@
|
||||
package io.netty.testsuite.transport.socket;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import io.netty.bootstrap.Bootstrap;
|
||||
import io.netty.bootstrap.ClientBootstrap;
|
||||
import io.netty.bootstrap.ServerBootstrap;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.Unpooled;
|
||||
@ -44,7 +44,7 @@ public class SocketEchoTest extends AbstractSocketTest {
|
||||
run();
|
||||
}
|
||||
|
||||
public void testSimpleEcho(ServerBootstrap sb, Bootstrap cb) throws Throwable {
|
||||
public void testSimpleEcho(ServerBootstrap sb, ClientBootstrap cb) throws Throwable {
|
||||
testSimpleEcho0(sb, cb, Integer.MAX_VALUE);
|
||||
}
|
||||
|
||||
@ -53,11 +53,11 @@ public class SocketEchoTest extends AbstractSocketTest {
|
||||
run();
|
||||
}
|
||||
|
||||
public void testSimpleEchoWithBoundedBuffer(ServerBootstrap sb, Bootstrap cb) throws Throwable {
|
||||
public void testSimpleEchoWithBoundedBuffer(ServerBootstrap sb, ClientBootstrap cb) throws Throwable {
|
||||
testSimpleEcho0(sb, cb, 32);
|
||||
}
|
||||
|
||||
private static void testSimpleEcho0(ServerBootstrap sb, Bootstrap cb, int maxInboundBufferSize) throws Throwable {
|
||||
private static void testSimpleEcho0(ServerBootstrap sb, ClientBootstrap cb, int maxInboundBufferSize) throws Throwable {
|
||||
EchoHandler sh = new EchoHandler(maxInboundBufferSize);
|
||||
EchoHandler ch = new EchoHandler(maxInboundBufferSize);
|
||||
|
||||
|
@ -16,7 +16,7 @@
|
||||
package io.netty.testsuite.transport.socket;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import io.netty.bootstrap.Bootstrap;
|
||||
import io.netty.bootstrap.ClientBootstrap;
|
||||
import io.netty.bootstrap.ServerBootstrap;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.Unpooled;
|
||||
@ -47,7 +47,7 @@ public class SocketFixedLengthEchoTest extends AbstractSocketTest {
|
||||
run();
|
||||
}
|
||||
|
||||
public void testFixedLengthEcho(ServerBootstrap sb, Bootstrap cb) throws Throwable {
|
||||
public void testFixedLengthEcho(ServerBootstrap sb, ClientBootstrap cb) throws Throwable {
|
||||
final EchoHandler sh = new EchoHandler();
|
||||
final EchoHandler ch = new EchoHandler();
|
||||
|
||||
|
@ -16,7 +16,7 @@
|
||||
package io.netty.testsuite.transport.socket;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import io.netty.bootstrap.Bootstrap;
|
||||
import io.netty.bootstrap.ClientBootstrap;
|
||||
import io.netty.bootstrap.ServerBootstrap;
|
||||
import io.netty.channel.Channel;
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
@ -55,7 +55,7 @@ public class SocketObjectEchoTest extends AbstractSocketTest {
|
||||
run();
|
||||
}
|
||||
|
||||
public void testObjectEcho(ServerBootstrap sb, Bootstrap cb) throws Throwable {
|
||||
public void testObjectEcho(ServerBootstrap sb, ClientBootstrap cb) throws Throwable {
|
||||
final EchoHandler sh = new EchoHandler();
|
||||
final EchoHandler ch = new EchoHandler();
|
||||
|
||||
|
@ -16,7 +16,7 @@
|
||||
package io.netty.testsuite.transport.socket;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import io.netty.bootstrap.Bootstrap;
|
||||
import io.netty.bootstrap.ClientBootstrap;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.Unpooled;
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
@ -37,7 +37,7 @@ public class SocketShutdownOutputBySelfTest extends AbstractClientSocketTest {
|
||||
run();
|
||||
}
|
||||
|
||||
public void testShutdownOutput(Bootstrap cb) throws Throwable {
|
||||
public void testShutdownOutput(ClientBootstrap cb) throws Throwable {
|
||||
TestHandler h = new TestHandler();
|
||||
ServerSocket ss = new ServerSocket();
|
||||
Socket s = null;
|
||||
|
@ -16,7 +16,7 @@
|
||||
package io.netty.testsuite.transport.socket;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import io.netty.bootstrap.Bootstrap;
|
||||
import io.netty.bootstrap.ClientBootstrap;
|
||||
import io.netty.bootstrap.ServerBootstrap;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.Unpooled;
|
||||
@ -175,7 +175,7 @@ public class SocketSpdyEchoTest extends AbstractSocketTest {
|
||||
}
|
||||
}
|
||||
|
||||
public void testSpdyEcho(ServerBootstrap sb, Bootstrap cb) throws Throwable {
|
||||
public void testSpdyEcho(ServerBootstrap sb, ClientBootstrap cb) throws Throwable {
|
||||
|
||||
ByteBuf frames = createFrames(version);
|
||||
|
||||
|
@ -16,7 +16,7 @@
|
||||
package io.netty.testsuite.transport.socket;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import io.netty.bootstrap.Bootstrap;
|
||||
import io.netty.bootstrap.ClientBootstrap;
|
||||
import io.netty.bootstrap.ServerBootstrap;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.Unpooled;
|
||||
@ -67,7 +67,7 @@ public class SocketSslEchoTest extends AbstractSocketTest {
|
||||
run();
|
||||
}
|
||||
|
||||
public void testSslEcho(ServerBootstrap sb, Bootstrap cb) throws Throwable {
|
||||
public void testSslEcho(ServerBootstrap sb, ClientBootstrap cb) throws Throwable {
|
||||
final EchoHandler sh = new EchoHandler(true);
|
||||
final EchoHandler ch = new EchoHandler(false);
|
||||
|
||||
|
@ -16,7 +16,7 @@
|
||||
package io.netty.testsuite.transport.socket;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import io.netty.bootstrap.Bootstrap;
|
||||
import io.netty.bootstrap.ClientBootstrap;
|
||||
import io.netty.bootstrap.ServerBootstrap;
|
||||
import io.netty.channel.Channel;
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
@ -57,7 +57,7 @@ public class SocketStringEchoTest extends AbstractSocketTest {
|
||||
run();
|
||||
}
|
||||
|
||||
public void testStringEcho(ServerBootstrap sb, Bootstrap cb) throws Throwable {
|
||||
public void testStringEcho(ServerBootstrap sb, ClientBootstrap cb) throws Throwable {
|
||||
final StringEchoHandler sh = new StringEchoHandler();
|
||||
final StringEchoHandler ch = new StringEchoHandler();
|
||||
|
||||
|
@ -15,8 +15,10 @@
|
||||
*/
|
||||
package io.netty.testsuite.transport.socket;
|
||||
|
||||
import io.netty.bootstrap.Bootstrap;
|
||||
import io.netty.bootstrap.Bootstrap.ChannelFactory;
|
||||
import io.netty.bootstrap.ClientBootstrap;
|
||||
import io.netty.bootstrap.ServerBootstrap;
|
||||
import io.netty.channel.Channel;
|
||||
import io.netty.channel.socket.InternetProtocolFamily;
|
||||
import io.netty.channel.socket.aio.AioEventLoopGroup;
|
||||
import io.netty.channel.socket.aio.AioServerSocketChannel;
|
||||
@ -36,34 +38,34 @@ import java.util.Map.Entry;
|
||||
|
||||
final class SocketTestPermutation {
|
||||
|
||||
static List<Entry<Factory<ServerBootstrap>, Factory<Bootstrap>>> socket() {
|
||||
List<Entry<Factory<ServerBootstrap>, Factory<Bootstrap>>> list =
|
||||
new ArrayList<Entry<Factory<ServerBootstrap>, Factory<Bootstrap>>>();
|
||||
static List<Entry<Factory<ServerBootstrap>, Factory<ClientBootstrap>>> socket() {
|
||||
List<Entry<Factory<ServerBootstrap>, Factory<ClientBootstrap>>> list =
|
||||
new ArrayList<Entry<Factory<ServerBootstrap>, Factory<ClientBootstrap>>>();
|
||||
|
||||
// Make the list of ServerBootstrap factories.
|
||||
List<Factory<ServerBootstrap>> sbfs = serverSocket();
|
||||
|
||||
// Make the list of Bootstrap factories.
|
||||
List<Factory<Bootstrap>> cbfs = clientSocket();
|
||||
List<Factory<ClientBootstrap>> cbfs = clientSocket();
|
||||
|
||||
// Populate the combinations
|
||||
for (Factory<ServerBootstrap> sbf: sbfs) {
|
||||
for (Factory<Bootstrap> cbf: cbfs) {
|
||||
for (Factory<ClientBootstrap> cbf: cbfs) {
|
||||
final Factory<ServerBootstrap> sbf0 = sbf;
|
||||
final Factory<Bootstrap> cbf0 = cbf;
|
||||
list.add(new Entry<Factory<ServerBootstrap>, Factory<Bootstrap>>() {
|
||||
final Factory<ClientBootstrap> cbf0 = cbf;
|
||||
list.add(new Entry<Factory<ServerBootstrap>, Factory<ClientBootstrap>>() {
|
||||
@Override
|
||||
public Factory<ServerBootstrap> getKey() {
|
||||
return sbf0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Factory<Bootstrap> getValue() {
|
||||
public Factory<ClientBootstrap> getValue() {
|
||||
return cbf0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Factory<Bootstrap> setValue(Factory<Bootstrap> value) {
|
||||
public Factory<ClientBootstrap> setValue(Factory<ClientBootstrap> value) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
});
|
||||
@ -76,45 +78,49 @@ final class SocketTestPermutation {
|
||||
return list;
|
||||
}
|
||||
|
||||
static List<Entry<Factory<Bootstrap>, Factory<Bootstrap>>> datagram() {
|
||||
List<Entry<Factory<Bootstrap>, Factory<Bootstrap>>> list =
|
||||
new ArrayList<Entry<Factory<Bootstrap>, Factory<Bootstrap>>>();
|
||||
static List<Entry<Factory<ClientBootstrap>, Factory<ClientBootstrap>>> datagram() {
|
||||
List<Entry<Factory<ClientBootstrap>, Factory<ClientBootstrap>>> list =
|
||||
new ArrayList<Entry<Factory<ClientBootstrap>, Factory<ClientBootstrap>>>();
|
||||
|
||||
// Make the list of Bootstrap factories.
|
||||
List<Factory<Bootstrap>> bfs =
|
||||
new ArrayList<Factory<Bootstrap>>();
|
||||
bfs.add(new Factory<Bootstrap>() {
|
||||
List<Factory<ClientBootstrap>> bfs =
|
||||
new ArrayList<Factory<ClientBootstrap>>();
|
||||
bfs.add(new Factory<ClientBootstrap>() {
|
||||
@Override
|
||||
public Bootstrap newInstance() {
|
||||
return new Bootstrap().group(new NioEventLoopGroup()).channel(
|
||||
new NioDatagramChannel(InternetProtocolFamily.IPv4));
|
||||
public ClientBootstrap newInstance() {
|
||||
return new ClientBootstrap().group(new NioEventLoopGroup()).channelFactory(new ChannelFactory() {
|
||||
@Override
|
||||
public Channel newChannel() {
|
||||
return new NioDatagramChannel(InternetProtocolFamily.IPv4);
|
||||
}
|
||||
});
|
||||
bfs.add(new Factory<Bootstrap>() {
|
||||
}
|
||||
});
|
||||
bfs.add(new Factory<ClientBootstrap>() {
|
||||
@Override
|
||||
public Bootstrap newInstance() {
|
||||
return new Bootstrap().group(new OioEventLoopGroup()).channel(new OioDatagramChannel());
|
||||
public ClientBootstrap newInstance() {
|
||||
return new ClientBootstrap().group(new OioEventLoopGroup()).channel(OioDatagramChannel.class);
|
||||
}
|
||||
});
|
||||
|
||||
// Populate the combinations
|
||||
for (Factory<Bootstrap> sbf: bfs) {
|
||||
for (Factory<Bootstrap> cbf: bfs) {
|
||||
final Factory<Bootstrap> sbf0 = sbf;
|
||||
final Factory<Bootstrap> cbf0 = cbf;
|
||||
list.add(new Entry<Factory<Bootstrap>, Factory<Bootstrap>>() {
|
||||
for (Factory<ClientBootstrap> sbf: bfs) {
|
||||
for (Factory<ClientBootstrap> cbf: bfs) {
|
||||
final Factory<ClientBootstrap> sbf0 = sbf;
|
||||
final Factory<ClientBootstrap> cbf0 = cbf;
|
||||
list.add(new Entry<Factory<ClientBootstrap>, Factory<ClientBootstrap>>() {
|
||||
@Override
|
||||
public Factory<Bootstrap> getKey() {
|
||||
public Factory<ClientBootstrap> getKey() {
|
||||
return sbf0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Factory<Bootstrap> getValue() {
|
||||
public Factory<ClientBootstrap> getValue() {
|
||||
return cbf0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Factory<Bootstrap> setValue(Factory<Bootstrap> value) {
|
||||
public Factory<ClientBootstrap> setValue(Factory<ClientBootstrap> value) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
});
|
||||
@ -133,17 +139,21 @@ final class SocketTestPermutation {
|
||||
public ServerBootstrap newInstance() {
|
||||
return new ServerBootstrap().
|
||||
group(new NioEventLoopGroup(), new NioEventLoopGroup()).
|
||||
channel(new NioServerSocketChannel());
|
||||
channel(NioServerSocketChannel.class);
|
||||
}
|
||||
});
|
||||
list.add(new Factory<ServerBootstrap>() {
|
||||
@Override
|
||||
public ServerBootstrap newInstance() {
|
||||
AioEventLoopGroup parentGroup = new AioEventLoopGroup();
|
||||
AioEventLoopGroup childGroup = new AioEventLoopGroup();
|
||||
return new ServerBootstrap().
|
||||
group(parentGroup, childGroup).
|
||||
channel(new AioServerSocketChannel(parentGroup, childGroup));
|
||||
final AioEventLoopGroup parentGroup = new AioEventLoopGroup();
|
||||
final AioEventLoopGroup childGroup = new AioEventLoopGroup();
|
||||
return new ServerBootstrap().group(parentGroup, childGroup).channelFactory(new ChannelFactory() {
|
||||
|
||||
@Override
|
||||
public Channel newChannel() {
|
||||
return new AioServerSocketChannel(parentGroup, childGroup);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
list.add(new Factory<ServerBootstrap>() {
|
||||
@ -151,32 +161,37 @@ final class SocketTestPermutation {
|
||||
public ServerBootstrap newInstance() {
|
||||
return new ServerBootstrap().
|
||||
group(new OioEventLoopGroup(), new OioEventLoopGroup()).
|
||||
channel(new OioServerSocketChannel());
|
||||
channel(OioServerSocketChannel.class);
|
||||
}
|
||||
});
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
static List<Factory<Bootstrap>> clientSocket() {
|
||||
List<Factory<Bootstrap>> list = new ArrayList<Factory<Bootstrap>>();
|
||||
list.add(new Factory<Bootstrap>() {
|
||||
static List<Factory<ClientBootstrap>> clientSocket() {
|
||||
List<Factory<ClientBootstrap>> list = new ArrayList<Factory<ClientBootstrap>>();
|
||||
list.add(new Factory<ClientBootstrap>() {
|
||||
@Override
|
||||
public Bootstrap newInstance() {
|
||||
return new Bootstrap().group(new NioEventLoopGroup()).channel(new NioSocketChannel());
|
||||
public ClientBootstrap newInstance() {
|
||||
return new ClientBootstrap().group(new NioEventLoopGroup()).channel(NioSocketChannel.class);
|
||||
}
|
||||
});
|
||||
list.add(new Factory<Bootstrap>() {
|
||||
list.add(new Factory<ClientBootstrap>() {
|
||||
@Override
|
||||
public Bootstrap newInstance() {
|
||||
AioEventLoopGroup loop = new AioEventLoopGroup();
|
||||
return new Bootstrap().group(loop).channel(new AioSocketChannel(loop));
|
||||
public ClientBootstrap newInstance() {
|
||||
final AioEventLoopGroup loop = new AioEventLoopGroup();
|
||||
return new ClientBootstrap().group(loop).channelFactory(new ChannelFactory() {
|
||||
@Override
|
||||
public Channel newChannel() {
|
||||
return new AioSocketChannel(loop);
|
||||
}
|
||||
});
|
||||
list.add(new Factory<Bootstrap>() {
|
||||
}
|
||||
});
|
||||
list.add(new Factory<ClientBootstrap>() {
|
||||
@Override
|
||||
public Bootstrap newInstance() {
|
||||
return new Bootstrap().group(new OioEventLoopGroup()).channel(new OioSocketChannel());
|
||||
public ClientBootstrap newInstance() {
|
||||
return new ClientBootstrap().group(new OioEventLoopGroup()).channel(OioSocketChannel.class);
|
||||
}
|
||||
});
|
||||
return list;
|
||||
|
@ -118,9 +118,6 @@ public abstract class Bootstrap<B extends Bootstrap<?>> {
|
||||
if (factory == null) {
|
||||
throw new IllegalStateException("factory not set");
|
||||
}
|
||||
if (handler == null) {
|
||||
throw new IllegalStateException("handler not set");
|
||||
}
|
||||
}
|
||||
|
||||
protected final void validate(ChannelFuture future) {
|
||||
|
@ -130,4 +130,12 @@ public class ClientBootstrap extends Bootstrap<ClientBootstrap> {
|
||||
group().register(channel).syncUninterruptibly();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void validate() {
|
||||
super.validate();
|
||||
if (handler() == null) {
|
||||
throw new IllegalStateException("handler not set");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user