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.controller.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;
16 public abstract class NotificationTopicRegistration implements AutoCloseable {
18 private static final Logger LOG = LoggerFactory.getLogger(NotificationTopicRegistration.class);
20 public enum NotificationSourceType {
22 ConnectionStatusChange;
25 private boolean active;
26 private final NotificationSourceType notificationSourceType;
27 private final String sourceName;
28 private final String notificationUrnPrefix;
29 private boolean replaySupported;
31 protected NotificationTopicRegistration(NotificationSourceType notificationSourceType, String sourceName,
32 String notificationUrnPrefix) {
33 this.notificationSourceType = notificationSourceType;
34 this.sourceName = sourceName;
35 this.notificationUrnPrefix = notificationUrnPrefix;
37 this.setReplaySupported(false);
40 public boolean isActive() {
44 protected void setActive(boolean active) {
48 public NotificationSourceType getNotificationSourceType() {
49 return notificationSourceType;
52 public String getSourceName() {
56 public String getNotificationUrnPrefix() {
57 return notificationUrnPrefix;
60 public boolean checkNotificationPath(SchemaPath notificationPath) {
61 if (notificationPath == null) {
64 String nameSpace = notificationPath.getLastComponent().toString();
65 LOG.debug("CheckNotification - name space {} - NotificationUrnPrefix {}", nameSpace,
66 getNotificationUrnPrefix());
67 return nameSpace.startsWith(getNotificationUrnPrefix());
70 abstract void activateNotificationSource();
72 abstract void deActivateNotificationSource();
74 abstract void reActivateNotificationSource();
76 abstract boolean registerNotificationTopic(SchemaPath notificationPath, TopicId topicId);
78 abstract void unRegisterNotificationTopic(TopicId topicId);
80 abstract ArrayList<TopicId> getNotificationTopicIds(SchemaPath notificationPath);
82 public boolean isReplaySupported() {
83 return replaySupported;
86 protected void setReplaySupported(boolean replaySupported) {
87 this.replaySupported = replaySupported;