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.binding.api;
12 import org.opendaylight.mdsal.binding.api.RpcConsumerRegistry;
14 import org.opendaylight.yangtools.concepts.ObjectRegistration;
15 import org.opendaylight.yangtools.yang.binding.BaseIdentity;
16 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
17 import org.opendaylight.yangtools.yang.binding.RpcService;
20 * Binding-aware core of the SAL layer responsible for wiring the SAL consumers.
22 * The responsibility of the broker is to maintain registration of SAL functionality
23 * {@link BindingAwareConsumer}s and {@link BindingAwareProvider}s, store provider and consumer
24 * specific context and functionality registration via
25 * {@link org.opendaylight.controller.sal.binding.api.BindingAwareBroker.ConsumerContext} and
26 * provide access to infrastructure services, which removes direct dependencies between providers
29 * The Binding-aware broker is also responsible for translation from Java classes modeling the
30 * functionality and data to binding-independent form which is used in SAL Core.
33 * <h3>Infrastructure services</h3> Some examples of infrastructure services: The services are
34 * exposed via session.
36 * <h3>Session-based access</h3>
38 * The providers and consumers needs to register in order to use the binding-independent SAL layer
39 * and to expose functionality via SAL layer.
41 * For more information about session-based access see
42 * {@link org.opendaylight.controller.sal.binding.api.BindingAwareBroker.ConsumerContext} and
43 * {@link ProviderContext}
45 public interface BindingAwareBroker {
48 * Registers the {@link BindingAwareConsumer}, which will use the SAL layer.
51 * Note that consumer could register additional functionality at later point by using service
52 * and functionality specific APIs.
55 * The consumer is required to use returned session for all communication with broker or one of
56 * the broker services. The session is announced to the consumer by invoking
57 * {@link BindingAwareConsumer#onSessionInitialized(org.opendaylight.controller.sal.binding.api.BindingAwareBroker.ConsumerContext)}.
59 * @param consumer Consumer to be registered.
60 * @return a session specific to consumer registration
61 * @throws IllegalArgumentException If the consumer is <code>null</code>.
62 * @throws IllegalStateException If the consumer is already registered.
64 ConsumerContext registerConsumer(BindingAwareConsumer consumer);
67 * Registers the {@link BindingAwareProvider}, which will use the SAL layer.
70 * Note that provider could register additional functionality at later point by using service
71 * and functionality specific APIs.
74 * The consumer is <b>required to use</b> returned session for all communication with broker or
75 * one of the broker services. The session is announced to the consumer by invoking
76 * {@link BindingAwareProvider#onSessionInitiated(ProviderContext)}.
79 * @param provider Provider to be registered.
80 * @return a session unique to the provider registration.
81 * @throws IllegalArgumentException If the provider is <code>null</code>.
82 * @throws IllegalStateException If the consumer is already registered.
84 ProviderContext registerProvider(BindingAwareProvider provider);
87 * {@link BindingAwareConsumer} specific access to the SAL functionality.
90 * ConsumerSession is {@link BindingAwareConsumer}-specific access to the SAL functionality and
91 * infrastructure services.
94 * The session serves to store SAL context (e.g. registration of functionality) for the consumer
95 * and provides access to the SAL infrastructure services and other functionality provided by
98 public interface ConsumerContext extends RpcConsumerRegistry {
101 * Returns a session specific instance (implementation) of requested
102 * binding-aware infrastructural service
106 * @return Session specific implementation of service
108 <T extends BindingAwareService> T getSALService(Class<T> service);
112 * {@link BindingAwareProvider} specific access to the SAL functionality.
115 * ProviderSession is {@link BindingAwareProvider}-specific access to the
116 * SAL functionality and infrastructure services, which also allows for
117 * exposing the provider's functionality to the other
118 * {@link BindingAwareConsumer}s.
121 * The session serves to store SAL context (e.g. registration of
122 * functionality) for the providers and exposes access to the SAL
123 * infrastructure services, dynamic functionality registration and any other
124 * functionality provided by other {@link BindingAwareConsumer}s.
127 public interface ProviderContext extends ConsumerContext, RpcProviderRegistry {
132 * Represents an RPC implementation registration. Users should call the
133 * {@link ObjectRegistration#close close} method when the registration is no longer needed.
135 * @param <T> the implemented RPC service interface
137 public interface RpcRegistration<T extends RpcService> extends ObjectRegistration<T> {
140 * Returns the implemented RPC service interface.
142 Class<T> getServiceType();
149 * Represents a routed RPC implementation registration. Users should call the
150 * {@link RpcRegistration#close() close} method when the registration is no longer needed.
152 * @param <T> the implemented RPC service interface
154 public interface RoutedRpcRegistration<T extends RpcService> extends RpcRegistration<T> {
157 * Register particular instance identifier to be processed by this
163 void registerPath(Class<? extends BaseIdentity> context, InstanceIdentifier<?> instance);
166 * Unregister particular instance identifier to be processed by this
172 void unregisterPath(Class<? extends BaseIdentity> context, InstanceIdentifier<?> instance);