public class HelloWorldEventSource extends Object implements org.opendaylight.controller.messagebus.spi.EventSource
EventSource interface.
This example shows how to implement all necessary methods.
For simulation of occurrence of notification HelloWorldEventSource periodically creates messages
and if there is an joined topic then publish notifications with created messages.
Event source is identified by NodeKey (see method getNodeKey). Actual implementation can obtain node
as a constructor parameter (like as this example) or it can build own node by implementation specific
naming policy.
Messages are generated in internal class (MessageGenerator).
Message generator is started in constructor.
Messages are generated periodically in given interval and contain given text
(see constructor parameters Short messageGeneratePeriod and String messageText)
There is method joinTopic, that is called by EventSourceRegistry when event topic
is created and HelloWorldEventSource could publish notification. Implementation of joinTopic
has to analyze input and compare it with HelloWorldEventSource's available notification.
Method joinTopic registers only topic that match with at least one available notification.
Follow comments and docs in code, to learn more.| Modifier and Type | Field and Description |
|---|---|
static org.opendaylight.yangtools.yang.common.QName |
sample_notification_QNAME |
static String |
XMLNS_ATTRIBUTE_KEY |
static String |
XMLNS_URI |
| Constructor and Description |
|---|
HelloWorldEventSource(org.opendaylight.controller.md.sal.dom.api.DOMNotificationPublishService domPublish,
org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node sourceNode,
Short messageGeneratePeriod,
String messageText) |
| Modifier and Type | Method and Description |
|---|---|
void |
close() |
Future<org.opendaylight.yangtools.yang.common.RpcResult<Void>> |
disJoinTopic(org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.messagebus.eventsource.rev141202.DisJoinTopicInput input) |
List<org.opendaylight.yangtools.yang.model.api.SchemaPath> |
getAvailableNotifications() |
org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.NodeKey |
getSourceNodeKey() |
Future<org.opendaylight.yangtools.yang.common.RpcResult<org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.messagebus.eventsource.rev141202.JoinTopicOutput>> |
joinTopic(org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.messagebus.eventsource.rev141202.JoinTopicInput input) |
public static final org.opendaylight.yangtools.yang.common.QName sample_notification_QNAME
public static final String XMLNS_ATTRIBUTE_KEY
public static final String XMLNS_URI
public HelloWorldEventSource(org.opendaylight.controller.md.sal.dom.api.DOMNotificationPublishService domPublish,
org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node sourceNode,
Short messageGeneratePeriod,
String messageText)
public Future<org.opendaylight.yangtools.yang.common.RpcResult<org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.messagebus.eventsource.rev141202.JoinTopicOutput>> joinTopic(org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.messagebus.eventsource.rev141202.JoinTopicInput input)
joinTopic in interface org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.messagebus.eventsource.rev141202.EventSourceServicepublic void close()
throws Exception
close in interface AutoCloseableExceptionpublic org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.NodeKey getSourceNodeKey()
getSourceNodeKey in interface org.opendaylight.controller.messagebus.spi.EventSourcepublic List<org.opendaylight.yangtools.yang.model.api.SchemaPath> getAvailableNotifications()
getAvailableNotifications in interface org.opendaylight.controller.messagebus.spi.EventSourcepublic Future<org.opendaylight.yangtools.yang.common.RpcResult<Void>> disJoinTopic(org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.messagebus.eventsource.rev141202.DisJoinTopicInput input)
disJoinTopic in interface org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.messagebus.eventsource.rev141202.EventSourceServiceCopyright © 2015. All rights reserved.