2 * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
8 package org.opendaylight.netconf.messagebus.eventsources.netconf;
10 import java.util.ArrayList;
11 import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.messagebus.eventaggregator.rev141202.TopicId;
12 import org.opendaylight.yangtools.yang.model.api.SchemaPath;
13 import org.slf4j.Logger;
14 import org.slf4j.LoggerFactory;
17 * Notification topic registration.
19 public abstract class NotificationTopicRegistration implements AutoCloseable {
21 private static final Logger LOG = LoggerFactory.getLogger(NotificationTopicRegistration.class);
23 public enum NotificationSourceType {
25 ConnectionStatusChange;
28 private boolean active;
29 private final NotificationSourceType notificationSourceType;
30 private final String sourceName;
31 private final String notificationUrnPrefix;
32 private boolean replaySupported;
34 protected NotificationTopicRegistration(NotificationSourceType notificationSourceType, String sourceName,
35 String notificationUrnPrefix) {
36 this.notificationSourceType = notificationSourceType;
37 this.sourceName = sourceName;
38 this.notificationUrnPrefix = notificationUrnPrefix;
40 this.setReplaySupported(false);
43 public boolean isActive() {
47 protected void setActive(boolean active) {
51 public NotificationSourceType getNotificationSourceType() {
52 return notificationSourceType;
55 public String getSourceName() {
59 public String getNotificationUrnPrefix() {
60 return notificationUrnPrefix;
64 * Checks, if notification is from namespace belonging to this registration.
65 * @param notificationPath path
66 * @return true, if notification belongs to registration namespace
68 public boolean checkNotificationPath(SchemaPath notificationPath) {
69 if (notificationPath == null) {
72 String nameSpace = notificationPath.getLastComponent().getNamespace().toString();
73 LOG.debug("CheckNotification - name space {} - NotificationUrnPrefix {}", nameSpace,
74 getNotificationUrnPrefix());
75 return nameSpace.startsWith(getNotificationUrnPrefix());
78 abstract void activateNotificationSource();
80 abstract void deActivateNotificationSource();
82 abstract void reActivateNotificationSource();
85 * Registers associated event source notification to topic.
86 * @param notificationPath notification path
87 * @param topicId topic id
88 * @return true, if successful
90 abstract boolean registerNotificationTopic(SchemaPath notificationPath, TopicId topicId);
93 * Registers associated event source notification to topic.
94 * @param topicId topic id
95 * @return true, if successful
97 abstract void unRegisterNotificationTopic(TopicId topicId);
100 * Returns registered topics for given path.
101 * @param notificationPath path
104 abstract ArrayList<TopicId> getNotificationTopicIds(SchemaPath notificationPath);
106 public boolean isReplaySupported() {
107 return replaySupported;
110 protected void setReplaySupported(boolean replaySupported) {
111 this.replaySupported = replaySupported;