
@ChannelPipelineCoverage(value="all") public class ExecutionHandler extends Object implements ChannelUpstreamHandler, ChannelDownstreamHandler, ExternalResourceReleasable
ChannelEvent to an Executor.
You can implement various thread model by adding this handler to a
ChannelPipeline. The most common use case of this handler is to
add a ExecutionHandler which was specified with
OrderedMemoryAwareThreadPoolExecutor:
ChannelPipeline pipeline = ...;
pipeline.addLast("decoder", new MyProtocolDecoder());
pipeline.addLast("encoder", new MyProtocolEncoder());
// HERE
pipeline.addLast("executor", new ExecutionHandler(new OrderedMemoryAwareThreadPoolExecutor(16, 1048576, 1048576)));
pipeline.addLast("handler", new MyBusinessLogicHandler());
to utilize more processors to handle ChannelEvents. You can also
use other Executor implementation than the recommended
OrderedMemoryAwareThreadPoolExecutor.| Constructor and Description |
|---|
ExecutionHandler(Executor executor)
Creates a new instance with the specified
Executor. |
| Modifier and Type | Method and Description |
|---|---|
Executor |
getExecutor()
Returns the
Executor which was specified with the constructor. |
void |
handleDownstream(ChannelHandlerContext ctx,
ChannelEvent e)
Handles the specified downstream event.
|
void |
handleUpstream(ChannelHandlerContext context,
ChannelEvent e)
Handles the specified upstream event.
|
void |
releaseExternalResources()
Shuts down the
Executor which was specified with the constructor
and wait for its termination. |
public ExecutionHandler(Executor executor)
Executor.
Specify an OrderedMemoryAwareThreadPoolExecutor if unsure.public Executor getExecutor()
Executor which was specified with the constructor.public void releaseExternalResources()
Executor which was specified with the constructor
and wait for its termination.releaseExternalResources in interface ExternalResourceReleasablepublic void handleUpstream(ChannelHandlerContext context, ChannelEvent e) throws Exception
ChannelUpstreamHandlerhandleUpstream in interface ChannelUpstreamHandlercontext - the context object for this handlere - the upstream event to process or interceptExceptionpublic void handleDownstream(ChannelHandlerContext ctx, ChannelEvent e) throws Exception
ChannelDownstreamHandlerhandleDownstream in interface ChannelDownstreamHandlerctx - the context object for this handlere - the downstream event to process or interceptExceptionCopyright © 2008-2013 JBoss, by Red Hat. All Rights Reserved.