2 * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.
\r
4 * This program and the accompanying materials are made available under the
\r
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
\r
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
\r
8 package org.opendaylight.controller.sal.core.api;
\r
10 import java.util.concurrent.Future;
\r
12 import org.opendaylight.controller.sal.core.api.data.DataBrokerService;
\r
13 import org.opendaylight.controller.sal.core.api.data.DataProviderService;
\r
14 import org.opendaylight.controller.sal.core.api.notify.NotificationProviderService;
\r
15 import org.opendaylight.controller.sal.core.api.notify.NotificationService;
\r
16 import org.opendaylight.controller.yang.common.QName;
\r
17 import org.opendaylight.controller.yang.common.RpcResult;
\r
18 import org.opendaylight.controller.yang.data.api.CompositeNode;
\r
22 * Core component of the SAL layer responsible for wiring the SAL consumers.
\r
24 * The responsibility of the broker is to maintain registration of SAL
\r
25 * functionality {@link Consumer}s and {@link Provider}s, store provider and
\r
26 * consumer specific context and functionality registration via
\r
27 * {@link ConsumerSession} and provide access to infrastructure services, which
\r
28 * removes direct dependencies between providers and consumers.
\r
31 * <h3>Infrastructure services</h3> Some examples of infrastructure services:
\r
34 * <li>RPC Invocation - see {@link ConsumerSession#rpc(QName, CompositeNode)},
\r
35 * {@link ProviderSession#addRpcImplementation(QName, RpcImplementation)} and
\r
36 * {@link RpcImplementation}
\r
37 * <li>Notification Service - see {@link NotificationService} and
\r
38 * {@link NotificationProviderService}
\r
39 * <li>Functionality and Data model
\r
40 * <li>Data Store access and modification - see {@link DataBrokerService} and
\r
41 * {@link DataProviderService}
\r
44 * The services are exposed via session.
\r
46 * <h3>Session-based access</h3>
\r
48 * The providers and consumers needs to register in order to use the
\r
49 * binding-independent SAL layer and to expose functionality via SAL layer.
\r
51 * For more information about session-based access see {@link ConsumerSession}
\r
52 * and {@link ProviderSession}
\r
57 public interface Broker {
\r
60 * Registers the {@link Consumer}, which will use the SAL layer.
\r
63 * During the registration, the broker obtains the initial functionality
\r
64 * from consumer, using the {@link Consumer#getConsumerFunctionality()}, and
\r
65 * register that functionality into system and concrete infrastructure
\r
69 * Note that consumer could register additional functionality at later point
\r
70 * by using service and functionality specific APIs.
\r
73 * The consumer is required to use returned session for all communication
\r
74 * with broker or one of the broker services. The session is announced to
\r
75 * the consumer by invoking
\r
76 * {@link Consumer#onSessionInitiated(ConsumerSession)}.
\r
79 * Consumer to be registered.
\r
80 * @return a session specific to consumer registration
\r
81 * @throws IllegalArgumentException
\r
82 * If the consumer is <code>null</code>.
\r
83 * @throws IllegalStateException
\r
84 * If the consumer is already registered.
\r
86 ConsumerSession registerConsumer(Consumer cons);
\r
89 * Registers the {@link Provider}, which will use the SAL layer.
\r
92 * During the registration, the broker obtains the initial functionality
\r
93 * from consumer, using the {@link Provider#getProviderFunctionality()}, and
\r
94 * register that functionality into system and concrete infrastructure
\r
98 * Note that consumer could register additional functionality at later point
\r
99 * by using service and functionality specific APIs (e.g.
\r
100 * {@link ProviderSession#addRpcImplementation(QName, RpcImplementation)}
\r
103 * The consumer is <b>required to use</b> returned session for all
\r
104 * communication with broker or one of the broker services. The session is
\r
105 * announced to the consumer by invoking
\r
106 * {@link Provider#onSessionInitiated(ProviderSession)}.
\r
110 * Provider to be registered.
\r
111 * @return a session unique to the provider registration.
\r
112 * @throws IllegalArgumentException
\r
113 * If the provider is <code>null</code>.
\r
114 * @throws IllegalStateException
\r
115 * If the consumer is already registered.
\r
117 ProviderSession registerProvider(Provider prov);
\r
120 * {@link Consumer} specific access to the SAL functionality.
\r
123 * ConsumerSession is {@link Consumer}-specific access to the SAL
\r
124 * functionality and infrastructure services.
\r
127 * The session serves to store SAL context (e.g. registration of
\r
128 * functionality) for the consumer and provides access to the SAL
\r
129 * infrastructure services and other functionality provided by
\r
130 * {@link Provider}s.
\r
135 public interface ConsumerSession {
\r
138 * Sends an RPC to other components registered to the broker.
\r
140 * @see RpcImplementation
\r
144 * Input data to the RPC
\r
145 * @return Result of the RPC call
\r
147 Future<RpcResult<CompositeNode>> rpc(QName rpc, CompositeNode input);
\r
149 boolean isClosed();
\r
152 * Returns a session specific instance (implementation) of requested
\r
157 * @return Session specific implementation of service
\r
159 <T extends BrokerService> T getService(Class<T> service);
\r
162 * Closes a session between consumer and broker.
\r
165 * The close operation unregisters a consumer and remove all registered
\r
166 * functionality of the consumer from the system.
\r
173 * {@link Provider} specific access to the SAL functionality.
\r
176 * ProviderSession is {@link Provider}-specific access to the SAL
\r
177 * functionality and infrastructure services, which also allows for exposing
\r
178 * the provider's functionality to the other {@link Consumer}s.
\r
181 * The session serves to store SAL context (e.g. registration of
\r
182 * functionality) for the providers and exposes access to the SAL
\r
183 * infrastructure services, dynamic functionality registration and any other
\r
184 * functionality provided by other {@link Provider}s.
\r
187 public interface ProviderSession extends ConsumerSession {
\r
189 * Registers an implementation of the rpc.
\r
192 * The registered rpc functionality will be available to all other
\r
193 * consumers and providers registered to the broker, which are aware of
\r
194 * the {@link QName} assigned to the rpc.
\r
197 * There is no assumption that rpc type is in the set returned by
\r
198 * invoking {@link RpcImplementation#getSupportedRpcs()}. This allows
\r
199 * for dynamic rpc implementations.
\r
203 * @param implementation
\r
204 * Provider's Implementation of the RPC functionality
\r
205 * @throws IllegalArgumentException
\r
206 * If the name of RPC is invalid
\r
208 void addRpcImplementation(QName rpcType,
\r
209 RpcImplementation implementation)
\r
210 throws IllegalArgumentException;
\r
213 * Unregisters an Rpc implementation
\r
217 * @param implementation
\r
218 * Registered Implementation of the Rpc functionality
\r
219 * @throws IllegalArgumentException
\r
221 void removeRpcImplementation(QName rpcType,
\r
222 RpcImplementation implementation)
\r
223 throws IllegalArgumentException;
\r
226 * Closes a session between provider and SAL.
\r
229 * The close operation unregisters a provider and remove all registered
\r
230 * functionality of the provider from the system.
\r
233 public void close();
\r
236 boolean isClosed();
\r