Documentation

This commit is contained in:
Trustin Lee 2009-12-29 03:07:20 +00:00
parent a07d24ec3e
commit 55078d87bd
2 changed files with 28 additions and 3 deletions

View File

@ -77,6 +77,31 @@ import java.util.concurrent.ConcurrentMap;
* p2.addLast("f4", fh);
* </pre>
*
* <h3>Retrieving for later use</h3>
*
* You can keep the {@link ChannelHandlerContext} for later use, such as
* triggering an event outside the handler methods, even from a different thread.
* <pre>
* public class MyHandler extends SimpleChannelHandler
* implements LifeCycleAwareChannelHandler {
*
* private ChannelHandlerContex ctx;
*
* public void beforeAdd(ChannelHandlerContext ctx) {
* this.ctx = ctx;
* }
*
* public void messageReceived(ChannelHandlerContext ctx, MessageEvent evt) {
* ctx.setAttachment(evt.getMessage());
* }
*
* public Object getLastReceivedMessage() {
* return ctx.getAttachment();
* }
* ...
* }
* </pre>
*
* <h3>Additional resources worth reading</h3>
* <p>
* Please refer to the {@link ChannelHandler}, {@link ChannelEvent}, and

View File

@ -24,9 +24,9 @@ package org.jboss.netty.channel;
* Calling {@link ChannelHandlerContext#sendUpstream(ChannelEvent)} or
* {@link ChannelHandlerContext#sendDownstream(ChannelEvent)} in
* {@link #beforeAdd(ChannelHandlerContext)} or {@link #afterRemove(ChannelHandlerContext)}
* will lead to an unexpected behavior. It is because the context object has
* not been fully added to the pipeline or the context object is not a part of
* the pipeline anymore respectively.
* might lead to an unexpected behavior. It is because the context object
* might not have been fully added to the pipeline or the context object is not
* a part of the pipeline anymore respectively.
*
* @author The Netty Project (netty-dev@lists.jboss.org)
* @author Trustin Lee (trustin@gmail.com)