Java Events Framework

The Java Events Framework is designed to help java developers use event-driven strategies in their applications with a minimum of fuss while retaining maximum control and flexibility.

With the aid of this easy-to-use framework any class can easily become an event source (provider) or target (consumer/listener/handler)... or both.

This allows for easy communications between objects in an application on a One-to-One, One-to-Many, Many-to-One or Many-to-Many basis.

The developer of the 'source' of the events has full control to choose a threading and priority dispatching model that ensures correct functionality of the application as intended. And a different threading model can be used for each event that is generated.

For example, suppose we have a MousePointer class (source) that generates events when a pointer is MOVED and when it is CLICKED. Several objects may wish to be notified of these events (listeners/handlers). But computing resources may be inadequate for all the listeners to process all the MOVE events that the MousePointer class dispatches.

The developer of the MousePointer class can therefore determine that it may not be critical to his application, for the event-listeners to obtain every single updated notification of the movement of the pointer. It may be sufficient (and indeed desirable) to rather receive updates of this type of event (MOVE) no more than 3 or 4 times per second. Thus the developer can easily designate the event dispatching mechanism for this event to run on a separate thread and dispatch updates at a suitable priority level asynchronously. Using this model, only the last (MOVE) event generated before the dispatcher notifies the listeners will be received by the handlers (some 'non-critical' events will be discarded).

On the other hand, the developer may decide that it is critical that every CLICK event be dispatched to its registered listeners. So he can either designate the event dispatching mechanism for this event to run on the same thread as the source object, dispatching the event synchronously (but 'holding-up' execution of the application until all registered listeners have been notified). Or he can still choose to have this type of event dispatched asynchronously on a separate thread but he can make use of an 'event-queue' capability that is built into the framework. This will ensure that although the (CLICK) events may be received by the handlers with a slight delay, depending on the chosen thread update priority level setting; all (CLICK) events will be received by all the registered listeners and no events will be discarded.

Visit the project's Wiki for a brief tutorial with a sample, based on the above discussion.

The source code can be dowloaded from the project's Downloads section and contains full Javadoc documentation of the framework's API.