Download presentation
1
CCA Event Specification Proposal
Steven Parker
2
Events The essence of events are very simple. Abstract the notion of an occurrence in the system from what should be done when it occurs. So, instead of having a function that is called when something happens, raise the event (hey, this happened), and let the handlers for that event to process that event.
3
Events: Asynchronous Processing
Events don’t have to be asynchronous You can raise an event, and wait for it to be handled if you want Of course, events are most useful when asynchronous processing is supported You raise the event, and return right away. The event handlers fire and complete as they can.
4
Event Contents Every event needs a body
The body contains the information needed to handle the event. For example, changed text in the text box. It is common, but not required to include a reference to the event sender. Also, in some systems, there is a event header and properties More common in distributed systems.
5
Events: Publish-Subscribe Model
One can add the notion of topics, which are named channels on which events are sent and received. To send an event on a topic, you publish that event To receive the events that are sent on a topic, you subscribe to that topic.
6
Event Topics It is often useful to organize topics into an hierarchy.
This organizes the namespace better Also, this allows us to subscribe to topic groups To get all events that are published to topics within that group.
7
Topic Examples In these examples, we use the topic naming scheme espoused by the TIBCO middleware system One could use a URI based scheme, but the idea is the same. Example 1: A simple topic. signals.processExit We have a processExit topic in the signals topic group.
8
Topic Examples Example 2: Another simple topic
workflow.control.exceptions.processExit While the topic has the same name, it is in a different group, therefore, it is different. Example 3: Wildcard topic. signals.* This matches every topic in the signals group (including sub-groups).
9
Topic Wildcards The use of wildcards allows us to subscribe to a whole set of topics at once. Of course, the top-level wildcard topic ‘*’ allows us to receive every event in the system. With some exceptions. More complex matching can be supported Allowing topics like *.signals.*.processExit We disallow this in the first drafts of the spec.
10
CCA Event Specification
Centers on four classes, one interface EventService: Manages the EventService Including global resources, properties, etc. TopicManager: Factory for Topic objects Topics can not be made directly. Topic: Represents a topic Stores properties, allows for events to be raised, event handlers to added, removed.
11
CCA Event Specification
Event: Allows for the creation of an event This includes the event body and a header Event body and header are typemaps EventHandler: Abstract Interface Any actual event handler must implement this interface to receive events.
12
Example (C++ Fragment)
Topic echoTopic = TopicManager.CreateTopic(“services.echo”); echoTopic.AddHandler(“handlerKey1”, new EchoEventHandler()); if (echoTopic != null) { echoTopic.RaiseEvent(new Event(“Hello World”)); } class EchoEventHandler : IEventHandler { void HandleEvent(Object Sender, Event newEvent) cout << newEvent.Body(); }
13
Outstanding concerns (BenGripestm)
Strings for event topics is less efficient than classes Much easier for the user Allows more flexible wildcarding Avoids explosion of tiny classes Conscious tradeoff Potential solutions: Make wildcarding optional? Assume events not performance critical
14
Outstanding concerns (BenGripestm)
Typemap payload is inefficient Must copy to avoid hijacking by component listeners Solution: Fix typemap by adding immutable tags (freeze/thaw)
15
Outstanding concerns (BenGripestm)
Event payload is cumbersome Inconvenient to get common data from typemaps Event payload has component strings instead of component pointers (typemap cannot hold objects) Solutions: Fix typemap by allowing objects Add convenience methods for common values in Event interface
16
Outstanding concerns (BenGripestm)
No scoping considered Solution: Please give us use cases
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.