moin event framework november 2007. © sap 2007 / page 2 moin event framework event framework - what...
Post on 05-Apr-2015
107 Views
Preview:
TRANSCRIPT
MOIN Event Framework
November 2007
© SAP 2007 / Page 2
MOIN Event Framework
Event Framework - What is it? Sends events when model instances change Sends events upon partition based incidents (e.g. sync)
Key Benefit: Performance Avoids polling for model changes Avoids “diff” calculations of model state
© SAP 2007 / Page 3
MOIN Event Framework
Use Case Scenarios Model Editing Tools
Tools need to update UI for changed elements Tool can refresh the UI upon changes in partitions (e.g. sync)
Model Transformation Re-Transformation only needed for changed source elements (Basis for incremental
builds)
OCL Impact Analysis Impact analysis uses events to determine minimum set of constraints to be checked
© SAP 2007 / Page 4
MOIN Event Framework - Classification
Event Classification Model Change Events
Notify about elements and links
Partition Events Notify about changes of partitions Partition events do NOT carry information about the CONTENT of the partition
ChangeEvent
ModelChangeEvent PartitionChangeEvent
© SAP 2007 / Page 5
Model Change Events Element Life-time
ElementCreateEvent ElementDeleteEvent
Element State AttributeValueChangeEvent Events for attributes with cardinality greater than 1
– AttributeValueAddEvent– AttributeValueRemoveEvent
Link Life-time LinkAddEvent LinkRemoveEvent
MOIN Event Framework - Classification
CEO-Name = “Henning”
CEO-Name = “Leo”
Board-Names:“Hasso”
“Henning”“Leo”
Board-Names:“Henning”
“Leo”
Hasso
ExecutiveBoard
SupervisoryBoard
© SAP 2007 / Page 6
MOIN Event Framework - Classification
Model Change Events
ElementChangeEvent
ModelChangeEvent
AttributeValueEvent ElementLifeCycleEvent
AttributeMultiValueEventAttributeValueChangeEvent ElementCreateEvent ElementDeleteEvent
AttributeValueAddEventAttributeValueRemoveEvent
© SAP 2007 / Page 7
MOIN Event Framework - Classification
Partition Events PartitionCreateEvent PartitionContentChangeEvent
Raised after a “save” or “sync” operation Indicates potential changes in the content of a
partition PartitionDeleteEvent PartitionSaveEvent
PartitionChangeEvent
ChangeEvent
PartitionCreateEvent PartitionContentChangeEvent ParitionDeleteEvent PartitionSaveEvent PartitionPropertyChangeEvent
PartitionPropertyChangeEvent Raised after “check-out”, “check-in”, “sync-to-
revision” Supported properties
– WRITABLE_STATE– CAN_BE_CHECKED_OUT– VERSION– VERSIONED_STATE
© SAP 2007 / Page 8
MOIN Event Framework - Registration
Client Side Event Notification Implement interface “UpdateListener”
void notifyUpdate(EventChain events)
Obtain event registry connection.getEventRegistry()
Register listener and provide event filter (see next slide) registry.registerUpdateListener(listener, filter)
The implementation of notifyUpdate() will be called after completion of each Command executed in the Connection’s Session (connection.getSession())
© SAP 2007 / Page 9
MOIN Event Framework - Registration
Deregistration of event listeners Obtain event registry
connection.getEventRegistry()
Deregister listener registry.deregister(listener)
Listeners are automatically deregistered on “connection.close()”
Event registration participates in the CommandStack’s “undo/redo” handling
© SAP 2007 / Page 10
MOIN Event Framework - Filtering
Event Filtering Assumption:
Event listeners need a small specific subset of all available events
Brute Force Approach:Listeners receive all events and ignore the irrelevant ones
Multiple event listeners might need similar subsets Event filtering code will be performed by every listener
MOIN Approach:Proactive event filtering by the framework
© SAP 2007 / Page 11
MOIN Event Framework - Filtering
Event Filtering Framework Listeners specify the needed events via the “Event Filter Language” Basic elements of the “Event Filter Language” (See JavaDoc for details)
“Global” filters– EventTypeFilter– ContainerFilter– ConnectionFilter– SessionFilter– PartitionFilter
Element related filters (ModelChangeEvents)– InstanceFilter– CompositionHierarchyFilter– ClassFilter– AttributeFilter– PackageFilter– AssociationFilter
© SAP 2007 / Page 12
MOIN Event Framework - Filtering
Event Filtering Framework Basic elements can be composed powerful filter expressions via
OR operation (2 or more operands allowed) AND operation (2 or more operands allowed) NOT operation
Examples I want to be notified about the creation of instances of type MyClassEventTypeFilter(ElementCreateEvent) AND ClassFilter(MyClass)
I want to get notified when a new link of type MyAssoc is created which affects the instance MyInstanceEventTypeFilter(LinkAddEvent) AND AssociationFilter(MyAssoc) AND InstanceFilter(MyInstance)
I want to receive all EventsEventTypeFilter(ChangeEvent)
© SAP 2007 / Page 13
MOIN Event Framework - Filtering
Client Side Usage of Event Filters
Create filter ("ElementChange" OR "LinkChange")
filterElementChange = new EventTypeFilter(ElementChangeEvent.class);
filterLinkChange = new EventTypeFilter(LinkChangeEvent.class);
mainFilter = new OrFilter(filterElementChange, filterLinkChange);
Register filter
eventRegistry.registerListener(mainFilter, listener);
© SAP 2007 / Page 14
Thank you!
top related