More javadocs fixes

This commit is contained in:
Norman Maurer 2012-12-19 21:08:47 +01:00
parent db0459ea9c
commit 695665a4cf
2 changed files with 43 additions and 45 deletions

View File

@ -16,14 +16,12 @@
package io.netty.handler.timeout; package io.netty.handler.timeout;
import io.netty.bootstrap.ServerBootstrap; import io.netty.bootstrap.ServerBootstrap;
import io.netty.channel.ChannelHandler; import io.netty.channel.Channel;
import io.netty.channel.ChannelHandlerAdapter;
import io.netty.channel.ChannelHandlerContext; import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelPipeline; import io.netty.channel.ChannelInitializer;
import io.netty.channel.ChannelStateHandlerAdapter; import io.netty.channel.ChannelStateHandlerAdapter;
import io.netty.util.HashedWheelTimer;
import io.netty.util.Timer;
import java.nio.channels.Channels;
import java.util.concurrent.ScheduledFuture; import java.util.concurrent.ScheduledFuture;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
@ -32,39 +30,38 @@ import java.util.concurrent.TimeUnit;
* period of time. * period of time.
* *
* <pre> * <pre>
* public class MyPipelineFactory implements {@link ChannelPipelineFactory} { * // The connection is closed when there is no inbound traffic
* // for 30 seconds.
* *
* private final {@link Timer} timer; * public class MyChannelInitializer extends {@link ChannelInitializer} {
* private final {@link ChannelHandler} timeoutHandler; * public void initChannel({@link Channel} channel) {
* * {@link Channel}.pipeline().addLast("readTimeoutHandler", new {@link ReadTimeoutHandler}(30);
* public MyPipelineFactory({@link Timer} timer) { * {@link Channel}.pipeline().addLast("myHandler", new MyHandler());
* this.timer = timer;
* this.timeoutHandler = <b>new {@link ReadTimeoutHandler}(timer, 30), // timer must be shared.</b>
* } * }
* }
* *
* public {@link ChannelPipeline} getPipeline() { * // Handler should handle the {@link ReadTimeoutException}.
* // An example configuration that implements 30-second read timeout: * public class MyHandler extends {@link ChannelHandlerAdapter} {
* return {@link Channels}.pipeline( * {@code @Override}
* timeoutHandler, * public void exceptionCaught({@link ChannelHandlerContext} ctx, {@link Throwable} cause)
* new MyHandler()); * throws {@link Exception} {
* if (cause instanceof {@link ReadTimeoutException}) {
* // do something
* } else {
* super.exceptionCaught(ctx, cause);
* }
* } * }
* } * }
* *
* {@link ServerBootstrap} bootstrap = ...; * {@link ServerBootstrap} bootstrap = ...;
* {@link Timer} timer = new {@link HashedWheelTimer}();
* ... * ...
* bootstrap.setPipelineFactory(new MyPipelineFactory(timer)); * bootstrap.childHandler(new MyChannelInitializer());
* ... * ...
* </pre> * </pre>
*
* The {@link Timer} which was specified when the {@link ReadTimeoutHandler} is
* created should be stopped manually by calling {@link #releaseExternalResources()}
* or {@link Timer#stop()} when your application shuts down.
* @see WriteTimeoutHandler * @see WriteTimeoutHandler
* @see IdleStateHandler * @see IdleStateHandler
* *
* @apiviz.landmark * @apiviz.landmark
* @apiviz.uses io.netty.util.HashedWheelTimer
* @apiviz.has io.netty.handler.timeout.TimeoutException oneway - - raises * @apiviz.has io.netty.handler.timeout.TimeoutException oneway - - raises
*/ */
public class ReadTimeoutHandler extends ChannelStateHandlerAdapter { public class ReadTimeoutHandler extends ChannelStateHandlerAdapter {

View File

@ -16,15 +16,14 @@
package io.netty.handler.timeout; package io.netty.handler.timeout;
import io.netty.bootstrap.ServerBootstrap; import io.netty.bootstrap.ServerBootstrap;
import io.netty.channel.Channel;
import io.netty.channel.ChannelFuture; import io.netty.channel.ChannelFuture;
import io.netty.channel.ChannelFutureListener; import io.netty.channel.ChannelFutureListener;
import io.netty.channel.ChannelHandlerAdapter;
import io.netty.channel.ChannelHandlerContext; import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelInitializer;
import io.netty.channel.ChannelOperationHandlerAdapter; import io.netty.channel.ChannelOperationHandlerAdapter;
import io.netty.channel.ChannelPipeline;
import io.netty.util.HashedWheelTimer;
import io.netty.util.Timer;
import java.nio.channels.Channels;
import java.util.concurrent.ScheduledFuture; import java.util.concurrent.ScheduledFuture;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
@ -33,36 +32,38 @@ import java.util.concurrent.TimeUnit;
* certain period of time. * certain period of time.
* *
* <pre> * <pre>
* public class MyPipelineFactory implements {@link ChannelPipelineFactory} { * // The connection is closed when there is no outbound traffic
* // for 30 seconds.
* *
* private final {@link Timer} timer; * public class MyChannelInitializer extends {@link ChannelInitializer} {
* * public void initChannel({@link Channel} channel) {
* public MyPipelineFactory({@link Timer} timer) { * {@link Channel}.pipeline().addLast("writeTimeoutHandler", new {@link WriteTimeoutHandler}(30);
* this.timer = timer; * {@link Channel}.pipeline().addLast("myHandler", new MyHandler());
* } * }
* }
* *
* public {@link ChannelPipeline} getPipeline() { * // Handler should handle the {@link WriteTimeoutException}.
* // An example configuration that implements 30-second write timeout: * public class MyHandler extends {@link ChannelHandlerAdapter} {
* return {@link Channels}.pipeline( * {@code @Override}
* <b>new {@link WriteTimeoutHandler}(timer, 30), // timer must be shared.</b> * public void exceptionCaught({@link ChannelHandlerContext} ctx, {@link Throwable} cause)
* new MyHandler()); * throws {@link Exception} {
* if (cause instanceof {@link WriteTimeoutException}) {
* // do something
* } else {
* super.exceptionCaught(ctx, cause);
* }
* } * }
* } * }
* *
* {@link ServerBootstrap} bootstrap = ...; * {@link ServerBootstrap} bootstrap = ...;
* {@link Timer} timer = new {@link HashedWheelTimer}();
* ... * ...
* bootstrap.setPipelineFactory(new MyPipelineFactory(timer)); * bootstrap.childHandler(new MyChannelInitializer());
* ...
* </pre> * </pre>
*
* The {@link Timer} which was specified when the {@link ReadTimeoutHandler} is
* created should be stopped manually by calling {@link #releaseExternalResources()}
* or {@link Timer#stop()} when your application shuts down.
* @see ReadTimeoutHandler * @see ReadTimeoutHandler
* @see IdleStateHandler * @see IdleStateHandler
* *
* @apiviz.landmark * @apiviz.landmark
* @apiviz.uses io.netty.util.HashedWheelTimer
* @apiviz.has io.netty.handler.timeout.TimeoutException oneway - - raises * @apiviz.has io.netty.handler.timeout.TimeoutException oneway - - raises
*/ */
public class WriteTimeoutHandler extends ChannelOperationHandlerAdapter { public class WriteTimeoutHandler extends ChannelOperationHandlerAdapter {