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 * @deprecated Use blueprint instead for code wiring.
38 public interface Broker {
41 * Registers the {@link Consumer}, which will use the SAL layer.
44 * During the registration, the broker obtains the initial functionality
45 * from consumer, using the {@link Consumer#getConsumerFunctionality()}, and
46 * register that functionality into system and concrete infrastructure
50 * Note that consumer could register additional functionality at later point
51 * by using service and functionality specific APIs.
54 * The consumer is required to use returned session for all communication
55 * with broker or one of the broker services. The session is announced to
56 * the consumer by invoking
57 * {@link Consumer#onSessionInitiated(ConsumerSession)}.
60 * Consumer to be registered.
61 * @return a session specific to consumer registration
62 * @throws IllegalArgumentException
63 * If the consumer is <code>null</code>.
64 * @throws IllegalStateException
65 * If the consumer is already registered.
67 ConsumerSession registerConsumer(Consumer cons);
70 * @deprecated Use registerConsumer(Consumer cons) instead (BundleContext is no longer used)
73 ConsumerSession registerConsumer(Consumer cons, BundleContext context);
76 * Registers the {@link Provider}, which will use the SAL layer.
79 * During the registration, the broker obtains the initial functionality
80 * from consumer, using the {@link Provider#getProviderFunctionality()}, and
81 * register that functionality into system and concrete infrastructure
85 * The consumer is <b>required to use</b> returned session for all
86 * communication with broker or one of the broker services. The session is
87 * announced to the consumer by invoking
88 * {@link Provider#onSessionInitiated(ProviderSession)}.
92 * Provider to be registered.
93 * @return a session unique to the provider registration.
94 * @throws IllegalArgumentException
95 * If the provider is <code>null</code>.
96 * @throws IllegalStateException
97 * If the consumer is already registered.
99 ProviderSession registerProvider(Provider prov);
102 * @deprecated Use registerProvider(Provider cons) instead (BundleContext is no longer used)
105 ProviderSession registerProvider(Provider prov, BundleContext context);
108 * {@link Consumer} specific access to the SAL functionality.
111 * ConsumerSession is {@link Consumer}-specific access to the SAL
112 * functionality and infrastructure services.
115 * The session serves to store SAL context (e.g. registration of
116 * functionality) for the consumer and provides access to the SAL
117 * infrastructure services and other functionality provided by
123 interface ConsumerSession {
128 * Returns a session specific instance (implementation) of requested service.
132 * @return Session specific implementation of service
134 <T extends BrokerService> T getService(Class<T> service);
137 * Closes a session between consumer and broker.
140 * The close operation unregisters a consumer and remove all registered
141 * functionality of the consumer from the system.
148 * {@link Provider} specific access to the SAL functionality.
151 * ProviderSession is {@link Provider}-specific access to the SAL
152 * functionality and infrastructure services, which also allows for exposing
153 * the provider's functionality to the other {@link Consumer}s.
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 Provider}s.
162 interface ProviderSession extends ConsumerSession {
164 * Closes a session between provider and SAL.
167 * The close operation unregisters a provider and remove all registered
168 * functionality of the provider from the system.