More javadocs cleanup

This commit is contained in:
Norman Maurer 2012-12-21 11:03:35 +01:00
parent e4ed551490
commit 3e31af68e4
5 changed files with 34 additions and 28 deletions

View File

@ -102,21 +102,21 @@ public abstract class AbstractBootstrap<B extends AbstractBootstrap<?>> {
}
/**
* See {@link #localAddress(SocketAddress)}
* @see {@link #localAddress(SocketAddress)}
*/
public B localAddress(int port) {
return localAddress(new InetSocketAddress(port));
}
/**
* See {@link #localAddress(SocketAddress)}
* @see {@link #localAddress(SocketAddress)}
*/
public B localAddress(String host, int port) {
return localAddress(new InetSocketAddress(host, port));
}
/**
* See {@link #localAddress(SocketAddress)}
* @see {@link #localAddress(SocketAddress)}
*/
public B localAddress(InetAddress host, int port) {
return localAddress(new InetSocketAddress(host, port));
@ -249,6 +249,7 @@ public abstract class AbstractBootstrap<B extends AbstractBootstrap<?>> {
return attrs;
}
@Override
public String toString() {
StringBuilder buf = new StringBuilder();
buf.append(getClass().getSimpleName());
@ -308,6 +309,7 @@ public abstract class AbstractBootstrap<B extends AbstractBootstrap<?>> {
}
}
@Override
public String toString() {
return clazz.getSimpleName() + ".class";
}

View File

@ -50,7 +50,7 @@ public class Bootstrap extends AbstractBootstrap<Bootstrap> {
}
/**
* See {@link #remoteAddress(SocketAddress)}
* @see {@link #remoteAddress(SocketAddress)}
*/
public Bootstrap remoteAddress(String host, int port) {
remoteAddress = new InetSocketAddress(host, port);
@ -58,7 +58,7 @@ public class Bootstrap extends AbstractBootstrap<Bootstrap> {
}
/**
* See {@link #remoteAddress(SocketAddress)}
* @see {@link #remoteAddress(SocketAddress)}
*/
public Bootstrap remoteAddress(InetAddress host, int port) {
remoteAddress = new InetSocketAddress(host, port);
@ -96,7 +96,7 @@ public class Bootstrap extends AbstractBootstrap<Bootstrap> {
}
/**
* See {@link #connect()}
* @see {@link #connect()}
*/
public ChannelFuture connect(ChannelFuture future) {
validate(future);
@ -166,6 +166,8 @@ public class Bootstrap extends AbstractBootstrap<Bootstrap> {
/**
* Create a new {@link Bootstrap} which has the identical configuration with this {@link Bootstrap}.
* This method is useful when you make multiple connections with similar settings.
*
* Be aware that if you call {@link #shutdown()} on one of them it will shutdown shared resources.
*/
public Bootstrap duplicate() {
validate();

View File

@ -119,6 +119,10 @@ public class ServerBootstrap extends AbstractBootstrap<ServerBootstrap> {
return this;
}
/**
* Set the specific {@link AttributeKey} with the given value on every child {@link Channel}. If the value is
* {@code null} the {@link AttributeKey} is removed
*/
public <T> ServerBootstrap childAttr(AttributeKey<T> childKey, T value) {
if (childKey == null) {
throw new NullPointerException("childKey");

View File

@ -20,6 +20,7 @@ import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
import io.netty.channel.Channel;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelStateHandlerAdapter;
import io.netty.channel.ServerChannel;
import io.netty.util.CharsetUtil;
@ -75,12 +76,12 @@ import java.util.Set;
* b.releaseExternalResources();
* }
*
* public class MyHandler extends {@link SimpleChannelUpstreamHandler} {
* public class MyHandler extends {@link ChannelStateHandlerAdapter} {
* {@code @Override}
* public void channelOpen({@link ChannelHandlerContext} ctx, {@link ChannelStateEvent} e) {
* // Add all open channels to the global group so that they are
* public void channelActive({@link ChannelHandlerContext} ctx) {
* // closed on shutdown.
* <strong>allChannels.add(e.getChannel());</strong>
* super.channelActive(ctx);
* }
* }
* </pre>

View File

@ -73,29 +73,26 @@ import java.util.concurrent.TimeUnit;
* <pre>
* // BAD - NEVER DO THIS
* {@code @Override}
* public void messageReceived({@link ChannelHandlerContext} ctx, {@link MessageEvent} e) {
* if (e.getMessage() instanceof ShutdownMessage) {
* {@link ChannelGroup} allChannels = MyServer.getAllChannels();
* {@link ChannelGroupFuture} future = allChannels.close();
* future.awaitUninterruptibly();
* // Perform post-shutdown operation
* // ...
* }
* public void messageReceived({@link ChannelHandlerContext} ctx, ShutdownMessage msg) {
* {@link ChannelGroup} allChannels = MyServer.getAllChannels();
* {@link ChannelGroupFuture} future = allChannels.close();
* future.awaitUninterruptibly();
* // Perform post-shutdown operation
* // ...
*
* }
*
* // GOOD
* {@code @Override}
* public void messageReceived(ChannelHandlerContext ctx, MessageEvent e) {
* if (e.getMessage() instanceof ShutdownMessage) {
* {@link ChannelGroup} allChannels = MyServer.getAllChannels();
* {@link ChannelGroupFuture} future = allChannels.close();
* future.addListener(new {@link ChannelGroupFutureListener}() {
* public void operationComplete({@link ChannelGroupFuture} future) {
* // Perform post-closure operation
* // ...
* }
* });
* }
* public void messageReceived(ChannelHandlerContext ctx, ShutdownMessage msg) {
* {@link ChannelGroup} allChannels = MyServer.getAllChannels();
* {@link ChannelGroupFuture} future = allChannels.close();
* future.addListener(new {@link ChannelGroupFutureListener}() {
* public void operationComplete({@link ChannelGroupFuture} future) {
* // Perform post-closure operation
* // ...
* }
* });
* }
* </pre>
* <p>