Porting of WebSockets to Jetty in RFC-8040 RESTCONF
[netconf.git] / restconf / restconf-nb-rfc8040 / src / main / java / org / opendaylight / restconf / nb / rfc8040 / streams / listeners / BaseListenerInterface.java
1 /*
2  * Copyright (c) 2016 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.restconf.nb.rfc8040.streams.listeners;
9
10 import java.util.Set;
11 import org.opendaylight.restconf.nb.rfc8040.streams.websockets.WebSocketSessionHandler;
12 import org.opendaylight.yangtools.concepts.ListenerRegistration;
13
14 /**
15  * Base interface for both listeners({@link ListenerAdapter}, {@link NotificationListenerAdapter}).
16  */
17 public interface BaseListenerInterface extends AutoCloseable {
18
19     /**
20      * Return all subscribers of listener.
21      *
22      * @return Set of all subscribers.
23      */
24     Set<WebSocketSessionHandler> getSubscribers();
25
26     /**
27      * Checks if exists at least one {@link WebSocketSessionHandler} subscriber.
28      *
29      * @return {@code true} if exist at least one {@link WebSocketSessionHandler} subscriber, {@code false} otherwise.
30      */
31     boolean hasSubscribers();
32
33     /**
34      * Get name of stream.
35      *
36      * @return Stream name.
37      */
38     String getStreamName();
39
40     /**
41      * Get output type.
42      *
43      * @return Output type (JSON or XML).
44      */
45     String getOutputType();
46
47     /**
48      * Registers {@link WebSocketSessionHandler} subscriber.
49      *
50      * @param subscriber Web-socket session handler.
51      */
52     void addSubscriber(WebSocketSessionHandler subscriber);
53
54     /**
55      * Removes {@link WebSocketSessionHandler} subscriber.
56      *
57      * @param subscriber Web-socket session handler.
58      */
59     void removeSubscriber(WebSocketSessionHandler subscriber);
60
61     /**
62      * Sets {@link ListenerRegistration} registration.
63      *
64      * @param registration DOMDataChangeListener registration.
65      */
66     void setRegistration(ListenerRegistration<?> registration);
67
68     /**
69      * Checks if {@link ListenerRegistration} registration exists.
70      *
71      * @return {@code true} if exists, {@code false} otherwise.
72      */
73     boolean isListening();
74 }