org.jboss.netty.channel
Interface ChannelEvent

All Known Subinterfaces:
ChannelStateEvent, ChildChannelStateEvent, ExceptionEvent, IdleStateEvent, MessageEvent, WriteCompletionEvent
All Known Implementing Classes:
DefaultChildChannelStateEvent, DefaultExceptionEvent, DefaultIdleStateEvent, DefaultWriteCompletionEvent, DownstreamChannelStateEvent, DownstreamMessageEvent, UpstreamChannelStateEvent, UpstreamMessageEvent

public interface ChannelEvent

An I/O event or I/O request associated with a Channel.

A ChannelEvent is supposed to be handled by the ChannelPipeline which is attached to the Channel that the event belongs to. Once an event is sent to a ChannelPipeline, it is handled by a list of ChannelHandlers.

Upstream events and downstream events, and their interpretation

Every event is either an upstream event or a downstream event. If an event flows forward from the first handler to the last handler in a ChannelPipeline, we call it an upstream event and say "an event goes upstream." If an event flows backward from the last handler to the first handler in a ChannelPipeline, we call it a downstream event and say "an event goes downstream." (Please refer to the diagram in ChannelPipeline for more explanation.)

A ChannelEvent is interpreted differently by a ChannelHandler depending on whether the event is an upstream event or a downstream event. An upstream event represents the notification of what happened in the past. By contrast, a downstream event represents the request of what should happen in the future. For example, a MessageEvent represents the notification of a received message when it goes upstream, while it represents the request of writing a message when it goes downstream.

Additional resources worth reading

Please refer to the documentation of ChannelHandler and its sub-types (ChannelUpstreamHandler for upstream events and ChannelDownstreamHandler for downstream events) to find out how a ChannelEvent is interpreted depending on the type of the handler more in detail. Also, please refer to the ChannelPipeline documentation to find out how an event flows in a pipeline.

Version:
$Rev: 1706 $, $Date: 2009-09-03 13:33:15 +0900 (목, 03 9 2009) $
Author:
The Netty Project (netty-dev@lists.jboss.org), Trustin Lee (tlee@redhat.com)

Method Summary
 Channel getChannel()
          Returns the Channel which is associated with this event.
 ChannelFuture getFuture()
          Returns the ChannelFuture which is associated with this event.
 

Method Detail

getChannel

Channel getChannel()
Returns the Channel which is associated with this event.


getFuture

ChannelFuture getFuture()
Returns the ChannelFuture which is associated with this event. If this event is an upstream event, this method will always return a SucceededChannelFuture because the event has occurred already. If this event is a downstream event (i.e. I/O request), the returned future will be notified when the I/O request succeeds or fails.



Copyright © 2008-2009 JBoss, by Red Hat. All Rights Reserved.