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.md.sal.common.api.routing.RoutedRegistration;
11 import org.opendaylight.controller.sal.binding.api.BindingAwareProvider.ProviderFunctionality;
12 import org.opendaylight.controller.sal.binding.api.data.DataBrokerService;
13 import org.opendaylight.controller.sal.binding.api.data.DataProviderService;
14 import org.opendaylight.yangtools.concepts.Registration;
15 import org.opendaylight.yangtools.yang.binding.BaseIdentity;
16 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
17 import org.opendaylight.yangtools.yang.binding.RpcService;
18 import org.osgi.framework.BundleContext;
21 * Binding-aware core of the SAL layer responsible for wiring the SAL consumers.
23 * The responsibility of the broker is to maintain registration of SAL
24 * functionality {@link Consumer}s and {@link Provider}s, store provider and
25 * consumer specific context and functionality registration via
26 * {@link ConsumerContext} and provide access to infrastructure services, which
27 * removes direct dependencies between providers and consumers.
29 * The Binding-aware broker is also responsible for translation from Java
30 * classes modeling the functionality and data to binding-indpenedent form which
31 * is used in SAL Core.
34 * <h3>Infrastructure services</h3> Some examples of infrastructure services:
37 * <li>YANG Module service - see {@link ConsumerContext#getRpcService(Class)},
38 * {@link ProviderContext}
39 * <li>Notification Service - see {@link NotificationService} and
40 * {@link NotificationProviderService}
41 * <li>Functionality and Data model
42 * <li>Data Store access and modification - see {@link DataBrokerService} and
43 * {@link DataProviderService}
46 * The services are exposed via session.
48 * <h3>Session-based access</h3>
50 * The providers and consumers needs to register in order to use the
51 * binding-independent SAL layer and to expose functionality via SAL layer.
53 * For more information about session-based access see {@link ConsumerContext}
54 * and {@link ProviderContext}
59 public interface BindingAwareBroker {
61 * Registers the {@link BindingAwareConsumer}, which will use the SAL layer.
64 * Note that consumer could register additional functionality at later point
65 * by using service and functionality specific APIs.
68 * The consumer is required to use returned session for all communication
69 * with broker or one of the broker services. The session is announced to
70 * the consumer by invoking
71 * {@link Consumer#onSessionInitiated(ConsumerContext)}.
74 * Consumer to be registered.
75 * @return a session specific to consumer registration
76 * @throws IllegalArgumentException
77 * If the consumer is <code>null</code>.
78 * @throws IllegalStateException
79 * If the consumer is already registered.
81 ConsumerContext registerConsumer(BindingAwareConsumer consumer, BundleContext ctx);
84 * Registers the {@link BindingAwareProvider}, which will use the SAL layer.
87 * During the registration, the broker obtains the initial functionality
88 * from consumer, using the
89 * {@link BindingAwareProvider#getImplementations()}, and register that
90 * functionality into system and concrete infrastructure services.
93 * Note that provider could register additional functionality at later point
94 * by using service and functionality specific APIs.
97 * The consumer is <b>required to use</b> returned session for all
98 * communication with broker or one of the broker services. The session is
99 * announced to the consumer by invoking
100 * {@link BindingAwareProvider#onSessionInitiated(ProviderContext)}.
104 * Provider to be registered.
105 * @return a session unique to the provider registration.
106 * @throws IllegalArgumentException
107 * If the provider is <code>null</code>.
108 * @throws IllegalStateException
109 * If the consumer is already registered.
111 ProviderContext registerProvider(BindingAwareProvider provider, BundleContext ctx);
114 * {@link BindingAwareConsumer} specific access to the SAL functionality.
117 * ConsumerSession is {@link BindingAwareConsumer}-specific access to the
118 * SAL functionality and infrastructure services.
121 * The session serves to store SAL context (e.g. registration of
122 * functionality) for the consumer and provides access to the SAL
123 * infrastructure services and other functionality provided by
129 public interface ConsumerContext {
132 * Returns a session specific instance (implementation) of requested
133 * binding-aware infrastructural service
137 * @return Session specific implementation of service
139 <T extends BindingAwareService> T getSALService(Class<T> service);
142 * Returns a session specific instance (implementation) of requested
143 * YANG module implentation / service provided by consumer.
147 * @return Session specific implementation of service
149 <T extends RpcService> T getRpcService(Class<T> module);
153 * {@link BindingAwareProvider} specific access to the SAL functionality.
156 * ProviderSession is {@link BindingAwareProvider}-specific access to the
157 * SAL functionality and infrastructure services, which also allows for
158 * exposing the provider's functionality to the other
159 * {@link BindingAwareConsumer}s.
162 * The session serves to store SAL context (e.g. registration of
163 * functionality) for the providers and exposes access to the SAL
164 * infrastructure services, dynamic functionality registration and any other
165 * functionality provided by other {@link BindingAwareConsumer}s.
168 public interface ProviderContext extends ConsumerContext {
170 * Registers an global RpcService implementation.
173 * @param implementation
176 <T extends RpcService> RpcRegistration<T> addRpcImplementation(Class<T> type, T implementation)
177 throws IllegalStateException;
179 <T extends RpcService> RpcRegistration<T> addMountRpcImplementation(Class<T> type, InstanceIdentifier<?> mount,
180 T implementation) throws IllegalStateException;
182 <T extends RpcService> RoutedRpcRegistration<T> addRoutedRpcImplementation(Class<T> type, T implementation)
183 throws IllegalStateException;
185 void registerFunctionality(ProviderFunctionality functionality);
187 void unregisterFunctionality(ProviderFunctionality functionality);
190 public interface RpcRegistration<T extends RpcService> extends Registration<T> {
194 * @return instance for which registration does exists.
200 public interface RoutedRpcRegistration<T extends RpcService> extends RpcRegistration<T>,
201 RoutedRegistration<Class<? extends BaseIdentity>, InstanceIdentifier<?>, T> {
204 * Register particular instance identifier to be processed by this
207 * Deprecated in favor of {@link RoutedRegistration#registerPath(Object, Object)}.
213 void registerInstance(Class<? extends BaseIdentity> context, InstanceIdentifier<?> instance);
216 void unregisterInstance(Class<? extends BaseIdentity> context, InstanceIdentifier<?> instance);