2 * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.
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
8 package org.opendaylight.controller.sal.binding.api;
10 import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.ConsumerContext;
14 * A developer implemented component that gets registered with the Broker.
16 * Semantically, a consumer may:
19 * <li>Subscribe for Notifications </li>
20 * <li>Invoke RPCs</li>
21 * <li>Read from either the operational or config data tree</li>
22 * <li>Write to the config data tree</li>
26 * <li> Emit Notifications</li>
27 * <li> Provide the implementation of RPCs </li>
28 * <li> Write to the operational data tree </li>
31 * Consider using a BindingAwareProvider
35 * To get a NotificationService:
38 * public void onSessionInitiated(ProviderContext session) {
39 * NotificationProviderService notificationService = session.getSALService(NotificationProviderService.class);
40 * notificationService.publish(notification)
42 * where notification is an instance of a modeled Notification.
43 * For more information on sending notifications via the NotificationProviderService
44 * @see org.opendaylight.controller.sal.binding.api.NotificationProviderService
47 * A consumer can *invoke* and RPC ( ie, call foo(fooArgs)) but it cannot register an RPC
48 * implementation with the MD-SAL that others can invoke(call).
49 * To get an invokable RPC:
52 * public void onSessionInitiated(ProviderContext session) {
53 * MyService rpcFlowSalService = session.getRpcService(MyService.class);
56 * Where MyService.class is a Service interface generated from a yang model with RPCs modeled in it. The returned
57 * rpcFlowSalService can be used like any other object by invoking its methods. Note, nothing special needs to be done
58 * for RoutedRPCs. They just work.
60 * To get a DataBroker to allow access to the data tree:
63 * public void onSessionInitiated(final ProviderContext session) {
64 * DataBroker databroker = session.getSALService(BindingDataBroker.class);
68 public interface BindingAwareConsumer {
71 * Callback signaling initialization of the consumer session to the SAL.
73 * The consumer MUST use the session for all communication with SAL or
74 * retrieving SAL infrastructure services.
76 * This method is invoked by
77 * {@link BindingAwareBroker#registerConsumer(BindingAwareConsumer)}
80 * Unique session between consumer and SAL.
82 void onSessionInitialized(ConsumerContext session);