About this tutorial
The Java 2 platform enables programmers to think about systems in terms of events, rather than a traditional call-return architectural style. Within the platform itself, there is direct support for several event notification patterns. One way to think about events is through the granularity and ownership of an event. Some event patterns succeed in presenting events at the granularity of a state change in an object instance. Others are more fine-grained and address changes in properties. Still other event techniques must be used to present events that are not necessarily associated with an object instance. Once mastered, event-programming techniques can be applied to user interface programming, service-oriented architectures, and enterprise application integration.
In this tutorial, we'll walk through a variety of event patterns and event delivery techniques that are tailored to specific event granularities. We'll start with relatively simple examples based on direct Java 2 platform classes and APIs, then work through the construction of a distributed event delivery service. By the end of the tutorial, you'll have learned first-hand about the complexities of building a distributed event environment.
This tutorial is intended to guide you through the complexities of event usage on the Java 2 platform. To that end, we'll focus on building event mechanisms from scratch, rather than applying a more user interface-centric approach.
We'll work through various event patterns that deliver different granularities of events. Upon reaching a convenient granularity for building distributed systems, we'll extend the model to a distributed environment. We'll wrap up with a completely different type of event service known as a topic-based event service.
By the time you've completed this tutorial, you will be comfortable with a variety of event patterns and implementations. If you're interested in event mechanisms that are specifically built for user interfaces, you'll likely learn quite a bit from the examples, although we will spend most of our time implementing non-visual, model-centric event mechanisms.
The technologies and techniques we'll use to complete the exercises are as follows:
-
JavaBeans: The JavaBeans technology illustrates many event
patterns, but familiarity with JavaBeans technology is not a requirement
for taking the tutorial. We'll walk through the examples of the important
aspects of JavaBeans with respect to events.
-
Remote Method Invocation (RMI): By the latter half of the tutorial we'll
implement a distributed event service. You need some basic
knowledge of RMI technology to keep up with the example in this section.
-
UML: Class diagrams produced with TogetherJ are used to
illustrate class relationships in each section of the tutorial; you should be able to interpret
these diagrams.
- Design patterns: Several design patterns and idioms are identified in the context of the tutorial, but you need not be an expert on the patterns to follow the examples.
See Resources for a listing of tutorials, articles, and other references that expand upon the material presented in this tutorial.
Code samples and installation requirements
All of the examples in this tutorial were built with the Netbeans development environment. While Netbeans offers first-class support for the JavaBeans event mechanism, any development editor or environment is sufficient to read the code.
It isn't essential that you compile and run the examples, but doing so may assist your learning. Java 2 platform, Standard Edition is required to compile and run the examples. See Resources to download the Java 2 platform.
The binaries and source code for the examples used in this tutorial are available as a downloadable jar file. See Resources to download the file.

