Copyright © TIBCO Software Inc. All Rights Reserved
Copyright © TIBCO Software Inc. All Rights Reserved


Chapter 11 Custom Adapter Example: zapadapter : Analysis and Design

Analysis and Design
Before implementing the adapter, you must be clear about the problem to be solved. This section illustrates how an example problem statement can be mapped to a design.
Problem Statement
The ZapAdapter application retrieves data from a ZAP source application and publishes it to the messaging system. ZAP has the following characteristics:
ZAP is an enterprise order processing application.
ZAP provides a DataMapper (in C++ only) and ZAPAppData classes to access ZAP data.
ZAP does not provide event-driven APIs.
Because the ZAP system’s data access API does not support an event-driven approach to retrieving data from the ZAP system, ZapAdapter checks every n seconds for new events. If there are unprocessed events, the data associated with the events must be published.
Figure 25 shows how this example fits into the TIBCO messaging application framework.
Figure 25 ZAPAdapter and the TIBCO Enterprise Model
The adapter sends the data to a listening adapter. The database, which is always kept current by the actions of ZAP adapter, is used for queries. This design offloads query processing from the ZAP instance.
TIBCO ActiveMatrix BusinessWorks could be set up to perform data conversion. This allows users of the database to work with queries they are familiar with.
Elements of Implementation
The implementation of ZapAdapter must provide the following elements:
Initialization and startup. In the example, the adapter needs to:
Event sources. The application must include the following event source:
Publisher. Publishes the data retrieved by the timer event source.
Event listener subclass with onEvent() methods.
In this example, the Timer event handler polls data when informed by timer event source.
Data conversion element. In the ZAP example, data conversion is done explicitly by a ZapEventListener, DataMapper (in C++ only) and ZAPAppData class. The ZapEventListener class accepts data from the ZAP instance and converts it to MInstance format. Specifically, this example retrieves two tables, Customer and Contract that share an ID field.
Configuration. The configuration is performed in TIBCO Designer. See Specifying Configuration Information.
Components of ZapAdapter Sample Application
This section gives an overview of the ZapAdapter files and their content.
External library used by the ZAP adapter to retrieve and update data.
MApp subclass with onInitialization() and onTermination() method. Creates an event handler and publisher instances. Top-level control function main().
Subclasses of MEventListener with onEvent() methods.
ZapConnection class with methods: connect(), disconnect(), and getPendingCustomerEvent()
Maintains ZAP connectivity logic. Connection parameters are passed through the properties object. This class creates and maintains the handle to the ZAP instance.
Maps AccountInfo and OrderInfo from MInstance to C++ and back.

Copyright © TIBCO Software Inc. All Rights Reserved
Copyright © TIBCO Software Inc. All Rights Reserved