Corrected inconsistencies in the Javadoc.
Port of 80030493b9f7824c02dc88260c2579afc0aed8bc
This commit is contained in:
parent
8afc2cd378
commit
95ff172c82
@ -53,7 +53,7 @@ import java.lang.annotation.Target;
|
|||||||
* {@link ChannelPipeline} it belongs to via a context object. Using the
|
* {@link ChannelPipeline} it belongs to via a context object. Using the
|
||||||
* context object, the {@link ChannelHandler} can pass events upstream or
|
* context object, the {@link ChannelHandler} can pass events upstream or
|
||||||
* downstream, modify the pipeline dynamically, or store the information
|
* downstream, modify the pipeline dynamically, or store the information
|
||||||
* (attachment) which is specific to the handler.
|
* (using {@link AttributeKey}s) which is specific to the handler.
|
||||||
*
|
*
|
||||||
* <h3>State management</h3>
|
* <h3>State management</h3>
|
||||||
*
|
*
|
||||||
@ -69,7 +69,7 @@ import java.lang.annotation.Target;
|
|||||||
* <b>private boolean loggedIn;</b>
|
* <b>private boolean loggedIn;</b>
|
||||||
*
|
*
|
||||||
* {@code @Override}
|
* {@code @Override}
|
||||||
* public void channelRead({@link ChannelHandlerContext} ctx, Message message) {
|
* public void channelRead0({@link ChannelHandlerContext} ctx, Message message) {
|
||||||
* {@link Channel} ch = e.getChannel();
|
* {@link Channel} ch = e.getChannel();
|
||||||
* if (message instanceof LoginMessage) {
|
* if (message instanceof LoginMessage) {
|
||||||
* authenticate((LoginMessage) message);
|
* authenticate((LoginMessage) message);
|
||||||
@ -101,11 +101,11 @@ import java.lang.annotation.Target;
|
|||||||
*
|
*
|
||||||
* </pre>
|
* </pre>
|
||||||
*
|
*
|
||||||
* <h4>Using an attachment</h4>
|
* <h4>Using {@link AttributeKey}</h4>
|
||||||
*
|
*
|
||||||
* Although it's recommended to use member variables to store the state of a
|
* Although it's recommended to use member variables to store the state of a
|
||||||
* handler, for some reason you might not want to create many handler instances.
|
* handler, for some reason you might not want to create many handler instances.
|
||||||
* In such a case, you can use an <em>attachment</em> which is provided by
|
* In such a case, you can use {@link AttributeKey}s which is provided by
|
||||||
* {@link ChannelHandlerContext}:
|
* {@link ChannelHandlerContext}:
|
||||||
* <pre>
|
* <pre>
|
||||||
* public interface Message {
|
* public interface Message {
|
||||||
@ -114,17 +114,12 @@ import java.lang.annotation.Target;
|
|||||||
*
|
*
|
||||||
* {@code @Sharable}
|
* {@code @Sharable}
|
||||||
* public class DataServerHandler extends {@link SimpleChannelInboundHandler}<Message> {
|
* public class DataServerHandler extends {@link SimpleChannelInboundHandler}<Message> {
|
||||||
* private final {@link AttributeKey}<{@link Boolean}> auth =
|
* private final {@link AttributeKey}<{@link Boolean}> auth =
|
||||||
* {@link AttributeKey#valueOf(String) AttributeKey.valueOf("auth")};
|
* {@link AttributeKey#valueOf(String) AttributeKey.valueOf("auth")};
|
||||||
*
|
*
|
||||||
* // This handler will receive a sequence of increasing integers starting
|
|
||||||
* // from 1.
|
|
||||||
* {@code @Override}
|
|
||||||
* public void channelRead({@link ChannelHandlerContext} ctx, {@link Integer} integer) {
|
|
||||||
* {@link Attribute}<{@link Boolean}> attr = ctx.attr(auth);
|
|
||||||
*
|
|
||||||
* {@code @Override}
|
* {@code @Override}
|
||||||
* public void channelRead({@link ChannelHandlerContext} ctx, Message message) {
|
* public void channelRead({@link ChannelHandlerContext} ctx, Message message) {
|
||||||
|
* {@link Attribute}<{@link Boolean}> attr = ctx.attr(auth);
|
||||||
* {@link Channel} ch = ctx.channel();
|
* {@link Channel} ch = ctx.channel();
|
||||||
* if (message instanceof LoginMessage) {
|
* if (message instanceof LoginMessage) {
|
||||||
* authenticate((LoginMessage) o);
|
* authenticate((LoginMessage) o);
|
||||||
@ -140,7 +135,7 @@ import java.lang.annotation.Target;
|
|||||||
* ...
|
* ...
|
||||||
* }
|
* }
|
||||||
* </pre>
|
* </pre>
|
||||||
* Now that the state of the handler is stored as an attachment, you can add the
|
* Now that the state of the handler isattached to the {@link ChannelHandlerContext}, you can add the
|
||||||
* same handler instance to different pipelines:
|
* same handler instance to different pipelines:
|
||||||
* <pre>
|
* <pre>
|
||||||
* public class DataServerInitializer extends {@link ChannelInitializer}<{@link Channel}> {
|
* public class DataServerInitializer extends {@link ChannelInitializer}<{@link Channel}> {
|
||||||
@ -157,7 +152,7 @@ import java.lang.annotation.Target;
|
|||||||
*
|
*
|
||||||
* <h4>The {@code @Sharable} annotation</h4>
|
* <h4>The {@code @Sharable} annotation</h4>
|
||||||
* <p>
|
* <p>
|
||||||
* In the examples above which used an attachment,
|
* In the example above which used an {@link AttributeKey},
|
||||||
* you might have noticed the {@code @Sharable} annotation.
|
* you might have noticed the {@code @Sharable} annotation.
|
||||||
* <p>
|
* <p>
|
||||||
* If a {@link ChannelHandler} is annotated with the {@code @Sharable}
|
* If a {@link ChannelHandler} is annotated with the {@code @Sharable}
|
||||||
|
@ -43,7 +43,7 @@ import java.nio.channels.Channels;
|
|||||||
*
|
*
|
||||||
* You can get the {@link ChannelPipeline} your handler belongs to by calling
|
* You can get the {@link ChannelPipeline} your handler belongs to by calling
|
||||||
* {@link #pipeline()}. A non-trivial application could insert, remove, or
|
* {@link #pipeline()}. A non-trivial application could insert, remove, or
|
||||||
* replace handlers in the pipeline dynamically in runtime.
|
* replace handlers in the pipeline dynamically at runtime.
|
||||||
*
|
*
|
||||||
* <h3>Retrieving for later use</h3>
|
* <h3>Retrieving for later use</h3>
|
||||||
*
|
*
|
||||||
@ -81,7 +81,7 @@ import java.nio.channels.Channels;
|
|||||||
* {@link ChannelHandlerContext}s if it is added to one or more
|
* {@link ChannelHandlerContext}s if it is added to one or more
|
||||||
* {@link ChannelPipeline}s more than once.
|
* {@link ChannelPipeline}s more than once.
|
||||||
* <p>
|
* <p>
|
||||||
* For example, the following handler will have as many independent attachments
|
* For example, the following handler will have as many independent {@link AttributeKey}s
|
||||||
* as how many times it is added to pipelines, regardless if it is added to the
|
* as how many times it is added to pipelines, regardless if it is added to the
|
||||||
* same pipeline multiple times or added to different pipelines multiple times:
|
* same pipeline multiple times or added to different pipelines multiple times:
|
||||||
* <pre>
|
* <pre>
|
||||||
@ -107,7 +107,7 @@ import java.nio.channels.Channels;
|
|||||||
*
|
*
|
||||||
* // Different context objects are given to "f1", "f2", "f3", and "f4" even if
|
* // Different context objects are given to "f1", "f2", "f3", and "f4" even if
|
||||||
* // they refer to the same handler instance. Because the FactorialHandler
|
* // they refer to the same handler instance. Because the FactorialHandler
|
||||||
* // stores its state in a context object (as an attachment), the factorial is
|
* // stores its state in a context object (as an (using an {@link AttributeKey}), the factorial is
|
||||||
* // calculated correctly 4 times once the two pipelines (p1 and p2) are active.
|
* // calculated correctly 4 times once the two pipelines (p1 and p2) are active.
|
||||||
* FactorialHandler fh = new FactorialHandler();
|
* FactorialHandler fh = new FactorialHandler();
|
||||||
*
|
*
|
||||||
|
@ -39,7 +39,7 @@ import io.netty.util.internal.TypeParameterMatcher;
|
|||||||
*
|
*
|
||||||
* <h3>Forward compatibility notice</h3>
|
* <h3>Forward compatibility notice</h3>
|
||||||
* <p>
|
* <p>
|
||||||
* Please keep in mind that {@link #channelRead0(ChannelHandlerContext, Object)} will be renamed to
|
* Please keep in mind that {@link #channelRead0(ChannelHandlerContext, I)} will be renamed to
|
||||||
* {@code messageReceived(ChannelHandlerContext, I)} in 5.0.
|
* {@code messageReceived(ChannelHandlerContext, I)} in 5.0.
|
||||||
* </p>
|
* </p>
|
||||||
*/
|
*/
|
||||||
|
Loading…
Reference in New Issue
Block a user