diff --git a/src/main/java/org/jboss/netty/handler/execution/ExecutionHandler.java b/src/main/java/org/jboss/netty/handler/execution/ExecutionHandler.java index c7edd7edfb..9a99bc036a 100644 --- a/src/main/java/org/jboss/netty/handler/execution/ExecutionHandler.java +++ b/src/main/java/org/jboss/netty/handler/execution/ExecutionHandler.java @@ -29,6 +29,7 @@ import org.jboss.netty.channel.ChannelHandlerContext; import org.jboss.netty.channel.ChannelPipeline; import org.jboss.netty.channel.ChannelPipelineCoverage; import org.jboss.netty.channel.ChannelUpstreamHandler; +import org.jboss.netty.util.ExecutorShutdownUtil; /** * Forwards an upstream {@link ChannelEvent} to an {@link Executor}. @@ -77,10 +78,18 @@ public class ExecutionHandler implements ChannelUpstreamHandler { /** * Returns the {@link Executor} which was specified with the constructor. */ - public final Executor getExecutor() { + public Executor getExecutor() { return executor; } + /** + * Shuts down the {@link Executor} which was specified with the constructor + * and wait for its termination. + */ + public void terminateExecutor() { + ExecutorShutdownUtil.shutdown(getExecutor()); + } + public void handleUpstream( ChannelHandlerContext context, ChannelEvent e) throws Exception { executor.execute(new ChannelEventRunnable(context, e));