|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.jboss.netty.channel.SimpleChannelUpstreamHandler
org.jboss.netty.handler.timeout.ReadTimeoutHandler
public class ReadTimeoutHandler
Raises a ReadTimeoutException when no data was read within a certain
period of time.
public class MyPipelineFactory implementsTheChannelPipelineFactory{ private finalTimertimer; public MyPipelineFactory(Timertimer) { this.timer = timer; } publicChannelPipelinegetPipeline() { // An example configuration that implements 30-second read timeout: returnChannels.pipeline( newReadTimeoutHandler(timer, 30), // timer must be shared. new MyHandler()); } }ServerBootstrapbootstrap = ...;Timertimer = newHashedWheelTimer(); ... bootstrap.setPipelineFactory(new MyPipelineFactory(timer)); ...
Timer which was specified when the ReadTimeoutHandler is
created should be stopped manually by calling releaseExternalResources()
or Timer.stop() when your application shuts down.
WriteTimeoutHandler,
IdleStateHandler| Nested Class Summary |
|---|
| Nested classes/interfaces inherited from interface org.jboss.netty.channel.ChannelHandler |
|---|
ChannelHandler.Sharable |
| Constructor Summary | |
|---|---|
ReadTimeoutHandler(Timer timer,
int timeoutSeconds)
Creates a new instance. |
|
ReadTimeoutHandler(Timer timer,
long timeout,
java.util.concurrent.TimeUnit unit)
Creates a new instance. |
|
| Method Summary | |
|---|---|
void |
afterAdd(ChannelHandlerContext ctx)
|
void |
afterRemove(ChannelHandlerContext ctx)
|
void |
beforeAdd(ChannelHandlerContext ctx)
|
void |
beforeRemove(ChannelHandlerContext ctx)
|
void |
channelClosed(ChannelHandlerContext ctx,
ChannelStateEvent e)
Invoked when a Channel was closed and all its related resources
were released. |
void |
channelOpen(ChannelHandlerContext ctx,
ChannelStateEvent e)
Invoked when a Channel is open, but not bound nor connected. |
void |
messageReceived(ChannelHandlerContext ctx,
MessageEvent e)
Invoked when a message object (e.g: ChannelBuffer) was received
from a remote peer. |
protected void |
readTimedOut(ChannelHandlerContext ctx)
|
void |
releaseExternalResources()
Stops the Timer which was specified in the constructor of this
handler. |
| Methods inherited from class org.jboss.netty.channel.SimpleChannelUpstreamHandler |
|---|
channelBound, channelConnected, channelDisconnected, channelInterestChanged, channelUnbound, childChannelClosed, childChannelOpen, exceptionCaught, handleUpstream, writeComplete |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public ReadTimeoutHandler(Timer timer,
int timeoutSeconds)
timer - the Timer that is used to trigger the scheduled event.
The recommended Timer implementation is HashedWheelTimer.timeoutSeconds - read timeout in seconds
public ReadTimeoutHandler(Timer timer,
long timeout,
java.util.concurrent.TimeUnit unit)
timer - the Timer that is used to trigger the scheduled event.
The recommended Timer implementation is HashedWheelTimer.timeout - read timeoutunit - the TimeUnit of timeout| Method Detail |
|---|
public void releaseExternalResources()
Timer which was specified in the constructor of this
handler. You should not call this method if the Timer is in use
by other objects.
releaseExternalResources in interface ExternalResourceReleasable
public void beforeAdd(ChannelHandlerContext ctx)
throws java.lang.Exception
beforeAdd in interface LifeCycleAwareChannelHandlerjava.lang.Exception
public void afterAdd(ChannelHandlerContext ctx)
throws java.lang.Exception
afterAdd in interface LifeCycleAwareChannelHandlerjava.lang.Exception
public void beforeRemove(ChannelHandlerContext ctx)
throws java.lang.Exception
beforeRemove in interface LifeCycleAwareChannelHandlerjava.lang.Exception
public void afterRemove(ChannelHandlerContext ctx)
throws java.lang.Exception
afterRemove in interface LifeCycleAwareChannelHandlerjava.lang.Exception
public void channelOpen(ChannelHandlerContext ctx,
ChannelStateEvent e)
throws java.lang.Exception
SimpleChannelUpstreamHandlerChannel is open, but not bound nor connected.
channelOpen in class SimpleChannelUpstreamHandlerjava.lang.Exception
public void channelClosed(ChannelHandlerContext ctx,
ChannelStateEvent e)
throws java.lang.Exception
SimpleChannelUpstreamHandlerChannel was closed and all its related resources
were released.
channelClosed in class SimpleChannelUpstreamHandlerjava.lang.Exception
public void messageReceived(ChannelHandlerContext ctx,
MessageEvent e)
throws java.lang.Exception
SimpleChannelUpstreamHandlerChannelBuffer) was received
from a remote peer.
messageReceived in class SimpleChannelUpstreamHandlerjava.lang.Exception
protected void readTimedOut(ChannelHandlerContext ctx)
throws java.lang.Exception
java.lang.Exception
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||