Handling Events

Event categories Events are categorized according to the subject of the event, each distinguished by an int in the icc.net.Event class. These are: UserEvents
    inform of users entering and leaving the system AgentEvents
    inform of delegates entering and leaving the system FileEvents
    inform of the creation, modification and deletion of documents PartnerEvents
    inform of the creation, modification and deletion of partners and teams ProjectEvents
    inform of the creation and modification of projects, and the specifcation of project partners and access rights

Event types A second classification exists according to the type of event, each distinguished by an int in the icc.net.Event class. These are: ENTERS
    occurs when a user or delegate enters the environment, or a partner enters the project LEAVES
    occurs when a user or delegate leaves the environment, or a partner leaves the project CREATION
    occurs when a project, document, partner or team is created DELETION
    occurs when a document, partner or team is deleted EDIT
    occurs when the attributes to a document, partner or team are altered, or when the access rights in a project are changed MODIFICATION
    occurs when the content of a document, or the members in a team are altered

Event information An Event object contains the following information: The event category or genus
    int category = event.genus() The event type
    int type = event.type The content object of the event
    Object content = event.object The address card of the source of the event
    IDCard card = event.source
The source of an event may be null. If the source of an event is not null, this event will not be posted to this source.

1. Implementing an event handler Two methods exist to implement an event handler.

a. Implementing icc.net.EventHandling When a class implements icc.net.EventHandling, it must contain a public method named handleEvent, with an Event as argument and no return value. For example:

public void handleEvent(Event event) {
    switch (event.genus()) {
    case Event.UserEvents:
	break;
    case Event.AgentEvents:
	break;
    case Event.FileEvents:
	break;
    case Event.PartnerEvents:
	break;
    case Event.ProjectEvents:
	break;
    }
}
b. Extending icc.net.EventHandler When a class extends icc.net.EventHandler, it should overwrite one or more of the following methods, as appropriate:
public void handleUserEvent(Event event) {}
public void handleAgentEvent(Event event) {}
public void handleFileEvent(Event event) {}
public void handlePartnerEvent(Event event) {}
public void handleProjectEvent(Event event) {}
public void handleOtherEvent(Event event) {}

2. Registering an event handler By registering itself to a Speaker, an event handler can handle all events known to the speaker for which it has interest. Note that each speaker only accepts one event handler. Thus, the same event handler must handle all events the user may be interested in. To specify its interest in certain categories of events, the event handler must provide the speaker with an int array of the appropriate event categories. For example:
    static final int[] events = {Event.FileEvents,
        Event.PartnerEvents, Event.ProjectEvents}; Then, the event handler class can register itself to the speaker as follows:
    speaker.setEventHandler(this, events); If the event handler is interested in all events, the AllEvents array can be used instead:
    speaker.setEventHandler(this, Event.AllEvents);

3. Handling respective events Examples are provided on how to deal with the different event categories:     User events     Delegate events     Document events     Partner events     Project events

Putting it all together: Handling the events This java source file shows an event handler class, as compiled from the information provided above.

Last updated: 12 June 1999
Please send suggestions, comments and bug reports to tuncer@arch.ethz.ch

This website has been archived and is no longer maintained.