Raising events

Raising an event is simply a matter of creating an event struct, populating it with data, then calling the event service API to raise the event. The event infrastructure will notify any registered handlers that the event has been raised. An example of how to raise an event is shown below.

Figure 1. Raising an event
import curam.util.events.struct.Event;
  import curam.util.events.impl.EventService;
  curam.util.events.EVENT_CLASS_ONE;

  ...

  Event event = new Event();
  event.eventKey = EVENT_CLASS_ONE.EVENT_TYPE_TWO;
  event.primaryEventData = 12300838;
  event.secondaryEventData = 23413081;

  EventService.raiseEvent(event);
eventKey
This is the unique identifier of the event within the system. It is made up of two constituent parts: the event class and the event type. As mentioned earlier and as shown in the example, though the event key is two parts it is best to specify it using one generated constant to avoid mismatching event classed and types.
eventClass
The class of the event being raised: this is the value on which handlers are registered.
eventType
The type of the event being raised: this identifies the specific type of the event in the given class.
primaryEventData
This is the primary payload of the event and is a 64-bit integer. Typically this will be (though not necessarily) the identifier of an entity in Cúram, the entity in question being identified by the class of the event. The event type is commonly used to indicate the action that has taken place on the entity.
secondaryEventData
This is any additional data that may be associated with an event when it is raised. Unlike the primary event data the secondary event data is optional.