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.core.api;
10 import org.osgi.framework.BundleContext;
13 * Core component of the SAL layer responsible for wiring the SAL consumers.
15 * The responsibility of the broker is to maintain registration of SAL
16 * functionality {@link Consumer}s and {@link Provider}s, store provider and
17 * consumer specific context and functionality registration via
18 * {@link ConsumerSession} and provide access to infrastructure services, which
19 * removes direct dependencies between providers and consumers.
22 * The services are exposed via session.
24 * <h3>Session-based access</h3>
26 * The providers and consumers needs to register in order to use the
27 * binding-independent SAL layer and to expose functionality via SAL layer.
29 * For more information about session-based access see {@link ConsumerSession}
30 * and {@link ProviderSession}
35 public interface Broker {
38 * Registers the {@link Consumer}, which will use the SAL layer.
41 * During the registration, the broker obtains the initial functionality
42 * from consumer, using the {@link Consumer#getConsumerFunctionality()}, and
43 * register that functionality into system and concrete infrastructure
47 * Note that consumer could register additional functionality at later point
48 * by using service and functionality specific APIs.
51 * The consumer is required to use returned session for all communication
52 * with broker or one of the broker services. The session is announced to
53 * the consumer by invoking
54 * {@link Consumer#onSessionInitiated(ConsumerSession)}.
57 * Consumer to be registered.
58 * @return a session specific to consumer registration
59 * @throws IllegalArgumentException
60 * If the consumer is <code>null</code>.
61 * @throws IllegalStateException
62 * If the consumer is already registered.
64 ConsumerSession registerConsumer(Consumer cons);
67 * @deprecated Use registerConsumer(Consumer cons) instead (BundleContext is no longer used)
70 ConsumerSession registerConsumer(Consumer cons, BundleContext context);
73 * Registers the {@link Provider}, which will use the SAL layer.
76 * During the registration, the broker obtains the initial functionality
77 * from consumer, using the {@link Provider#getProviderFunctionality()}, and
78 * register that functionality into system and concrete infrastructure
81 * The consumer is <b>required to use</b> returned session for all
82 * communication with broker or one of the broker services. The session is
83 * announced to the consumer by invoking
84 * {@link Provider#onSessionInitiated(ProviderSession)}.
88 * Provider to be registered.
89 * @return a session unique to the provider registration.
90 * @throws IllegalArgumentException
91 * If the provider is <code>null</code>.
92 * @throws IllegalStateException
93 * If the consumer is already registered.
95 ProviderSession registerProvider(Provider prov);
98 * @deprecated Use registerProvider(Provider cons) instead (BundleContext is no longer used)
101 ProviderSession registerProvider(Provider prov, BundleContext context);
104 * {@link Consumer} specific access to the SAL functionality.
107 * ConsumerSession is {@link Consumer}-specific access to the SAL
108 * functionality and infrastructure services.
111 * The session serves to store SAL context (e.g. registration of
112 * functionality) for the consumer and provides access to the SAL
113 * infrastructure services and other functionality provided by
119 public interface ConsumerSession {
124 * Returns a session specific instance (implementation) of requested
129 * @return Session specific implementation of service
131 <T extends BrokerService> T getService(Class<T> service);
134 * Closes a session between consumer and broker.
137 * The close operation unregisters a consumer and remove all registered
138 * functionality of the consumer from the system.
145 * {@link Provider} specific access to the SAL functionality.
148 * ProviderSession is {@link Provider}-specific access to the SAL
149 * functionality and infrastructure services, which also allows for exposing
150 * the provider's functionality to the other {@link Consumer}s.
153 * The session serves to store SAL context (e.g. registration of
154 * functionality) for the providers and exposes access to the SAL
155 * infrastructure services, dynamic functionality registration and any other
156 * functionality provided by other {@link Provider}s.
159 public interface ProviderSession extends ConsumerSession {
161 * Closes a session between provider and SAL.
164 * The close operation unregisters a provider and remove all registered
165 * functionality of the provider from the system.