Merge "Fixed for bug 1168 : Issue while update subnet"
[controller.git] / opendaylight / md-sal / sal-binding-api / src / main / java / org / opendaylight / controller / sal / binding / api / NotificationProviderService.java
1 /*
2  * Copyright (c) 2013 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.sal.binding.api;
9
10 import java.util.EventListener;
11 import java.util.concurrent.ExecutorService;
12
13 import org.opendaylight.controller.md.sal.common.api.notify.NotificationPublishService;
14 import org.opendaylight.yangtools.concepts.ListenerRegistration;
15 import org.opendaylight.yangtools.yang.binding.Notification;
16
17 /**
18  * Interface for a notification service that provides publish/subscribe capabilities for YANG
19  * modeled notifications. This interface is a combination of the {@link NotificationService} and
20  * {@link NotificationPublishService} interfaces.
21  */
22 public interface NotificationProviderService extends NotificationService, NotificationPublishService<Notification> {
23
24     /**
25      * {@inheritDoc}
26      */
27     @Override
28     public void publish(Notification notification);
29
30     /**
31      * {@inheritDoc}
32      */
33     @Override
34     void publish(Notification notification, ExecutorService executor);
35
36     /**
37      * Registers a listener to be notified about notification subscriptions. This
38      * enables a component to know when there is a notification listener subscribed
39      * for a particular notification type.
40      * <p>
41      * On registration of this listener, the
42      * {@link NotificationInterestListener#onNotificationSubscribtion(Class)} method
43      * will be invoked for every notification type that currently has a notification listener
44      * subscribed.
45      *
46      * @param interestListener the listener that will be notified when subscriptions
47      *                         for new notification types occur.
48      * @return a {@link ListenerRegistration} instance that should be used to unregister the listener
49      *         by invoking the {@link ListenerRegistration#close()} method when no longer needed.
50      */
51     ListenerRegistration<NotificationInterestListener> registerInterestListener(
52             NotificationInterestListener interestListener);
53
54     /**
55      * Interface for a listener interested in being notified about notification subscriptions.
56      */
57     public interface NotificationInterestListener extends EventListener {
58
59         /**
60          * Callback that is invoked when a notification listener subscribes for a
61          * particular notification type.
62          * <p>
63          * This method is only called for the first subscription that occurs for a
64          * particular notification type. Subsequent subscriptions for the same
65          * notification type do not trigger invocation of this method.
66          * <p>
67          * <b>Note:</b>This callback is delivered from thread not owned by this listener,
68          * all processing should be as fast as possible and implementations should
69          * not do any blocking calls or block this thread.
70          *
71          * @param notificationType the notification type for the subscription that occurred.
72          */
73         void onNotificationSubscribtion(Class<? extends Notification> notificationType);
74     }
75 }