Fix javadocs and enable doclint
[controller.git] / opendaylight / md-sal / sal-binding-api / src / main / java / org / opendaylight / controller / sal / binding / api / BindingAwareBroker.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.md.sal.common.api.routing.RoutedRegistration;
11 import org.opendaylight.yangtools.concepts.ObjectRegistration;
12 import org.opendaylight.yangtools.yang.binding.BaseIdentity;
13 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
14 import org.opendaylight.yangtools.yang.binding.RpcService;
15 import org.osgi.framework.BundleContext;
16
17 /**
18  * Binding-aware core of the SAL layer responsible for wiring the SAL consumers.
19  *
20  * The responsibility of the broker is to maintain registration of SAL
21  * functionality Consumers and Providers, store provider and
22  * consumer specific context and functionality registration via
23  * {@link ConsumerContext} and provide access to infrastructure services, which
24  * removes direct dependencies between providers and consumers.
25  *
26  * The Binding-aware broker is also responsible for translation from Java
27  * classes modeling the functionality and data to binding-independent form which
28  * is used in SAL Core.
29  *
30  *
31  * <h3>Infrastructure services</h3> Some examples of infrastructure services:
32  *
33  * <ul>
34  * <li>YANG Module service - see {@link ConsumerContext#getRpcService(Class)},
35  * {@link ProviderContext}
36  * <li>Notification Service - see {@link NotificationService} and
37  * {@link NotificationProviderService}
38  * <li>Functionality and Data model
39  * <li>Data Store access and modification - see {@link org.opendaylight.controller.sal.binding.api.data.DataBrokerService} and
40  * {@link org.opendaylight.controller.sal.binding.api.data.DataProviderService}
41  * </ul>
42  *
43  * The services are exposed via session.
44  *
45  * <h3>Session-based access</h3>
46  *
47  * The providers and consumers needs to register in order to use the
48  * binding-independent SAL layer and to expose functionality via SAL layer.
49  *
50  * For more information about session-based access see {@link ConsumerContext}
51  * and {@link ProviderContext}
52  */
53 public interface BindingAwareBroker {
54     /*
55      * @deprecated Use registerConsumer(BindingAwareConsumer cons) instead (BundleContext is no longer used)
56      */
57     @Deprecated
58     ConsumerContext registerConsumer(BindingAwareConsumer consumer, BundleContext ctx);
59
60     /**
61      * Registers the {@link BindingAwareConsumer}, which will use the SAL layer.
62      *
63      * <p>
64      * Note that consumer could register additional functionality at later point
65      * by using service and functionality specific APIs.
66      *
67      * <p>
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 BindingAwareConsumer#onSessionInitialized(ConsumerContext)}.
72      *
73      * @param consumer
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.
80      */
81     ConsumerContext registerConsumer(BindingAwareConsumer consumer);
82
83     /*
84      * @deprecated Use registerProvider(BindingAwareProvider prov) instead (BundleContext is no longer used)
85      */
86     @Deprecated
87     ProviderContext registerProvider(BindingAwareProvider provider, BundleContext ctx);
88
89     /**
90      * Registers the {@link BindingAwareProvider}, which will use the SAL layer.
91      *
92      * <p>
93      * During the registration, the broker obtains the initial functionality
94      * from consumer, using the
95      * BindingAwareProvider#getImplementations(), and register that
96      * functionality into system and concrete infrastructure services.
97      *
98      * <p>
99      * Note that provider could register additional functionality at later point
100      * by using service and functionality specific APIs.
101      *
102      * <p>
103      * The consumer is <b>required to use</b> returned session for all
104      * communication with broker or one of the broker services. The session is
105      * announced to the consumer by invoking
106      * {@link BindingAwareProvider#onSessionInitiated(ProviderContext)}.
107      *
108      *
109      * @param provider
110      *            Provider to be registered.
111      * @return a session unique to the provider registration.
112      * @throws IllegalArgumentException
113      *             If the provider is <code>null</code>.
114      * @throws IllegalStateException
115      *             If the consumer is already registered.
116      */
117     ProviderContext registerProvider(BindingAwareProvider provider);
118
119     /**
120      * {@link BindingAwareConsumer} specific access to the SAL functionality.
121      *
122      * <p>
123      * ConsumerSession is {@link BindingAwareConsumer}-specific access to the
124      * SAL functionality and infrastructure services.
125      *
126      * <p>
127      * The session serves to store SAL context (e.g. registration of
128      * functionality) for the consumer and provides access to the SAL
129      * infrastructure services and other functionality provided by
130      * {@link BindingAwareProvider}s.
131      */
132     interface ConsumerContext extends RpcConsumerRegistry {
133
134         /**
135          * Returns a session specific instance (implementation) of requested
136          * binding-aware infrastructural service
137          *
138          * @param service
139          *            Broker service
140          * @return Session specific implementation of service
141          */
142         <T extends BindingAwareService> T getSALService(Class<T> service);
143     }
144
145     /**
146      * {@link BindingAwareProvider} specific access to the SAL functionality.
147      *
148      * <p>
149      * ProviderSession is {@link BindingAwareProvider}-specific access to the
150      * SAL functionality and infrastructure services, which also allows for
151      * exposing the provider's functionality to the other
152      * {@link BindingAwareConsumer}s.
153      *
154      * <p>
155      * The session serves to store SAL context (e.g. registration of
156      * functionality) for the providers and exposes access to the SAL
157      * infrastructure services, dynamic functionality registration and any other
158      * functionality provided by other {@link BindingAwareConsumer}s.
159      *
160      */
161     interface ProviderContext extends ConsumerContext, RpcProviderRegistry {
162
163     }
164
165     /**
166      * Represents an RPC implementation registration. Users should call the
167      * {@link ObjectRegistration#close close} method when the registration is no longer needed.
168      *
169      * @param <T> the implemented RPC service interface
170      */
171     interface RpcRegistration<T extends RpcService> extends ObjectRegistration<T> {
172
173         /**
174          * Returns the implemented RPC service interface.
175          */
176         Class<T> getServiceType();
177
178         @Override
179         void close();
180     }
181
182     /**
183      * Represents a routed RPC implementation registration. Users should call the
184      * {@link RoutedRegistration#close close} method when the registration is no longer needed.
185      *
186      * @param <T> the implemented RPC service interface
187      */
188     interface RoutedRpcRegistration<T extends RpcService> extends RpcRegistration<T>,
189             RoutedRegistration<Class<? extends BaseIdentity>, InstanceIdentifier<?>, T> {
190
191         /**
192          * Register particular instance identifier to be processed by this
193          * RpcService
194          *
195          * Deprecated in favor of RoutedRegistration#registerPath(Object, Object).
196          *
197          * @param context
198          * @param instance
199          */
200         @Deprecated
201         void registerInstance(Class<? extends BaseIdentity> context, InstanceIdentifier<?> instance);
202
203         /**
204          * Unregister particular instance identifier to be processed by this
205          * RpcService
206          *
207          * Deprecated in favor of RoutedRegistration#unregisterPath(Class, InstanceIdentifier).
208          *
209          * @param context
210          * @param instance
211          */
212         @Deprecated
213         void unregisterInstance(Class<? extends BaseIdentity> context, InstanceIdentifier<?> instance);
214     }
215 }