Observer and Observable are used when one object needs to "observe" or "listen to" changes in another object. The event model is an elaborate implementation of this concept. Basically, an Observable object has an array that stores references to objects impelmenting the "Observer" interface. Since those objects implement Observer, they must have a method called "update". The Observable object "tells" the listening objects that an event took place by running update on each object in the array.
Observable/Observer can be handy, and certainly illustrate an important OO issue. However, coding your own mechanism for storing references to observing objects, and broadcasting events to those objects (by running an interface-specified method on each reference) isn't too hard to code from scratch. It's also not very realistic to think your classes will be able to sub-class Observable becuase they'll already be in your class hierarchy.
An alternative to coding your own mechanism is to have a property be an Observable object. For example, assume you have class Employee with a "name" property. You might want other objects to be able to detect when the employee name changes. To do this you could have a property called "nameChangeObservable". The calling routine would implement Observer (and therefore provide an update method) and do something like:
anEmployee.getNameChangeObservable().addObserver(this);
In the class Employee setName() routine you would verify that the name is changing, then do:
this.getNameChangeObservable().notifyObservers(this);
This results in all observers having their update method run.
Doing the observer/observable thing isn't too easy in a distributed environment. And it may not be relevant. For example, in a
servlet each HTTP request is a-synchonous, so there really is no way to tell each browser that a change has been made to an object they are viewing. As far as I can tell,
EJB doesn't address this either.