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;
12 import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.messagebus.eventaggregator.rev141202.TopicId;
13 import org.opendaylight.yangtools.yang.model.api.SchemaPath;
14 import org.slf4j.Logger;
15 import org.slf4j.LoggerFactory;
18 public abstract class NotificationTopicRegistration implements AutoCloseable {
20 private static final Logger LOG = LoggerFactory.getLogger(NotificationTopicRegistration.class);
22 public enum NotificationSourceType{
24 ConnectionStatusChange;
27 private boolean active;
28 private final NotificationSourceType notificationSourceType;
29 private final String sourceName;
30 private final String notificationUrnPrefix;
31 private boolean replaySupported;
33 protected NotificationTopicRegistration(NotificationSourceType notificationSourceType, String sourceName, String notificationUrnPrefix) {
34 this.notificationSourceType = notificationSourceType;
35 this.sourceName = sourceName;
36 this.notificationUrnPrefix = notificationUrnPrefix;
38 this.setReplaySupported(false);
41 public boolean isActive() {
45 protected void setActive(boolean active) {
49 public NotificationSourceType getNotificationSourceType() {
50 return notificationSourceType;
53 public String getSourceName() {
57 public String getNotificationUrnPrefix() {
58 return notificationUrnPrefix;
61 public boolean checkNotificationPath(SchemaPath notificationPath){
62 if(notificationPath == null){
65 String nameSpace = notificationPath.getLastComponent().toString();
66 LOG.debug("CheckNotification - name space {} - NotificationUrnPrefix {}", nameSpace, getNotificationUrnPrefix());
67 return nameSpace.startsWith(getNotificationUrnPrefix());
69 abstract void activateNotificationSource();
71 abstract void deActivateNotificationSource();
73 abstract void reActivateNotificationSource();
75 abstract boolean registerNotificationTopic(SchemaPath notificationPath, TopicId topicId);
77 abstract void unRegisterNotificationTopic(TopicId topicId);
79 abstract ArrayList<TopicId> getNotificationTopicIds(SchemaPath notificationPath);
81 public boolean isReplaySupported() {
82 return replaySupported;
85 protected void setReplaySupported(boolean replaySupported) {
86 this.replaySupported = replaySupported;