Added ChannelHandlerContext.get/setAttachment() - NETTY-134

This commit is contained in:
Trustin Lee 2009-03-11 10:53:52 +00:00
parent f4dd29c70f
commit d2c4a1143e
2 changed files with 12 additions and 0 deletions

View File

@ -95,4 +95,7 @@ public interface ChannelHandlerContext {
* rather than calling this method directly.
*/
void sendDownstream(ChannelEvent e);
Object getAttachment();
void setAttachment(Object attachment);
}

View File

@ -694,6 +694,7 @@ public class DefaultChannelPipeline implements ChannelPipeline {
private final ChannelHandler handler;
private final boolean canHandleUpstream;
private final boolean canHandleDownstream;
private volatile Object attachment;
DefaultChannelHandlerContext(
DefaultChannelHandlerContext prev, DefaultChannelHandlerContext next,
@ -774,6 +775,14 @@ public class DefaultChannelPipeline implements ChannelPipeline {
return name;
}
public Object getAttachment() {
return attachment;
}
public void setAttachment(Object attachment) {
this.attachment = attachment;
}
public void sendDownstream(ChannelEvent e) {
DefaultChannelHandlerContext prev = getActualDownstreamContext(this.prev);
if (prev == null) {