JASF (Java Asynchronous Server
Framework) - A first approach
Overview :
This is a very basic and experimental
framework that help to build asinchronous server applications.
Developers can use it to forget write thread pools, Reactor
handlers and memory management in ours applications.
Structure :
The framework can be viewed as three main
component.
Reactor Manager :
Is the responsible of balance the IOHandlers
registrations on the existing Reactors.
Reactor are implementation of the Reactor dessign pattern.
This handle the service of request that are deliver concurrently
to an application by one or more clients.
The reactor implementation invoke the method defined in the
IOHanler Class.
Event Dispatcher :
Is a simple thread pool that dispatch
the events generated by the IOHanlder.
This can be used by the application to dispatch owns events
or completion events (like a Proactor).
Buffer Pool Manager
:
This facilitates the allocation
and management of a buffer poll related to IO operations (very
incomplete yet).
USE :
To implement a server
you need write three component.
IOHandler: their function
is service the IO event of a selectable channel. When
a channel is ready for some IO operation the reactor
invoke the appropiated method.
If the IOHandler determinate that has receive a request
then create a ProtocolEvent and dispatch it.
Protocol Event. : This event carries
information of the new incomming request and how to
proccess.
ProtocolHandler: This component
handle the request and generate the response (if any).
In the most
cases we contruct a NioServer , then contruct a ProtocolHandler
and this registrate ours IOHandlers.
Sample:
"Micro Minimalistic
Web Server"
MMWS is a very limitated sample of implementing a protocol
whit JASF.
Their only accept the HTTP GET method and service the uri
related filed using MMF (Memory mapped files).
Usage:
Modify the CLASSPATH environment variable to include
directory /Jasf/classes
or the file jasf.jar.
Do java org.aonik.jasf.mmws.Mmws DOCROOT
where DOCROOT is the document root of the site.