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.BindingAwareProvider.ProviderFunctionality;
11 import org.opendaylight.controller.sal.binding.api.data.DataBrokerService;
12 import org.opendaylight.controller.sal.binding.api.data.DataProviderService;
13 import org.opendaylight.yangtools.yang.binding.BaseIdentity;
14 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
15 import org.opendaylight.yangtools.yang.binding.RpcService;
16 import org.osgi.framework.BundleContext;
19 * Binding-aware core of the SAL layer responsible for wiring the SAL consumers.
21 * The responsibility of the broker is to maintain registration of SAL
22 * functionality {@link Consumer}s and {@link Provider}s, store provider and
23 * consumer specific context and functionality registration via
24 * {@link ConsumerContext} and provide access to infrastructure services, which
25 * removes direct dependencies between providers and consumers.
27 * The Binding-aware broker is also responsible for translation from Java
28 * classes modeling the functionality and data to binding-indpenedent form which
29 * is used in SAL Core.
32 * <h3>Infrastructure services</h3> Some examples of infrastructure services:
35 * <li>YANG Module service - see {@link ConsumerContext#getRpcService(Class)},
36 * {@link ProviderContext}
37 * <li>Notification Service - see {@link NotificationService} and
38 * {@link NotificationProviderService}
39 * <li>Functionality and Data model
40 * <li>Data Store access and modification - see {@link DataBrokerService} and
41 * {@link DataProviderService}
44 * The services are exposed via session.
46 * <h3>Session-based access</h3>
48 * The providers and consumers needs to register in order to use the
49 * binding-independent SAL layer and to expose functionality via SAL layer.
51 * For more information about session-based access see {@link ConsumerContext}
52 * and {@link ProviderContext}
57 public interface BindingAwareBroker {
59 * Registers the {@link BindingAwareConsumer}, which will use the SAL layer.
62 * Note that consumer could register additional functionality at later point
63 * by using service and functionality specific APIs.
66 * The consumer is required to use returned session for all communication
67 * with broker or one of the broker services. The session is announced to
68 * the consumer by invoking
69 * {@link Consumer#onSessionInitiated(ConsumerContext)}.
72 * Consumer to be registered.
73 * @return a session specific to consumer registration
74 * @throws IllegalArgumentException
75 * If the consumer is <code>null</code>.
76 * @throws IllegalStateException
77 * If the consumer is already registered.
79 ConsumerContext registerConsumer(BindingAwareConsumer consumer, BundleContext ctx);
82 * Registers the {@link BindingAwareProvider}, which will use the SAL layer.
85 * During the registration, the broker obtains the initial functionality
86 * from consumer, using the
87 * {@link BindingAwareProvider#getImplementations()}, and register that
88 * functionality into system and concrete infrastructure services.
91 * Note that provider could register additional functionality at later point
92 * by using service and functionality specific APIs.
95 * The consumer is <b>required to use</b> returned session for all
96 * communication with broker or one of the broker services. The session is
97 * announced to the consumer by invoking
98 * {@link BindingAwareProvider#onSessionInitiated(ProviderContext)}.
102 * Provider to be registered.
103 * @return a session unique to the provider registration.
104 * @throws IllegalArgumentException
105 * If the provider is <code>null</code>.
106 * @throws IllegalStateException
107 * If the consumer is already registered.
109 ProviderContext registerProvider(BindingAwareProvider provider, BundleContext ctx);
112 * {@link BindingAwareConsumer} specific access to the SAL functionality.
115 * ConsumerSession is {@link BindingAwareConsumer}-specific access to the
116 * SAL functionality and infrastructure services.
119 * The session serves to store SAL context (e.g. registration of
120 * functionality) for the consumer and provides access to the SAL
121 * infrastructure services and other functionality provided by
127 public interface ConsumerContext {
130 * Returns a session specific instance (implementation) of requested
131 * binding-aware infrastructural service
135 * @return Session specific implementation of service
137 <T extends BindingAwareService> T getSALService(Class<T> service);
140 * Returns a session specific instance (implementation) of requested
141 * YANG module implentation / service provided by consumer.
145 * @return Session specific implementation of service
147 <T extends RpcService> T getRpcService(Class<T> module);
151 * {@link BindingAwareProvider} specific access to the SAL functionality.
154 * ProviderSession is {@link BindingAwareProvider}-specific access to the
155 * SAL functionality and infrastructure services, which also allows for
156 * exposing the provider's functionality to the other
157 * {@link BindingAwareConsumer}s.
160 * The session serves to store SAL context (e.g. registration of
161 * functionality) for the providers and exposes access to the SAL
162 * infrastructure services, dynamic functionality registration and any other
163 * functionality provided by other {@link BindingAwareConsumer}s.
166 public interface ProviderContext extends ConsumerContext {
168 * Registers an global RpcService implementation.
171 * @param implementation
174 <T extends RpcService> RpcRegistration<T> addRpcImplementation(Class<T> type, T implementation)
175 throws IllegalStateException;
177 <T extends RpcService> RpcRegistration<T> addMountRpcImplementation(Class<T> type,
178 InstanceIdentifier mount, T implementation) throws IllegalStateException;
180 <T extends RpcService> RoutedRpcRegistration<T> addRoutedRpcImplementation(Class<T> type, T implementation)
181 throws IllegalStateException;
183 void registerFunctionality(ProviderFunctionality functionality);
184 void unregisterFunctionality(ProviderFunctionality functionality);
187 public interface RpcRegistration<T extends RpcService> {
191 * @return instance for which registration does exists.
196 * Unregister an RpcService from broker.
202 public interface RoutedRpcRegistration<T extends RpcService> extends RpcRegistration<T> {
205 * Register particular instance identifier to be processed by this
211 void registerInstance(Class<? extends BaseIdentity> context, InstanceIdentifier instance);
213 void unregisterInstance(Class<? extends BaseIdentity> context, InstanceIdentifier instance);