NAF is an open-source Java API that implements a reactive event-driven framework based on the JDK's NIO interface for non-blocking sockets.
It is distributed under the terms of the GNU Affero General Public License, Version 3 (AGPLv3).
Key features of NAF:
-
NAF supports non-blocking I/O operations (both reads and writes) and timers, enabling you to scale to extremely large numbers of concurrent connections and high data throughput levels.
-
Simple framework for TCP and UDP clients and servers.
Just plug in your application oriented code to process the received data on I/O completion callbacks.
-
NAF provides seamless support for non-blocking I/O on SSL connections as well.
You can easily create client or server SSL connections, with or without client certificates, and you can start the connection in SSL mode, or negotiate the transition to SSL later.
-
NAF provides a lock-free single-threaded execution environment based on the Reactor pattern - parallelism can be provided by adding more Dispatcher threads.
-
You can set up your application in an entirely programmatic manner if you wish, but it can also be automatically constructed and launched via an XML config file, in which you specify the application classes to be instantiated.
-
NAF contains a built-in management agent (NAFMAN) that offers an extensible web-based GUI. This lets you see snapshots of the registered I/O endpoints and timers in real time and you can even kill individual connections.
-
NAF contains a non-blocking asynchronous DNS-Resolver API, allowing you to query for NS, MX, SOA, SRV and TXT records as well as the usual A (hostname-to-IP) and PTR (IP-to-hostname) lookups.
Your code will be called back when the answer is available.
-
NAF also contains a blocking DNS-Resolver API which provides simple access to all the above, for non-NAF applications, ie. applications that are not necessarily built to run within the NAF framework, but simply require a utility API.
-
DNS-Server framework: You provide the backend data-retrieval, but all the DNS protocol exchanges and encoding/decoding is done for you.
-
NAF encourages object reuse and minimises memory churn (ie. garbage generation), thus minimising the need for expensive GC (Garbage Collector) runs.
Along the same lines, it provides Maps and Sets for primitive integers, avoiding the penalty of autoboxing.
-
NAF provides a simple API to common SASL authentication mechanisms - Plain, CRAM-MD5, External
-
NAF is used as the basis for the high-performance mail server,
Mailismus.
The Programmer's Guide and API Reference are included in the download, but can also be viewed online:
• Programmer's Guide
• API Reference
NAF is open source software, distributed under the terms of the
GNU Affero General Public License, version 3 (AGPLv3).
See LICENCE.
See COPYRIGHT.
NAFMAN Start screen |
|
Dispatcher Details screen |
|
|
|
Download
The NAF source code is hosted on GitHub, at
https://github.com/greysoft/naf
You can add the NAF libraries to your project with the following Maven dependency block.
<dependency>
<groupId>com.github.greysoft.naf</groupId>
<artifactId>greynaf</artifactId>
<version>2.5.0</version>
</dependency>
NAF releases are also available as pre-compiled JARs, which can be downloaded
here.