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 * Note that consumer could register additional functionality at later point
42 * by using service and functionality specific APIs.
45 * The consumer is required to use returned session for all communication
46 * with broker or one of the broker services. The session is announced to
47 * the consumer by invoking
48 * {@link Consumer#onSessionInitiated(ConsumerSession)}.
51 * Consumer to be registered.
52 * @return a session specific to consumer registration
53 * @throws IllegalArgumentException
54 * If the consumer is <code>null</code>.
55 * @throws IllegalStateException
56 * If the consumer is already registered.
58 ConsumerSession registerConsumer(Consumer cons);
61 * @deprecated Use registerConsumer(Consumer cons) instead (BundleContext is no longer used)
64 ConsumerSession registerConsumer(Consumer cons, BundleContext context);
67 * Registers the {@link Provider}, which will use the SAL layer.
70 * The consumer is <b>required to use</b> returned session for all
71 * communication with broker or one of the broker services. The session is
72 * announced to the consumer by invoking
73 * {@link Provider#onSessionInitiated(ProviderSession)}.
77 * Provider to be registered.
78 * @return a session unique to the provider registration.
79 * @throws IllegalArgumentException
80 * If the provider is <code>null</code>.
81 * @throws IllegalStateException
82 * If the consumer is already registered.
84 ProviderSession registerProvider(Provider prov);
87 * @deprecated Use registerProvider(Provider cons) instead (BundleContext is no longer used)
90 ProviderSession registerProvider(Provider prov, BundleContext context);
93 * {@link Consumer} specific access to the SAL functionality.
96 * ConsumerSession is {@link Consumer}-specific access to the SAL
97 * functionality and infrastructure services.
100 * The session serves to store SAL context (e.g. registration of
101 * functionality) for the consumer and provides access to the SAL
102 * infrastructure services and other functionality provided by
108 public interface ConsumerSession {
113 * Returns a session specific instance (implementation) of requested
118 * @return Session specific implementation of service
120 <T extends BrokerService> T getService(Class<T> service);
123 * Closes a session between consumer and broker.
126 * The close operation unregisters a consumer and remove all registered
127 * functionality of the consumer from the system.
134 * {@link Provider} specific access to the SAL functionality.
137 * ProviderSession is {@link Provider}-specific access to the SAL
138 * functionality and infrastructure services, which also allows for exposing
139 * the provider's functionality to the other {@link Consumer}s.
142 * The session serves to store SAL context (e.g. registration of
143 * functionality) for the providers and exposes access to the SAL
144 * infrastructure services, dynamic functionality registration and any other
145 * functionality provided by other {@link Provider}s.
148 public interface ProviderSession extends ConsumerSession {
150 * Closes a session between provider and SAL.
153 * The close operation unregisters a provider and remove all registered
154 * functionality of the provider from the system.