Improve segmented journal actor metrics
[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  * <p>
21  * The responsibility of the broker is to maintain registration of SAL
22  * functionality Consumers and Providers, 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.
26  *
27  * <p>
28  * The Binding-aware broker is also responsible for translation from Java
29  * classes modeling the functionality and data to binding-independent form which
30  * is used in SAL Core.
31  *
32  * <h3>Infrastructure services</h3> Some examples of infrastructure services:
33  *
34  * <ul>
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  * </ul>
40  *
41  * <p>
42  * The services are exposed via session.
43  *
44  * <h3>Session-based access</h3>
45  *
46  * <p>
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  * <p>
51  * For more information about session-based access see {@link ConsumerContext}
52  * and {@link ProviderContext}
53  */
54 @Deprecated(forRemoval = true)
55 public interface BindingAwareBroker {
56     @Deprecated
57     ConsumerContext registerConsumer(BindingAwareConsumer consumer, BundleContext ctx);
58
59     /**
60      * Registers the {@link BindingAwareConsumer}, which will use the SAL layer.
61      *
62      * <p>
63      * Note that consumer could register additional functionality at later point
64      * by using service and functionality specific APIs.
65      *
66      * <p>
67      * The consumer is required to use returned session for all communication
68      * with broker or one of the broker services. The session is announced to
69      * the consumer by invoking
70      * {@link BindingAwareConsumer#onSessionInitialized(ConsumerContext)}.
71      *
72      * @param consumer
73      *            Consumer to be registered.
74      * @return a session specific to consumer registration
75      * @throws IllegalArgumentException
76      *             If the consumer is <code>null</code>.
77      * @throws IllegalStateException
78      *             If the consumer is already registered.
79      */
80     @Deprecated
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     @Deprecated
118     ProviderContext registerProvider(BindingAwareProvider provider);
119
120     /**
121      * {@link BindingAwareConsumer} specific access to the SAL functionality.
122      *
123      * <p>
124      * ConsumerSession is {@link BindingAwareConsumer}-specific access to the
125      * SAL functionality and infrastructure services.
126      *
127      * <p>
128      * The session serves to store SAL context (e.g. registration of
129      * functionality) for the consumer and provides access to the SAL
130      * infrastructure services and other functionality provided by
131      * {@link BindingAwareProvider}s.
132      */
133     @Deprecated
134     interface ConsumerContext extends RpcConsumerRegistry {
135
136         /**
137          * Returns a session specific instance (implementation) of requested binding-aware infrastructure service.
138          *
139          * @param service
140          *            Broker service
141          * @return Session specific implementation of service
142          */
143         <T extends BindingAwareService> T getSALService(Class<T> service);
144     }
145
146     /**
147      * {@link BindingAwareProvider} specific access to the SAL functionality.
148      *
149      * <p>
150      * ProviderSession is {@link BindingAwareProvider}-specific access to the
151      * SAL functionality and infrastructure services, which also allows for
152      * exposing the provider's functionality to the other
153      * {@link BindingAwareConsumer}s.
154      *
155      * <p>
156      * The session serves to store SAL context (e.g. registration of
157      * functionality) for the providers and exposes access to the SAL
158      * infrastructure services, dynamic functionality registration and any other
159      * functionality provided by other {@link BindingAwareConsumer}s.
160      *
161      */
162     @Deprecated
163     interface ProviderContext extends ConsumerContext, RpcProviderRegistry {
164
165     }
166
167     /**
168      * Represents an RPC implementation registration. Users should call the
169      * {@link ObjectRegistration#close close} method when the registration is no longer needed.
170      *
171      * @param <T> the implemented RPC service interface
172      */
173     interface RpcRegistration<T extends RpcService> extends ObjectRegistration<T> {
174
175         /**
176          * Returns the implemented RPC service interface.
177          */
178         Class<T> getServiceType();
179
180         @Override
181         void close();
182     }
183
184     /**
185      * Represents a routed RPC implementation registration. Users should call the
186      * {@link RoutedRegistration#close close} method when the registration is no longer needed.
187      *
188      * @param <T> the implemented RPC service interface
189      */
190     interface RoutedRpcRegistration<T extends RpcService> extends RpcRegistration<T>,
191             RoutedRegistration<Class<? extends BaseIdentity>, InstanceIdentifier<?>, T> {
192
193         /**
194          * Register particular instance identifier to be processed by this RpcService.
195          *
196          * @deprecated in favor of RoutedRegistration#registerPath(Object, Object).
197          */
198         @Deprecated
199         void registerInstance(Class<? extends BaseIdentity> context, InstanceIdentifier<?> instance);
200
201         /**
202          * Unregister particular instance identifier to be processed by this RpcService.
203          *
204          * @deprecated in favor of RoutedRegistration#unregisterPath(Class, InstanceIdentifier).
205          */
206         @Deprecated
207         void unregisterInstance(Class<? extends BaseIdentity> context, InstanceIdentifier<?> instance);
208     }
209 }