next up previous
Next: But how do you Up: How to Use the Previous: How to Use the

Where's the beef?

The provided event mechanism is broken up into the following parts:

Events:
Events are declared by extending from the Events.Event class. The other parts of the infrastructure know about events and what to do with them when you get them. Events need to have constructors which accept the information associated with the event, and can have any methods needed to observe this data. (Additionally, all events need a default constructor for binding purposes and dependencies in the Event package.)

For an example, see implicitinvocation.OverfullEvent. The actual events are usually quite simple; in order to use an OverfullEvent in the code, you would use something like:

        OverfullEvent oe = new OverfullEvent(section);
        oe.announce();

Event Delivery:
In order to deliver the event announcements, the Delivery class is used. Each ``event / recipient class'' pair needs its own delivery class.

These delivery objects know both about the type of the event and of the method to invoke in the recipient object. This object will only be called with the correct types of objects, but must cast the objects into the correct type before it can use their methods.

With this decoupling, the actual components don't need to know about the events. For example, if something will respond to an OverfullEvent, the component that will deal with it only needs to know what section is full, and should not need to know which event just took place. All knowledge of the event is in the Delivery object.


next up previous
Next: But how do you Up: How to Use the Previous: How to Use the
Tom Conversion Service