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.yangtools.concepts.ObjectRegistration;
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-independent 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 org.opendaylight.controller.sal.binding.api.data.DataBrokerService} and
41 * {@link org.opendaylight.controller.sal.binding.api.data.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}
54 public interface BindingAwareBroker {
56 * Registers the {@link BindingAwareConsumer}, which will use the SAL layer.
59 * Note that consumer could register additional functionality at later point
60 * by using service and functionality specific APIs.
63 * The consumer is required to use returned session for all communication
64 * with broker or one of the broker services. The session is announced to
65 * the consumer by invoking
66 * {@link Consumer#onSessionInitiated(ConsumerContext)}.
69 * Consumer to be registered.
70 * @return a session specific to consumer registration
71 * @throws IllegalArgumentException
72 * If the consumer is <code>null</code>.
73 * @throws IllegalStateException
74 * If the consumer is already registered.
76 ConsumerContext registerConsumer(BindingAwareConsumer consumer, BundleContext ctx);
79 * Registers the {@link BindingAwareProvider}, which will use the SAL layer.
82 * During the registration, the broker obtains the initial functionality
83 * from consumer, using the
84 * {@link BindingAwareProvider#getImplementations()}, and register that
85 * functionality into system and concrete infrastructure services.
88 * Note that provider could register additional functionality at later point
89 * by using service and functionality specific APIs.
92 * The consumer is <b>required to use</b> returned session for all
93 * communication with broker or one of the broker services. The session is
94 * announced to the consumer by invoking
95 * {@link BindingAwareProvider#onSessionInitiated(ProviderContext)}.
99 * Provider to be registered.
100 * @return a session unique to the provider registration.
101 * @throws IllegalArgumentException
102 * If the provider is <code>null</code>.
103 * @throws IllegalStateException
104 * If the consumer is already registered.
106 ProviderContext registerProvider(BindingAwareProvider provider, BundleContext ctx);
109 * {@link BindingAwareConsumer} specific access to the SAL functionality.
112 * ConsumerSession is {@link BindingAwareConsumer}-specific access to the
113 * SAL functionality and infrastructure services.
116 * The session serves to store SAL context (e.g. registration of
117 * functionality) for the consumer and provides access to the SAL
118 * infrastructure services and other functionality provided by
121 public interface ConsumerContext extends RpcConsumerRegistry {
124 * Returns a session specific instance (implementation) of requested
125 * binding-aware infrastructural service
129 * @return Session specific implementation of service
131 <T extends BindingAwareService> T getSALService(Class<T> service);
135 * {@link BindingAwareProvider} specific access to the SAL functionality.
138 * ProviderSession is {@link BindingAwareProvider}-specific access to the
139 * SAL functionality and infrastructure services, which also allows for
140 * exposing the provider's functionality to the other
141 * {@link BindingAwareConsumer}s.
144 * The session serves to store SAL context (e.g. registration of
145 * functionality) for the providers and exposes access to the SAL
146 * infrastructure services, dynamic functionality registration and any other
147 * functionality provided by other {@link BindingAwareConsumer}s.
150 public interface ProviderContext extends ConsumerContext, RpcProviderRegistry {
153 void registerFunctionality(ProviderFunctionality functionality);
156 void unregisterFunctionality(ProviderFunctionality functionality);
159 public interface RpcRegistration<T extends RpcService> extends ObjectRegistration<T> {
161 Class<T> getServiceType();
164 public interface RoutedRpcRegistration<T extends RpcService> extends RpcRegistration<T>,
165 RoutedRegistration<Class<? extends BaseIdentity>, InstanceIdentifier<?>, T> {
168 * Register particular instance identifier to be processed by this
171 * Deprecated in favor of {@link RoutedRegistration#registerPath(Object, Object)}.
177 void registerInstance(Class<? extends BaseIdentity> context, InstanceIdentifier<?> instance);
180 * Unregister particular instance identifier to be processed by this
183 * Deprecated in favor of {@link RoutedRegistration#unregisterPath(Object, Object)}.
189 void unregisterInstance(Class<? extends BaseIdentity> context, InstanceIdentifier<?> instance);