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.
16 * The responsibility of the broker is to maintain registration of SAL
17 * functionality {@link Consumer}s and {@link Provider}s, store provider and
18 * consumer specific context and functionality registration via
19 * {@link ConsumerSession} and provide access to infrastructure services, which
20 * removes direct dependencies between providers and consumers.
23 * The services are exposed via session.
25 * <h3>Session-based access</h3>
28 * The providers and consumers needs to register in order to use the
29 * binding-independent SAL layer and to expose functionality via SAL layer.
32 * For more information about session-based access see {@link ConsumerSession}
33 * 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
82 * The consumer is <b>required to use</b> returned session for all
83 * communication with broker or one of the broker services. The session is
84 * announced to the consumer by invoking
85 * {@link Provider#onSessionInitiated(ProviderSession)}.
89 * Provider to be registered.
90 * @return a session unique to the provider registration.
91 * @throws IllegalArgumentException
92 * If the provider is <code>null</code>.
93 * @throws IllegalStateException
94 * If the consumer is already registered.
96 ProviderSession registerProvider(Provider prov);
99 * @deprecated Use registerProvider(Provider cons) instead (BundleContext is no longer used)
102 ProviderSession registerProvider(Provider prov, BundleContext context);
105 * {@link Consumer} specific access to the SAL functionality.
108 * ConsumerSession is {@link Consumer}-specific access to the SAL
109 * functionality and infrastructure services.
112 * The session serves to store SAL context (e.g. registration of
113 * functionality) for the consumer and provides access to the SAL
114 * infrastructure services and other functionality provided by
120 interface ConsumerSession {
125 * Returns a session specific instance (implementation) of requested service.
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 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.