BUG 3030 - reconnect netconf event source
[controller.git] / opendaylight / md-sal / messagebus-impl / src / main / java / org / opendaylight / controller / messagebus / eventsources / netconf / NotificationTopicRegistration.java
1 /*
2  * Copyright (c) 2015 Cisco Systems, Inc. and others.  All rights reserved.
3  *
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
7  */
8 package org.opendaylight.controller.messagebus.eventsources.netconf;
9
10 import java.util.ArrayList;
11
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
15
16 public abstract class NotificationTopicRegistration implements AutoCloseable {
17
18     public enum NotificationSourceType{
19         NetconfDeviceStream,
20         ConnectionStatusChange;
21     }
22
23     private boolean active;
24     private final NotificationSourceType notificationSourceType;
25     private final String sourceName;
26     private final String notificationUrnPrefix;
27     private boolean replaySupported;
28
29     protected NotificationTopicRegistration(NotificationSourceType notificationSourceType, String sourceName, String notificationUrnPrefix) {
30         this.notificationSourceType = notificationSourceType;
31         this.sourceName = sourceName;
32         this.notificationUrnPrefix = notificationUrnPrefix;
33         this.active = false;
34         this.setReplaySupported(false);
35     }
36
37     public boolean isActive() {
38         return active;
39     }
40
41     protected void setActive(boolean active) {
42         this.active = active;
43     }
44
45     public NotificationSourceType getNotificationSourceType() {
46         return notificationSourceType;
47     }
48
49     public String getSourceName() {
50         return sourceName;
51     }
52
53     public String getNotificationUrnPrefix() {
54         return notificationUrnPrefix;
55     }
56
57     abstract void activateNotificationSource();
58
59     abstract void deActivateNotificationSource();
60
61     abstract void reActivateNotificationSource();
62
63     abstract boolean registerNotificationTopic(SchemaPath notificationPath, TopicId topicId);
64
65     abstract void unRegisterNotificationTopic(TopicId topicId);
66
67     abstract ArrayList<TopicId> getNotificationTopicIds(SchemaPath notificationPath);
68
69     public boolean isReplaySupported() {
70         return replaySupported;
71     }
72
73     protected void setReplaySupported(boolean replaySupported) {
74         this.replaySupported = replaySupported;
75     }
76
77 }