diff --git a/codec-http/src/test/java/io/netty/handler/codec/spdy/AbstractSocketSpdyEchoTest.java b/codec-http/src/test/java/io/netty/handler/codec/spdy/AbstractSocketSpdyEchoTest.java index f0207c9348..f0e8c228fa 100644 --- a/codec-http/src/test/java/io/netty/handler/codec/spdy/AbstractSocketSpdyEchoTest.java +++ b/codec-http/src/test/java/io/netty/handler/codec/spdy/AbstractSocketSpdyEchoTest.java @@ -190,7 +190,7 @@ public abstract class AbstractSocketSpdyEchoTest { final SpdyEchoTestServerHandler sh = new SpdyEchoTestServerHandler(); final SpdyEchoTestClientHandler ch = new SpdyEchoTestClientHandler(frames); - sb.childInitializer(new ChannelInitializer() { + sb.childHandler(new ChannelInitializer() { @Override public void initChannel(SocketChannel channel) throws Exception { channel.pipeline().addLast( @@ -200,12 +200,7 @@ public abstract class AbstractSocketSpdyEchoTest { } }); - cb.initializer(new ChannelInitializer() { - @Override - public void initChannel(SocketChannel channel) throws Exception { - channel.pipeline().addLast(ch); - } - }); + cb.handler(ch); Channel sc = sb.localAddress(0).bind().sync().channel(); int port = ((InetSocketAddress) sc.localAddress()).getPort(); diff --git a/example/src/main/java/io/netty/example/discard/DiscardClient.java b/example/src/main/java/io/netty/example/discard/DiscardClient.java index 6594d024b2..affdc216d6 100644 --- a/example/src/main/java/io/netty/example/discard/DiscardClient.java +++ b/example/src/main/java/io/netty/example/discard/DiscardClient.java @@ -17,8 +17,6 @@ package io.netty.example.discard; import io.netty.bootstrap.Bootstrap; import io.netty.channel.ChannelFuture; -import io.netty.channel.ChannelInitializer; -import io.netty.channel.socket.SocketChannel; import io.netty.channel.socket.nio.NioEventLoop; import io.netty.channel.socket.nio.NioSocketChannel; @@ -43,12 +41,7 @@ public class DiscardClient { b.eventLoop(new NioEventLoop()) .channel(new NioSocketChannel()) .remoteAddress(host, port) - .initializer(new ChannelInitializer() { - @Override - public void initChannel(SocketChannel ch) throws Exception { - ch.pipeline().addLast(new DiscardClientHandler(firstMessageSize)); - } - }); + .handler(new DiscardClientHandler(firstMessageSize)); // Make the connection attempt. ChannelFuture f = b.connect().sync(); diff --git a/example/src/main/java/io/netty/example/discard/DiscardServer.java b/example/src/main/java/io/netty/example/discard/DiscardServer.java index 707305a600..9a9cd7fe62 100644 --- a/example/src/main/java/io/netty/example/discard/DiscardServer.java +++ b/example/src/main/java/io/netty/example/discard/DiscardServer.java @@ -39,7 +39,7 @@ public class DiscardServer { b.eventLoop(new NioEventLoop(), new NioEventLoop()) .channel(new NioServerSocketChannel()) .localAddress(port) - .childInitializer(new ChannelInitializer() { + .childHandler(new ChannelInitializer() { @Override public void initChannel(SocketChannel ch) throws Exception { ch.pipeline().addLast(new DiscardServerHandler()); diff --git a/example/src/main/java/io/netty/example/echo/EchoClient.java b/example/src/main/java/io/netty/example/echo/EchoClient.java index 7bd14c3a60..17b1f1a9af 100644 --- a/example/src/main/java/io/netty/example/echo/EchoClient.java +++ b/example/src/main/java/io/netty/example/echo/EchoClient.java @@ -51,7 +51,7 @@ public class EchoClient { .channel(new NioSocketChannel()) .option(ChannelOption.TCP_NODELAY, true) .remoteAddress(new InetSocketAddress(host, port)) - .initializer(new ChannelInitializer() { + .handler(new ChannelInitializer() { @Override public void initChannel(SocketChannel ch) throws Exception { ch.pipeline().addLast( diff --git a/example/src/main/java/io/netty/example/echo/EchoServer.java b/example/src/main/java/io/netty/example/echo/EchoServer.java index 58f0f7179d..b94f4050ef 100644 --- a/example/src/main/java/io/netty/example/echo/EchoServer.java +++ b/example/src/main/java/io/netty/example/echo/EchoServer.java @@ -48,13 +48,13 @@ public class EchoServer { .option(ChannelOption.SO_BACKLOG, 100) .localAddress(new InetSocketAddress(port)) .childOption(ChannelOption.TCP_NODELAY, true) - .initializer(new ChannelInitializer() { + .handler(new ChannelInitializer() { @Override public void initChannel(ServerSocketChannel ch) throws Exception { ch.pipeline().addLast(new LoggingHandler(LogLevel.INFO)); } }) - .childInitializer(new ChannelInitializer() { + .childHandler(new ChannelInitializer() { @Override public void initChannel(SocketChannel ch) throws Exception { ch.pipeline().addLast( diff --git a/example/src/main/java/io/netty/example/factorial/FactorialClient.java b/example/src/main/java/io/netty/example/factorial/FactorialClient.java index 9fac78539d..6cb9458398 100644 --- a/example/src/main/java/io/netty/example/factorial/FactorialClient.java +++ b/example/src/main/java/io/netty/example/factorial/FactorialClient.java @@ -42,7 +42,7 @@ public class FactorialClient { b.eventLoop(new NioEventLoop()) .channel(new NioSocketChannel()) .remoteAddress(host, port) - .initializer(new FactorialClientInitializer(count)); + .handler(new FactorialClientInitializer(count)); // Make a new connection. ChannelFuture f = b.connect().sync(); diff --git a/example/src/main/java/io/netty/example/factorial/FactorialServer.java b/example/src/main/java/io/netty/example/factorial/FactorialServer.java index 2cb3dc6e64..328660104d 100644 --- a/example/src/main/java/io/netty/example/factorial/FactorialServer.java +++ b/example/src/main/java/io/netty/example/factorial/FactorialServer.java @@ -37,7 +37,7 @@ public class FactorialServer { b.eventLoop(new NioEventLoop(), new NioEventLoop()) .channel(new NioServerSocketChannel()) .localAddress(port) - .childInitializer(new FactorialServerInitializer()); + .childHandler(new FactorialServerInitializer()); b.bind().sync().channel().closeFuture().sync(); } finally { diff --git a/example/src/main/java/io/netty/example/http/file/HttpStaticFileServer.java b/example/src/main/java/io/netty/example/http/file/HttpStaticFileServer.java index 50e61a0e69..acc6e1ee31 100644 --- a/example/src/main/java/io/netty/example/http/file/HttpStaticFileServer.java +++ b/example/src/main/java/io/netty/example/http/file/HttpStaticFileServer.java @@ -33,7 +33,7 @@ public class HttpStaticFileServer { b.eventLoop(new NioEventLoop(), new NioEventLoop()) .channel(new NioServerSocketChannel()) .localAddress(port) - .childInitializer(new HttpStaticFileServerInitializer()); + .childHandler(new HttpStaticFileServerInitializer()); b.bind().sync().channel().closeFuture().sync(); } finally { diff --git a/example/src/main/java/io/netty/example/http/snoop/HttpSnoopClient.java b/example/src/main/java/io/netty/example/http/snoop/HttpSnoopClient.java index e14a4b3506..fdf28c199a 100644 --- a/example/src/main/java/io/netty/example/http/snoop/HttpSnoopClient.java +++ b/example/src/main/java/io/netty/example/http/snoop/HttpSnoopClient.java @@ -65,7 +65,7 @@ public class HttpSnoopClient { try { b.eventLoop(new NioEventLoop()) .channel(new NioSocketChannel()) - .initializer(new HttpSnoopClientInitializer(ssl)) + .handler(new HttpSnoopClientInitializer(ssl)) .remoteAddress(new InetSocketAddress(host, port)); // Make the connection attempt. diff --git a/example/src/main/java/io/netty/example/http/snoop/HttpSnoopServer.java b/example/src/main/java/io/netty/example/http/snoop/HttpSnoopServer.java index 56a55b0015..e9f4d428b7 100644 --- a/example/src/main/java/io/netty/example/http/snoop/HttpSnoopServer.java +++ b/example/src/main/java/io/netty/example/http/snoop/HttpSnoopServer.java @@ -41,7 +41,7 @@ public class HttpSnoopServer { try { b.eventLoop(new NioEventLoop(), new NioEventLoop()) .channel(new NioServerSocketChannel()) - .childInitializer(new HttpSnoopServerInitializer()) + .childHandler(new HttpSnoopServerInitializer()) .localAddress(new InetSocketAddress(port)); Channel ch = b.bind().sync().channel(); diff --git a/example/src/main/java/io/netty/example/http/websocketx/autobahn/AutobahnServer.java b/example/src/main/java/io/netty/example/http/websocketx/autobahn/AutobahnServer.java index fdc2e1f0bc..3629e7f290 100644 --- a/example/src/main/java/io/netty/example/http/websocketx/autobahn/AutobahnServer.java +++ b/example/src/main/java/io/netty/example/http/websocketx/autobahn/AutobahnServer.java @@ -38,7 +38,7 @@ public class AutobahnServer { b.eventLoop(new NioEventLoop(), new NioEventLoop()) .channel(new NioServerSocketChannel()) .localAddress(port) - .childInitializer(new AutobahnServerInitializer()); + .childHandler(new AutobahnServerInitializer()); ChannelFuture f = b.bind().sync(); System.out.println("Web Socket Server started at port " + port); diff --git a/example/src/main/java/io/netty/example/http/websocketx/client/WebSocketClient.java b/example/src/main/java/io/netty/example/http/websocketx/client/WebSocketClient.java index 5216c8d9f3..e6243e30df 100644 --- a/example/src/main/java/io/netty/example/http/websocketx/client/WebSocketClient.java +++ b/example/src/main/java/io/netty/example/http/websocketx/client/WebSocketClient.java @@ -86,7 +86,7 @@ public class WebSocketClient { b.eventLoop(new NioEventLoop()) .channel(new NioSocketChannel()) .remoteAddress(uri.getHost(), uri.getPort()) - .initializer(new ChannelInitializer() { + .handler(new ChannelInitializer() { @Override public void initChannel(SocketChannel ch) throws Exception { ChannelPipeline pipeline = ch.pipeline(); diff --git a/example/src/main/java/io/netty/example/http/websocketx/server/WebSocketServer.java b/example/src/main/java/io/netty/example/http/websocketx/server/WebSocketServer.java index 2ccd49a2bc..208bbe762f 100644 --- a/example/src/main/java/io/netty/example/http/websocketx/server/WebSocketServer.java +++ b/example/src/main/java/io/netty/example/http/websocketx/server/WebSocketServer.java @@ -53,7 +53,7 @@ public class WebSocketServer { b.eventLoop(new NioEventLoop(), new NioEventLoop()) .channel(new NioServerSocketChannel()) .localAddress(port) - .childInitializer(new WebSocketServerInitializer()); + .childHandler(new WebSocketServerInitializer()); Channel ch = b.bind().sync().channel(); System.out.println("Web socket server started at port " + port + '.'); diff --git a/example/src/main/java/io/netty/example/http/websocketx/sslserver/WebSocketSslServer.java b/example/src/main/java/io/netty/example/http/websocketx/sslserver/WebSocketSslServer.java index 10df32d615..d453b9b223 100644 --- a/example/src/main/java/io/netty/example/http/websocketx/sslserver/WebSocketSslServer.java +++ b/example/src/main/java/io/netty/example/http/websocketx/sslserver/WebSocketSslServer.java @@ -52,7 +52,7 @@ public class WebSocketSslServer { b.eventLoop(new NioEventLoop(), new NioEventLoop()) .channel(new NioServerSocketChannel()) .localAddress(port) - .childInitializer(new WebSocketSslServerInitializer()); + .childHandler(new WebSocketSslServerInitializer()); Channel ch = b.bind().sync().channel(); System.out.println("Web socket server started at port " + port + '.'); diff --git a/example/src/main/java/io/netty/example/localecho/LocalEcho.java b/example/src/main/java/io/netty/example/localecho/LocalEcho.java index 16719e9cd9..cc21bdb2b2 100644 --- a/example/src/main/java/io/netty/example/localecho/LocalEcho.java +++ b/example/src/main/java/io/netty/example/localecho/LocalEcho.java @@ -52,13 +52,13 @@ public class LocalEcho { sb.eventLoop(new LocalEventLoop(), new LocalEventLoop()) .channel(new LocalServerChannel()) .localAddress(addr) - .initializer(new ChannelInitializer() { + .handler(new ChannelInitializer() { @Override public void initChannel(LocalServerChannel ch) throws Exception { ch.pipeline().addLast(new LoggingHandler(LogLevel.INFO)); } }) - .childInitializer(new ChannelInitializer() { + .childHandler(new ChannelInitializer() { @Override public void initChannel(LocalChannel ch) throws Exception { ch.pipeline().addLast( @@ -70,7 +70,7 @@ public class LocalEcho { cb.eventLoop(new NioEventLoop()) .channel(new LocalChannel()) .remoteAddress(addr) - .initializer(new ChannelInitializer() { + .handler(new ChannelInitializer() { @Override public void initChannel(LocalChannel ch) throws Exception { ch.pipeline().addLast( diff --git a/example/src/main/java/io/netty/example/localtime/LocalTimeClient.java b/example/src/main/java/io/netty/example/localtime/LocalTimeClient.java index a57ae96381..401a67df1d 100644 --- a/example/src/main/java/io/netty/example/localtime/LocalTimeClient.java +++ b/example/src/main/java/io/netty/example/localtime/LocalTimeClient.java @@ -48,7 +48,7 @@ public class LocalTimeClient { b.eventLoop(new NioEventLoop()) .channel(new NioSocketChannel()) .remoteAddress(host, port) - .initializer(new LocalTimeClientInitializer()); + .handler(new LocalTimeClientInitializer()); // Make a new connection. Channel ch = b.connect().sync().channel(); diff --git a/example/src/main/java/io/netty/example/localtime/LocalTimeServer.java b/example/src/main/java/io/netty/example/localtime/LocalTimeServer.java index 22c248aeb9..ec9ad2d7f2 100644 --- a/example/src/main/java/io/netty/example/localtime/LocalTimeServer.java +++ b/example/src/main/java/io/netty/example/localtime/LocalTimeServer.java @@ -37,7 +37,7 @@ public class LocalTimeServer { b.eventLoop(new NioEventLoop(), new NioEventLoop()) .channel(new NioServerSocketChannel()) .localAddress(port) - .childInitializer(new LocalTimeServerInitializer()); + .childHandler(new LocalTimeServerInitializer()); b.bind().sync().channel().closeFuture().sync(); diff --git a/example/src/main/java/io/netty/example/objectecho/ObjectEchoClient.java b/example/src/main/java/io/netty/example/objectecho/ObjectEchoClient.java index 47f2e063f9..69e5f82b8e 100644 --- a/example/src/main/java/io/netty/example/objectecho/ObjectEchoClient.java +++ b/example/src/main/java/io/netty/example/objectecho/ObjectEchoClient.java @@ -46,7 +46,7 @@ public class ObjectEchoClient { b.eventLoop(new NioEventLoop()) .channel(new NioSocketChannel()) .remoteAddress(host, port) - .initializer(new ChannelInitializer() { + .handler(new ChannelInitializer() { @Override public void initChannel(SocketChannel ch) throws Exception { ch.pipeline().addLast( diff --git a/example/src/main/java/io/netty/example/objectecho/ObjectEchoServer.java b/example/src/main/java/io/netty/example/objectecho/ObjectEchoServer.java index 9ab36964ef..69c1e4da68 100644 --- a/example/src/main/java/io/netty/example/objectecho/ObjectEchoServer.java +++ b/example/src/main/java/io/netty/example/objectecho/ObjectEchoServer.java @@ -42,7 +42,7 @@ public class ObjectEchoServer { b.eventLoop(new NioEventLoop(), new NioEventLoop()) .channel(new NioServerSocketChannel()) .localAddress(port) - .childInitializer(new ChannelInitializer() { + .childHandler(new ChannelInitializer() { @Override public void initChannel(SocketChannel ch) throws Exception { ch.pipeline().addLast( diff --git a/example/src/main/java/io/netty/example/portunification/PortUnificationServer.java b/example/src/main/java/io/netty/example/portunification/PortUnificationServer.java index 479d42c916..f2ecc32350 100644 --- a/example/src/main/java/io/netty/example/portunification/PortUnificationServer.java +++ b/example/src/main/java/io/netty/example/portunification/PortUnificationServer.java @@ -42,7 +42,7 @@ public class PortUnificationServer { b.eventLoop(new NioEventLoop(), new NioEventLoop()) .channel(new NioServerSocketChannel()) .localAddress(port) - .childInitializer(new ChannelInitializer() { + .childHandler(new ChannelInitializer() { @Override public void initChannel(SocketChannel ch) throws Exception { ch.pipeline().addLast(new PortUnificationServerHandler()); diff --git a/example/src/main/java/io/netty/example/proxy/HexDumpProxy.java b/example/src/main/java/io/netty/example/proxy/HexDumpProxy.java index 317e491970..abf1584d03 100644 --- a/example/src/main/java/io/netty/example/proxy/HexDumpProxy.java +++ b/example/src/main/java/io/netty/example/proxy/HexDumpProxy.java @@ -42,7 +42,7 @@ public class HexDumpProxy { b.eventLoop(new NioEventLoop(), new NioEventLoop()) .channel(new NioServerSocketChannel()) .localAddress(localPort) - .childInitializer(new HexDumpProxyInitializer(remoteHost, remotePort)); + .childHandler(new HexDumpProxyInitializer(remoteHost, remotePort)); b.bind().sync().channel().closeFuture().sync(); } finally { diff --git a/example/src/main/java/io/netty/example/proxy/HexDumpProxyFrontendHandler.java b/example/src/main/java/io/netty/example/proxy/HexDumpProxyFrontendHandler.java index f946669232..a412dc0a09 100644 --- a/example/src/main/java/io/netty/example/proxy/HexDumpProxyFrontendHandler.java +++ b/example/src/main/java/io/netty/example/proxy/HexDumpProxyFrontendHandler.java @@ -22,8 +22,6 @@ import io.netty.channel.ChannelFuture; import io.netty.channel.ChannelFutureListener; import io.netty.channel.ChannelInboundHandlerContext; import io.netty.channel.ChannelInboundStreamHandlerAdapter; -import io.netty.channel.ChannelInitializer; -import io.netty.channel.socket.SocketChannel; import io.netty.channel.socket.nio.NioSocketChannel; public class HexDumpProxyFrontendHandler extends ChannelInboundStreamHandlerAdapter { @@ -49,12 +47,7 @@ public class HexDumpProxyFrontendHandler extends ChannelInboundStreamHandlerAdap b.eventLoop(inboundChannel.eventLoop()) .channel(new NioSocketChannel()) .remoteAddress(remoteHost, remotePort) - .initializer(new ChannelInitializer() { - @Override - public void initChannel(SocketChannel ch) throws Exception { - ch.pipeline().addLast(new HexDumpProxyBackendHandler(inboundChannel)); - } - }); + .handler(new HexDumpProxyBackendHandler(inboundChannel)); ChannelFuture f = b.connect(); outboundChannel = f.channel(); diff --git a/example/src/main/java/io/netty/example/qotm/QuoteOfTheMomentClient.java b/example/src/main/java/io/netty/example/qotm/QuoteOfTheMomentClient.java index d049210890..6ce2e6e56f 100644 --- a/example/src/main/java/io/netty/example/qotm/QuoteOfTheMomentClient.java +++ b/example/src/main/java/io/netty/example/qotm/QuoteOfTheMomentClient.java @@ -18,9 +18,7 @@ package io.netty.example.qotm; import io.netty.bootstrap.Bootstrap; import io.netty.buffer.ChannelBuffers; import io.netty.channel.Channel; -import io.netty.channel.ChannelInitializer; import io.netty.channel.ChannelOption; -import io.netty.channel.socket.DatagramChannel; import io.netty.channel.socket.DatagramPacket; import io.netty.channel.socket.nio.NioDatagramChannel; import io.netty.channel.socket.nio.NioEventLoop; @@ -49,12 +47,7 @@ public class QuoteOfTheMomentClient { .channel(new NioDatagramChannel()) .localAddress(new InetSocketAddress(0)) .option(ChannelOption.SO_BROADCAST, true) - .initializer(new ChannelInitializer() { - @Override - public void initChannel(DatagramChannel ch) throws Exception { - ch.pipeline().addLast(new QuoteOfTheMomentClientHandler()); - } - }); + .handler(new QuoteOfTheMomentClientHandler()); Channel ch = b.bind().sync().channel(); diff --git a/example/src/main/java/io/netty/example/qotm/QuoteOfTheMomentServer.java b/example/src/main/java/io/netty/example/qotm/QuoteOfTheMomentServer.java index 786d5f13a8..691fc505be 100644 --- a/example/src/main/java/io/netty/example/qotm/QuoteOfTheMomentServer.java +++ b/example/src/main/java/io/netty/example/qotm/QuoteOfTheMomentServer.java @@ -16,9 +16,7 @@ package io.netty.example.qotm; import io.netty.bootstrap.Bootstrap; -import io.netty.channel.ChannelInitializer; import io.netty.channel.ChannelOption; -import io.netty.channel.socket.DatagramChannel; import io.netty.channel.socket.nio.NioDatagramChannel; import io.netty.channel.socket.nio.NioEventLoop; @@ -45,12 +43,7 @@ public class QuoteOfTheMomentServer { .channel(new NioDatagramChannel()) .localAddress(new InetSocketAddress(port)) .option(ChannelOption.SO_BROADCAST, true) - .initializer(new ChannelInitializer() { - @Override - public void initChannel(DatagramChannel ch) throws Exception { - ch.pipeline().addLast(new QuoteOfTheMomentServerHandler()); - } - }); + .handler(new QuoteOfTheMomentServerHandler()); b.bind().sync().channel().closeFuture().await(); } finally { diff --git a/example/src/main/java/io/netty/example/securechat/SecureChatClient.java b/example/src/main/java/io/netty/example/securechat/SecureChatClient.java index 84e273d004..e620cfa381 100644 --- a/example/src/main/java/io/netty/example/securechat/SecureChatClient.java +++ b/example/src/main/java/io/netty/example/securechat/SecureChatClient.java @@ -44,7 +44,7 @@ public class SecureChatClient { b.eventLoop(new NioEventLoop()) .channel(new NioSocketChannel()) .remoteAddress(host, port) - .initializer(new SecureChatClientInitializer()); + .handler(new SecureChatClientInitializer()); // Start the connection attempt. Channel ch = b.connect().sync().channel(); diff --git a/example/src/main/java/io/netty/example/securechat/SecureChatServer.java b/example/src/main/java/io/netty/example/securechat/SecureChatServer.java index b95a623482..a77853bf7a 100644 --- a/example/src/main/java/io/netty/example/securechat/SecureChatServer.java +++ b/example/src/main/java/io/netty/example/securechat/SecureChatServer.java @@ -37,7 +37,7 @@ public class SecureChatServer { b.eventLoop(new NioEventLoop(), new NioEventLoop()) .channel(new NioServerSocketChannel()) .localAddress(port) - .childInitializer(new SecureChatServerInitializer()); + .childHandler(new SecureChatServerInitializer()); b.bind().sync().channel().closeFuture().sync(); } finally { diff --git a/example/src/main/java/io/netty/example/telnet/TelnetClient.java b/example/src/main/java/io/netty/example/telnet/TelnetClient.java index f4cae9789b..4044caed4b 100644 --- a/example/src/main/java/io/netty/example/telnet/TelnetClient.java +++ b/example/src/main/java/io/netty/example/telnet/TelnetClient.java @@ -43,7 +43,7 @@ public class TelnetClient { b.eventLoop(new NioEventLoop()) .channel(new NioSocketChannel()) .remoteAddress(host, port) - .initializer(new TelnetClientInitializer()); + .handler(new TelnetClientInitializer()); // Start the connection attempt. Channel ch = b.connect().sync().channel(); diff --git a/example/src/main/java/io/netty/example/telnet/TelnetServer.java b/example/src/main/java/io/netty/example/telnet/TelnetServer.java index dc3cc3eabd..7c9feabced 100644 --- a/example/src/main/java/io/netty/example/telnet/TelnetServer.java +++ b/example/src/main/java/io/netty/example/telnet/TelnetServer.java @@ -36,7 +36,7 @@ public class TelnetServer { b.eventLoop(new NioEventLoop(), new NioEventLoop()) .channel(new NioServerSocketChannel()) .localAddress(port) - .childInitializer(new TelnetServerPipelineFactory()); + .childHandler(new TelnetServerPipelineFactory()); b.bind().sync().channel().closeFuture().sync(); } finally { diff --git a/example/src/main/java/io/netty/example/uptime/UptimeClient.java b/example/src/main/java/io/netty/example/uptime/UptimeClient.java index a041477692..2efc00c6be 100644 --- a/example/src/main/java/io/netty/example/uptime/UptimeClient.java +++ b/example/src/main/java/io/netty/example/uptime/UptimeClient.java @@ -61,7 +61,7 @@ public class UptimeClient { b.eventLoop(l) .channel(new NioSocketChannel()) .remoteAddress(host, port) - .initializer(new ChannelInitializer() { + .handler(new ChannelInitializer() { @Override public void initChannel(SocketChannel ch) throws Exception { ch.pipeline().addLast(new IdleStateHandler(READ_TIMEOUT, 0, 0), handler); diff --git a/transport/src/main/java/io/netty/bootstrap/Bootstrap.java b/transport/src/main/java/io/netty/bootstrap/Bootstrap.java index f11b3753ef..b07d796688 100644 --- a/transport/src/main/java/io/netty/bootstrap/Bootstrap.java +++ b/transport/src/main/java/io/netty/bootstrap/Bootstrap.java @@ -26,7 +26,7 @@ public class Bootstrap { private final Map, Object> options = new LinkedHashMap, Object>(); private EventLoop eventLoop; private Channel channel; - private ChannelHandler initializer; + private ChannelHandler handler; private SocketAddress localAddress; private SocketAddress remoteAddress; @@ -64,11 +64,11 @@ public class Bootstrap { return this; } - public Bootstrap initializer(ChannelHandler initializer) { - if (initializer == null) { - throw new NullPointerException("initializer"); + public Bootstrap handler(ChannelHandler handler) { + if (handler == null) { + throw new NullPointerException("handler"); } - this.initializer = initializer; + this.handler = handler; return this; } @@ -174,7 +174,7 @@ public class Bootstrap { } ChannelPipeline p = channel.pipeline(); - p.addLast(initializer); + p.addLast(handler); for (Entry, Object> e: options.entrySet()) { try { @@ -192,7 +192,7 @@ public class Bootstrap { private static boolean ensureOpen(ChannelFuture future) { if (!future.channel().isOpen()) { // Registration was successful but the channel was closed due to some failure in - // initializer. + // handler. future.setFailure(new ChannelException("initialization failure")); return false; } @@ -212,8 +212,8 @@ public class Bootstrap { if (channel == null) { throw new IllegalStateException("channel not set"); } - if (initializer == null) { - throw new IllegalStateException("initializer not set"); + if (handler == null) { + throw new IllegalStateException("handler not set"); } } diff --git a/transport/src/main/java/io/netty/bootstrap/ServerBootstrap.java b/transport/src/main/java/io/netty/bootstrap/ServerBootstrap.java index 35a43c6fe3..3f2689177b 100644 --- a/transport/src/main/java/io/netty/bootstrap/ServerBootstrap.java +++ b/transport/src/main/java/io/netty/bootstrap/ServerBootstrap.java @@ -44,8 +44,8 @@ public class ServerBootstrap { private EventLoop parentEventLoop; private EventLoop childEventLoop; private ServerChannel channel; - private ChannelHandler initializer; - private ChannelHandler childInitializer; + private ChannelHandler handler; + private ChannelHandler childHandler; private SocketAddress localAddress; public ServerBootstrap eventLoop(EventLoop parentEventLoop, EventLoop childEventLoop) { @@ -95,16 +95,16 @@ public class ServerBootstrap { return this; } - public ServerBootstrap initializer(ChannelHandler initializer) { - this.initializer = initializer; + public ServerBootstrap handler(ChannelHandler handler) { + this.handler = handler; return this; } - public ServerBootstrap childInitializer(ChannelHandler childInitializer) { - if (childInitializer == null) { - throw new NullPointerException("childInitializer"); + public ServerBootstrap childHandler(ChannelHandler childHandler) { + if (childHandler == null) { + throw new NullPointerException("childHandler"); } - this.childInitializer = childInitializer; + this.childHandler = childHandler; return this; } @@ -152,8 +152,8 @@ public class ServerBootstrap { } ChannelPipeline p = channel.pipeline(); - if (initializer != null) { - p.addLast(initializer); + if (handler != null) { + p.addLast(handler); } p.addLast(acceptor); @@ -165,7 +165,7 @@ public class ServerBootstrap { if (!channel.isOpen()) { // Registration was successful but the channel was closed due to some failure in - // initializer. + // handler. future.setFailure(new ChannelException("initialization failure")); return future; } @@ -191,8 +191,8 @@ public class ServerBootstrap { if (channel == null) { throw new IllegalStateException("channel not set"); } - if (childInitializer == null) { - throw new IllegalStateException("childInitializer not set"); + if (childHandler == null) { + throw new IllegalStateException("childHandler not set"); } if (childEventLoop == null) { logger.warn("childEventLoop is not set. Using eventLoop instead."); @@ -230,7 +230,7 @@ public class ServerBootstrap { break; } - child.pipeline().addLast(childInitializer); + child.pipeline().addLast(childHandler); for (Entry, Object> e: childOptions.entrySet()) { try { diff --git a/transport/src/test/java/io/netty/channel/local/LocalChannelRegistryTest.java b/transport/src/test/java/io/netty/channel/local/LocalChannelRegistryTest.java index af257a6ffd..feac631aef 100644 --- a/transport/src/test/java/io/netty/channel/local/LocalChannelRegistryTest.java +++ b/transport/src/test/java/io/netty/channel/local/LocalChannelRegistryTest.java @@ -45,17 +45,12 @@ public class LocalChannelRegistryTest { cb.eventLoop(new LocalEventLoop()) .channel(new LocalChannel()) .remoteAddress(addr) - .initializer(new ChannelInitializer() { - @Override - public void initChannel(LocalChannel ch) throws Exception { - ch.pipeline().addLast(new TestHandler()); - } - }); + .handler(new TestHandler()); sb.eventLoop(new LocalEventLoop(), new LocalEventLoop()) .channel(new LocalServerChannel()) .localAddress(addr) - .childInitializer(new ChannelInitializer() { + .childHandler(new ChannelInitializer() { @Override public void initChannel(LocalChannel ch) throws Exception { ch.pipeline().addLast(new TestHandler()); diff --git a/transport/src/test/java/io/netty/channel/local/LocalTransportThreadModelTest.java b/transport/src/test/java/io/netty/channel/local/LocalTransportThreadModelTest.java index 3f2cc7a4a4..6476b573a3 100644 --- a/transport/src/test/java/io/netty/channel/local/LocalTransportThreadModelTest.java +++ b/transport/src/test/java/io/netty/channel/local/LocalTransportThreadModelTest.java @@ -38,7 +38,7 @@ public class LocalTransportThreadModelTest { sb.eventLoop(new LocalEventLoop(), new LocalEventLoop()) .channel(new LocalServerChannel()) .localAddress(LocalAddress.ANY) - .childInitializer(new ChannelInitializer() { + .childHandler(new ChannelInitializer() { @Override public void initChannel(LocalChannel ch) throws Exception { ch.pipeline().addLast(new ChannelInboundMessageHandlerAdapter() {