Package org.jboss.netty.channel
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
public class SimpleChannelUpstreamHandler extends java.lang.Object implements ChannelUpstreamHandler
AChannelUpstreamHandlerwhich 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 theChannelEventdocumentation.Please use
SimpleChannelHandlerif you need to implement bothChannelUpstreamHandlerandChannelDownstreamHandler.Overriding the
handleUpstreammethodYou can override the
handleUpstreammethod just like overriding an ordinary Java method. Please make sure to callsuper.handleUpstream()so that other handler methods are invoked properly:public class MyChannelHandler extends
SimpleChannelUpstreamHandler{@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 org.jboss.netty.channel.ChannelHandler
ChannelHandler.Sharable
-
-
Field Summary
Fields Modifier and Type Field Description private static InternalLoggerlogger
-
Constructor Summary
Constructors Constructor Description SimpleChannelUpstreamHandler()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidchannelBound(ChannelHandlerContext ctx, ChannelStateEvent e)Invoked when aChannelis open and bound to a local address, but not connected.voidchannelClosed(ChannelHandlerContext ctx, ChannelStateEvent e)Invoked when aChannelwas closed and all its related resources were released.voidchannelConnected(ChannelHandlerContext ctx, ChannelStateEvent e)Invoked when aChannelis open, bound to a local address, and connected to a remote address.voidchannelDisconnected(ChannelHandlerContext ctx, ChannelStateEvent e)Invoked when aChannelwas disconnected from its remote peer.voidchannelInterestChanged(ChannelHandlerContext ctx, ChannelStateEvent e)Invoked when aChannel'sinterestOpswas changed.voidchannelOpen(ChannelHandlerContext ctx, ChannelStateEvent e)Invoked when aChannelis open, but not bound nor connected.voidchannelUnbound(ChannelHandlerContext ctx, ChannelStateEvent e)Invoked when aChannelwas unbound from the current local address.voidchildChannelClosed(ChannelHandlerContext ctx, ChildChannelStateEvent e)Invoked when a childChannelwas closed.voidchildChannelOpen(ChannelHandlerContext ctx, ChildChannelStateEvent e)Invoked when a childChannelwas open.voidexceptionCaught(ChannelHandlerContext ctx, ExceptionEvent e)Invoked when an exception was raised by an I/O thread or aChannelHandler.voidhandleUpstream(ChannelHandlerContext ctx, ChannelEvent e)Handles the specified upstream event.voidmessageReceived(ChannelHandlerContext ctx, MessageEvent e)Invoked when a message object (e.g:ChannelBuffer) was received from a remote peer.voidwriteComplete(ChannelHandlerContext ctx, WriteCompletionEvent e)Invoked when something was written into aChannel.
-
-
-
Field Detail
-
logger
private static final InternalLogger logger
-
-
Method Detail
-
handleUpstream
public void handleUpstream(ChannelHandlerContext ctx, ChannelEvent e) throws java.lang.Exception
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:
java.lang.Exception
-
messageReceived
public void messageReceived(ChannelHandlerContext ctx, MessageEvent e) throws java.lang.Exception
Invoked when a message object (e.g:ChannelBuffer) was received from a remote peer.- Throws:
java.lang.Exception
-
exceptionCaught
public void exceptionCaught(ChannelHandlerContext ctx, ExceptionEvent e) throws java.lang.Exception
Invoked when an exception was raised by an I/O thread or aChannelHandler.- Throws:
java.lang.Exception
-
channelOpen
public void channelOpen(ChannelHandlerContext ctx, ChannelStateEvent e) throws java.lang.Exception
Invoked when aChannelis open, but not bound nor connected.
Be aware that this event is fired from within the I/O thread. You should never execute any heavy operation in there as it will block the dispatching to other workers!- Throws:
java.lang.Exception
-
channelBound
public void channelBound(ChannelHandlerContext ctx, ChannelStateEvent e) throws java.lang.Exception
Invoked when aChannelis open and bound to a local address, but not connected.
Be aware that this event is fired from within the I/O thread. You should never execute any heavy operation in there as it will block the dispatching to other workers!- Throws:
java.lang.Exception
-
channelConnected
public void channelConnected(ChannelHandlerContext ctx, ChannelStateEvent e) throws java.lang.Exception
Invoked when aChannelis open, bound to a local address, and connected to a remote address.
Be aware that this event is fired from within the I/O thread. You should never execute any heavy operation in there as it will block the dispatching to other workers!- Throws:
java.lang.Exception
-
channelInterestChanged
public void channelInterestChanged(ChannelHandlerContext ctx, ChannelStateEvent e) throws java.lang.Exception
Invoked when aChannel'sinterestOpswas changed.- Throws:
java.lang.Exception
-
channelDisconnected
public void channelDisconnected(ChannelHandlerContext ctx, ChannelStateEvent e) throws java.lang.Exception
Invoked when aChannelwas disconnected from its remote peer.- Throws:
java.lang.Exception
-
channelUnbound
public void channelUnbound(ChannelHandlerContext ctx, ChannelStateEvent e) throws java.lang.Exception
Invoked when aChannelwas unbound from the current local address.- Throws:
java.lang.Exception
-
channelClosed
public void channelClosed(ChannelHandlerContext ctx, ChannelStateEvent e) throws java.lang.Exception
Invoked when aChannelwas closed and all its related resources were released.- Throws:
java.lang.Exception
-
writeComplete
public void writeComplete(ChannelHandlerContext ctx, WriteCompletionEvent e) throws java.lang.Exception
Invoked when something was written into aChannel.- Throws:
java.lang.Exception
-
childChannelOpen
public void childChannelOpen(ChannelHandlerContext ctx, ChildChannelStateEvent e) throws java.lang.Exception
Invoked when a childChannelwas open. (e.g. a server channel accepted a connection)- Throws:
java.lang.Exception
-
childChannelClosed
public void childChannelClosed(ChannelHandlerContext ctx, ChildChannelStateEvent e) throws java.lang.Exception
Invoked when a childChannelwas closed. (e.g. the accepted connection was closed)- Throws:
java.lang.Exception
-
-