Deprecate controller APIs
[controller.git] / opendaylight / md-sal / sal-binding-api / src / main / java / org / opendaylight / controller / md / sal / binding / api / NotificationService.java
1 /*
2  * Copyright (c) 2014 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.md.sal.binding.api;
9
10 import org.opendaylight.yangtools.concepts.ListenerRegistration;
11 import org.opendaylight.yangtools.yang.binding.NotificationListener;
12
13 /**
14  * Notification broker which allows clients to subscribe for and publish YANG-modeled notifications.
15  *
16  * <p>
17  * Each YANG module which defines notifications results in a generated interface <code>{ModuleName}Listener</code>
18  * which handles all the notifications defined in the YANG model. Each notification type translates to
19  * a specific method of the form <code>on{NotificationType}</code> on the generated interface.
20  * The generated interface also extends the
21  * {@link org.opendaylight.yangtools.yang.binding.NotificationListener} interface and implementations
22  * are registered using
23  *  {@link #registerNotificationListener(org.opendaylight.yangtools.yang.binding.NotificationListener)} method.
24  *
25  * <h3>Dispatch Listener Example</h3>
26  *
27  * <p>
28  * Lets assume we have following YANG model:
29  *
30  * <pre>
31  * module example {
32  *      ...
33  *
34  *      notification start {
35  *          ...
36  *      }
37  *
38  *      notification stop {
39  *           ...
40  *      }
41  * }
42  * </pre>
43  *
44  * <p>
45  * The generated interface will be:
46  * {@code
47  *  public interface ExampleListener extends NotificationListener {
48  *      void onStart(Start notification);
49  *      void onStop(Stop notification);
50  *  }
51  * }
52  * The following defines an implementation of the generated interface:
53  * {@code
54  *  public class MyExampleListener implements ExampleListener {
55  *      public void onStart(Start notification) {
56  *          // do something
57  *      }
58  *
59  *      public void onStop(Stop notification) {
60  *          // do something
61  *      }
62  *  }
63  * }
64  * The implementation is registered as follows:
65  * {@code
66  *  MyExampleListener listener = new MyExampleListener();
67  *  ListenerRegistration<NotificationListener> reg = service.registerNotificationListener( listener );
68  * }
69  * The <code>onStart</code> method will be invoked when someone publishes a <code>Start</code> notification and
70  * the <code>onStop</code> method will be invoked when someone publishes a <code>Stop</code> notification.
71  *
72  * @deprecated Use {@link org.opendaylight.mdsal.binding.api.NotificationService} instead
73  */
74 @Deprecated
75 public interface NotificationService extends BindingService {
76     /**
77      * Registers a listener which implements a YANG-generated notification interface derived from
78      * {@link NotificationListener}. The listener is registered for all notifications present in
79      * the implemented interface.
80      *
81      * @param listener the listener implementation that will receive notifications.
82      * @return a {@link ListenerRegistration} instance that should be used to unregister the listener
83      *         by invoking the {@link ListenerRegistration#close()} method when no longer needed.
84      */
85     <T extends NotificationListener> ListenerRegistration<T> registerNotificationListener(T listener);
86 }