Adding an Event Provider

VWoeltjen edited this page Jun 22, 2012 · 2 revisions

In order to manage your data source, MCT provides notifications about which data points it is interested in by requesting and releasing subscriptions. An event provider allows you to connect these notifications to your actual data source.

An event provider implements the EventProvider interface:

public Collection<String> subscribeTopics(String... topic);
public void unsubscribeTopics(String... topic);
public void refresh();

The topic variables in each case are the same as the feed IDs used by the data provider (prefixed by the string EventProvider.TELEMETRY_TOPIC_PREFIX). Since you may have multiple data sources, not all topics will be relevant to a specific event provider. The subscribeTopics method should be aware of this and filter out unknown feed IDs when making the actual data subscription, and return a collection of only those topics actually subscribed. The unsubscribeTopics method allows for subscriptions to be released by the adapted data source. The refresh method may be used to explicitly request new data for the existing subscriptions, if this is appropriate to your data source.

Once your event provider is implemented, it can be made available to MCT through OSGi's declarative services. The easiest way to do this is to package your component in a Jar archive along with an XML document that describes what service you are offering (typically OSGI-INF/services.xml). An example of how such an XML file should look:

<?xml version="1.0" encoding="UTF-8"?>
<root xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0">
<scr:component name="gov.nasa.arc.mct.limits.data.ExampleEventProvider">
    <implementation class="gov.nasa.arc.mct.limits.data.ExampleEventProvider"/>
    <service>
        <provide interface="gov.nasa.arc.mct.event.services.EventProvider"/> 
    </service>
</scr:component>
</root>

Finally, you should add a line to your Jar's manifest to identify this service description:

Service-Component: OSGI-INF/services.xml