![]() |
Copyright © TIBCO Software Inc. All Rights Reserved |
Three classes participate in the TIBCO Adapter event model: event sources, events, and event listeners. Figure 9 illustrates the event management class hierarchy.Figure 9 Event Management Class Hierarchy
• Event sources generate events, that is, an event source creates an event instance when it is triggered. An example is the MSubscriber event source, which creates MDataEvent, MExceptionEvent, or MTimeOutEvent instances.
• Events are created and owned by the event source. Instances of events encapsulate state information about an event. Some adapters may decide to provide a custom event for their source or target application.An MSubscriber sends a special event, MExceptionEvent. See How Adapters Receive Data for details on when a subscriber receives an MException event.
• Event listeners register interest with event sources. Custom adapters create appropriate subclasses of the SDK event listener class and implement onEvent() methods with application-specific behavior.The following code fragment accesses a subscriber event source, which was defined in the project repository, and binds a listener—in effect, a callback—to the subscriber:
The Java API supports MEventSource, MEvent, and MEventListener classes to implement an event model that mirrors that of the C++ API.In contrast to the C++ API, the MIODescriptor event source and related MIOEvent are not supported because there is no need for them in conjunction with the Java event model.
2. An MSubscriber instance (event source) receives the data and creates an instance of MDataEvent (event). A new event instance is created each time new data is received.
3. The event source informs each registered listener by calling the listener’s onEvent() method. Each onEvent() method executes using the information stored in the MDataEvent instance.Figure 10 TIBCO Adapter Event ModelA custom adapter can use custom events to suit its needs. In these cases, the custom adapter needs to provide the following elements:
• Custom event source(s)—subclass(es) of MEventSource—with these methods defined:
− addListener() adds a listener to the event source.
− removeListener() removes a listener from the event source. Calling this method does not cancel certified delivery agreement for RVCM.
− notify() triggers an event in each event listener attached to this event source.
• A custom event (subclass of MEvent). This is the event the custom event source generates. In the constructor for the event, the related event source is provided.
•
![]() |
Copyright © TIBCO Software Inc. All Rights Reserved |