Motivation: Being able to access the invoker() is useful when adding additional handlers that should be running in the same thread. Since an application may be using a threading model unsupported by the default invoker, they can specify their own. Because of that, in a handler that auto-adds other handlers: // This is a good pattern ctx.pipeline().addBefore(ctx.invoker(), ctx.name(), null, newHandler); // This will generally work, but prevents using custom invoker. ctx.pipeline().addBefore(ctx.executor(), ctx.name(), null, newHandler); That's why I believe in commit 110745b0, for the now-defunct 5.0 branch, when ChannelHandlerAppender was added the invoker() method was also necessary. There is a side-benefit to exposing the invoker: in certain advanced use-cases using the invoker for a particular handler is useful. Using the invoker you are able to invoke a _particular_ handler, from possibly a different thread yet still using standard exception processing. ChannelHandlerContext does part of that, but is unwieldy when trying to invoke a particular handler because it invokes the prev or next handler, not the one the context is for. A workaround is to use the next or prev context (respectively), but this breaks when the pipeline changes. This came up during writing the Http2MultiplexCodec which uses a separate child channel for each http/2 stream and wants to send messages from the child channel directly to the Http2MultiplexCodec handler that created it. Modifications: Add the invoker() method to ChannelHandlerContext. It was already being implemented by AbstractChannelHandlerContext. The two other implementations of ChannelHandlerContext needed minor tweaks. Result: Access to the invoker used for a particular handler, for either reusing for other handlers or for advanced use-cases. Fixes #4738
Netty Project
Netty is an asynchronous event-driven network application framework for rapid development of maintainable high performance protocol servers & clients.
Links
How to build
For the detailed information about building and developing Netty, please visit the developer guide. This page only gives very basic information.
You require the following to build Netty:
- Latest stable Oracle JDK 7
- Latest stable Apache Maven
- If you are on Linux, you need additional development packages installed on your system, because you'll build the native transport.
Note that this is build-time requirement. JDK 5 (for 3.x) or 6 (for 4.0+) is enough to run your Netty-based application.
Branches to look
The 'master' branch is where the development of the latest major version lives on. The development of all other versions takes place in each branch whose name is identical to <majorVersion>.<minorVersion>
. For example, the development of 3.9 and 4.0 resides in the branch '3.9' and the branch '4.0' respectively.