Fixup checkstyle
[controller.git] / opendaylight / md-sal / sal-binding-api / src / main / java / org / opendaylight / controller / sal / binding / api / BindingAwareProvider.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 org.opendaylight.controller.sal.binding.api.BindingAwareBroker.ProviderContext;
11
12 /**
13  * A developer implemented component that gets registered with the Broker.
14  *
15  * <p>
16  * Semantically, a provider may:
17  *
18  * <ol>
19  *   <li> Emit Notifications</li>
20  *   <li> Provide the implementation of RPCs </li>
21  *   <li> Write to the operational data tree </li>
22  * </ol>
23  *
24  * <p>
25  * If a class is not doing at least one of those three, consider using
26  * a BindingAwareConsumer instead:
27  * see {@link org.opendaylight.controller.sal.binding.api.BindingAwareConsumer}
28  *
29  * <p>
30  * In addition, a BindingAwareProvider can in pursuit of its goals:
31  * <ol>
32  *   <li>Subscribe for Notifications </li>
33  *   <li>Invoke RPCs</li>
34  *   <li>Read from either the operational or config data tree</li>
35  *   <li>Write to the config data tree</li>
36  * </ol>
37  * (All of the above are things a Consumer can also do).
38  *
39  * <p>
40  * Examples:
41  *
42  *<p>
43  * To get a NotificationService:
44  *
45  * {@code
46  * public void onSessionInitiated(ProviderContext session) {
47  *      NotificationProviderService notificationService = session.getSALService(NotificationProviderService.class);
48  * }
49  * }
50  * For more information on sending notifications via the NotificationProviderService
51  * see {@link org.opendaylight.controller.sal.binding.api.NotificationProviderService}
52  *
53  * <p>
54  * To register an RPC implementation:
55  *
56  * {@code
57  * public void onSessionInitiated(ProviderContext session) {
58  *    RpcRegistration<MyService> registration = session.addRpcImplementation(MyService.class, myImplementationInstance);
59  * }
60  * }
61  *
62  * <p>
63  * Where MyService.class is a Service interface generated from a yang model with RPCs modeled in it and
64  * myImplementationInstance is an instance of a class that implements MyService.
65  *
66  * <p>
67  * To register a Routed RPC Implementation:
68  * {@code
69  * public void onSessionInitiated(ProviderContext session) {
70  *   RoutedRpcRegistration<SalFlowService> flowRegistration = session.addRoutedRpcImplementation(SalFlowService.class,
71  *       salFlowServiceImplementationInstance);
72      flowRegistration.registerPath(NodeContext.class, nodeInstanceId);
73  * }
74  * }
75  *
76  * <p>
77  * Where SalFlowService.class is a Service interface generated from a yang model with RPCs modeled in it and
78  * salFlowServiceImplementationInstance is an instance of a class that implements SalFlowService.
79  *
80  * <p>
81  * The line:
82  * {@code
83  * flowRegistration.registerPath(NodeContext.class, nodeInstanceId);
84  * }
85  * Is indicating that the RPC implementation is registered to handle RPC invocations that have their NodeContext
86  * pointing to the node with instance id nodeInstanceId. This bears a bit of further explanation.  RoutedRPCs can be
87  * 'routed' to an implementation based upon 'context'.  'context' is a pointer (instanceId) to some place in the data
88  * tree.  In this example, the 'context' is a pointer to a Node.  In this way, a provider can register its ability to
89  * provide a service for a particular Node, but not *all* Nodes.  The Broker routes the RPC by 'context' to the correct
90  * implementation, without the caller having to do extra work.  Because of this when a RoutedRPC is registered, it
91  * needs to also be able to indicate for which 'contexts' it is providing an implementation.
92  *
93  * <p>
94  * An example of a Routed RPC would be an updateFlow(node, flow) that would be routed based on node to the provider
95  * which had registered to provide it *for that node*.
96  *
97  *<p>
98  * To get a DataBroker to allow access to the data tree:
99  *
100  * {@code
101  * public void onSessionInitiated(final ProviderContext session) {
102  *      DataBroker databroker = session.getSALService(BindingDataBroker.class);
103  * }
104  * }
105  */
106 @Deprecated(forRemoval = true)
107 public interface BindingAwareProvider {
108
109     /**
110      * Callback signaling initialization of the consumer session to the SAL.
111      *
112      * <p>
113      * The consumer MUST use the session for all communication with SAL or
114      * retrieving SAL infrastructure services.
115      *
116      * <p>
117      * This method is invoked by
118      * {@link BindingAwareBroker#registerProvider(BindingAwareProvider)}
119      *
120      * @param session Unique session between consumer and SAL.
121      */
122     void onSessionInitiated(ProviderContext session);
123 }