Class SimpleChannelUpstreamHandler
java.lang.Object
org.jboss.netty.channel.SimpleChannelUpstreamHandler
- All Implemented Interfaces:
ChannelHandler, ChannelUpstreamHandler
- Direct Known Subclasses:
AutobahnServerHandler, BlockingReadHandler, DiscardClientHandler, DiscardServerHandler, EchoClientHandler, EchoServerHandler, FactorialClientHandler, FactorialServerHandler, FrameDecoder, HexDumpProxyInboundHandler, HexDumpProxyInboundHandler.OutboundHandler, HttpChunkAggregator, HttpContentDecoder, HttpHelloWorldServerHandler, HttpSnoopClientHandler, HttpSnoopServerHandler, HttpStaticFileServerHandler, HttpTunnelingClientSocketChannel.ServletChannelHandler, HttpTunnelingServlet.OutboundConnectionHandler, HttpUploadClientHandler, HttpUploadServerHandler, IdleStateAwareChannelUpstreamHandler, IdleStateHandler, LocalTimeClientHandler, LocalTimeServerHandler, ObjectEchoClientHandler, ObjectEchoServerHandler, QuoteOfTheMomentClientHandler, QuoteOfTheMomentServerHandler, ReadTimeoutHandler, SecureChatClientHandler, SecureChatServerHandler, ServerBootstrap.Binder, SpdySessionHandler, TelnetClientHandler, TelnetServerHandler, UptimeClientHandler, WebSocketClientHandler, WebSocketServerHandler, WebSocketServerProtocolHandler, WebSocketServerProtocolHandshakeHandler
A Overriding the
ChannelUpstreamHandler which provides an individual handler method
for each event type. This handler down-casts the received upstream event
into more meaningful sub-type event and calls an appropriate handler method
with the down-cast event. The names of the methods are identical to the
upstream event names, as introduced in the ChannelEvent documentation.
Please use SimpleChannelHandler if you need to implement both
ChannelUpstreamHandler and ChannelDownstreamHandler.
Overriding the handleUpstream method
You can override the handleUpstream
method just like overriding an ordinary Java method. Please make sure to
call super.handleUpstream() so that other handler methods are invoked
properly:
public class MyChannelHandler extendsSimpleChannelUpstreamHandler{@Overridepublic void handleUpstream(ChannelHandlerContextctx,ChannelEvente) throws Exception { // Log all channel state changes. if (e instanceofChannelStateEvent) { logger.info("Channel state changed: " + e); } super.handleUpstream(ctx, e); } }
-
Nested Class Summary
Nested classes/interfaces inherited from interface ChannelHandler
ChannelHandler.Sharable -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidInvoked when aChannelis open and bound to a local address, but not connected.voidInvoked when aChannelwas closed and all its related resources were released.voidInvoked when aChannelis open, bound to a local address, and connected to a remote address.voidInvoked when aChannelwas disconnected from its remote peer.voidInvoked when aChannel'sinterestOpswas changed.voidInvoked when aChannelis open, but not bound nor connected.voidInvoked when aChannelwas unbound from the current local address.voidInvoked when a childChannelwas closed.voidInvoked when a childChannelwas open.voidInvoked when an exception was raised by an I/O thread or aChannelHandler.voidHandles the specified upstream event.voidInvoked when a message object (e.g:ChannelBuffer) was received from a remote peer.voidInvoked when something was written into aChannel.
-
Field Details
-
logger
-
-
Constructor Details
-
SimpleChannelUpstreamHandler
public SimpleChannelUpstreamHandler()
-
-
Method Details
-
handleUpstream
Handles the specified upstream event. Down-casts the received upstream event into more meaningful sub-type event and calls an appropriate handler method with the down-casted event.- Specified by:
handleUpstreamin interfaceChannelUpstreamHandler- Parameters:
ctx- the context object for this handlere- the upstream event to process or intercept- Throws:
Exception
-
messageReceived
Invoked when a message object (e.g:ChannelBuffer) was received from a remote peer.- Throws:
Exception
-
exceptionCaught
Invoked when an exception was raised by an I/O thread or aChannelHandler.- Throws:
Exception
-
channelOpen
-
channelBound
-
channelConnected
-
channelInterestChanged
Invoked when aChannel'sinterestOpswas changed.- Throws:
Exception
-
channelDisconnected
-
channelUnbound
-
channelClosed
-
writeComplete
-
childChannelOpen
-
childChannelClosed
public void childChannelClosed(ChannelHandlerContext ctx, ChildChannelStateEvent e) throws Exception Invoked when a childChannelwas closed. (e.g. the accepted connection was closed)- Throws:
Exception
-