-/*\r
- * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.\r
- *\r
- * This program and the accompanying materials are made available under the\r
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
- * and is available at http://www.eclipse.org/legal/epl-v10.html\r
- */\r
-package org.opendaylight.controller.sal.binding.api;\r
-\r
-import org.opendaylight.controller.yang.binding.RpcService;\r
-\r
-/**\r
- * Binding-aware core of the SAL layer responsible for wiring the SAL consumers.\r
- * \r
- * The responsibility of the broker is to maintain registration of SAL\r
- * functionality {@link Consumer}s and {@link Provider}s, store provider and\r
- * consumer specific context and functionality registration via\r
- * {@link ConsumerSession} and provide access to infrastructure services, which\r
- * removes direct dependencies between providers and consumers.\r
- * \r
- * The Binding-aware broker is also responsible for translation from Java\r
- * classes modeling the functionality and data to binding-indpenedent form which\r
- * is used in SAL Core.\r
- * \r
- * \r
- * <h3>Infrastructure services</h3> Some examples of infrastructure services:\r
- * \r
- * <ul>\r
- * <li>YANG Module service - see {@link ConsumerSession#getRpcService(Class)},\r
- * {@link ProviderSession}\r
- * <li>Notification Service - see {@link NotificationService} and\r
- * {@link NotificationProviderService}\r
- * <li>Functionality and Data model\r
- * <li>Data Store access and modification - see {@link DataBrokerService} and\r
- * {@link DataProviderService}\r
- * </ul>\r
- * \r
- * The services are exposed via session.\r
- * \r
- * <h3>Session-based access</h3>\r
- * \r
- * The providers and consumers needs to register in order to use the\r
- * binding-independent SAL layer and to expose functionality via SAL layer.\r
- * \r
- * For more information about session-based access see {@link ConsumerSession}\r
- * and {@link ProviderSession}\r
- * \r
- * \r
-\r
- * \r
- */\r
-public interface BindingAwareBroker {\r
- /**\r
- * Registers the {@link BindingAwareConsumer}, which will use the SAL layer.\r
- * \r
- * <p>\r
- * Note that consumer could register additional functionality at later point\r
- * by using service and functionality specific APIs.\r
- * \r
- * <p>\r
- * The consumer is required to use returned session for all communication\r
- * with broker or one of the broker services. The session is announced to\r
- * the consumer by invoking\r
- * {@link Consumer#onSessionInitiated(ConsumerSession)}.\r
- * \r
- * @param cons\r
- * Consumer to be registered.\r
- * @return a session specific to consumer registration\r
- * @throws IllegalArgumentException\r
- * If the consumer is <code>null</code>.\r
- * @throws IllegalStateException\r
- * If the consumer is already registered.\r
- */\r
- ConsumerSession registerConsumer(BindingAwareConsumer consumer);\r
-\r
- /**\r
- * Registers the {@link BindingAwareProvider}, which will use the SAL layer.\r
- * \r
- * <p>\r
- * During the registration, the broker obtains the initial functionality\r
- * from consumer, using the\r
- * {@link BindingAwareProvider#getImplementations()}, and register that\r
- * functionality into system and concrete infrastructure services.\r
- * \r
- * <p>\r
- * Note that provider could register additional functionality at later point\r
- * by using service and functionality specific APIs.\r
- * \r
- * <p>\r
- * The consumer is <b>required to use</b> returned session for all\r
- * communication with broker or one of the broker services. The session is\r
- * announced to the consumer by invoking\r
- * {@link BindingAwareProvider#onSessionInitiated(ProviderSession)}.\r
- * \r
- * \r
- * @param prov\r
- * Provider to be registered.\r
- * @return a session unique to the provider registration.\r
- * @throws IllegalArgumentException\r
- * If the provider is <code>null</code>.\r
- * @throws IllegalStateException\r
- * If the consumer is already registered.\r
- */\r
- ProviderSession registerProvider(BindingAwareProvider provider);\r
-\r
- /**\r
- * {@link BindingAwareConsumer} specific access to the SAL functionality.\r
- * \r
- * <p>\r
- * ConsumerSession is {@link BindingAwareConsumer}-specific access to the\r
- * SAL functionality and infrastructure services.\r
- * \r
- * <p>\r
- * The session serves to store SAL context (e.g. registration of\r
- * functionality) for the consumer and provides access to the SAL\r
- * infrastructure services and other functionality provided by\r
- * {@link Provider}s.\r
- * \r
-\r
- * \r
- */\r
- public interface ConsumerSession {\r
-\r
- /**\r
- * Returns a session specific instance (implementation) of requested\r
- * binding-aware infrastructural service\r
- * \r
- * @param service\r
- * Broker service\r
- * @return Session specific implementation of service\r
- */\r
- <T extends BindingAwareService> T getSALService(Class<T> service);\r
-\r
- /**\r
- * Returns a session specific instance (implementation) of requested\r
- * YANG module implentation / service provided by consumer.\r
- * \r
- * @param service\r
- * Broker service\r
- * @return Session specific implementation of service\r
- */\r
- <T extends RpcService> T getRpcService(Class<T> module);\r
- }\r
-\r
- /**\r
- * {@link BindingAwareProvider} specific access to the SAL functionality.\r
- * \r
- * <p>\r
- * ProviderSession is {@link BindingAwareProvider}-specific access to the\r
- * SAL functionality and infrastructure services, which also allows for\r
- * exposing the provider's functionality to the other\r
- * {@link BindingAwareConsumer}s.\r
- * \r
- * <p>\r
- * The session serves to store SAL context (e.g. registration of\r
- * functionality) for the providers and exposes access to the SAL\r
- * infrastructure services, dynamic functionality registration and any other\r
- * functionality provided by other {@link BindingAwareConsumer}s.\r
- * \r
- */\r
- public interface ProviderSession extends ConsumerSession {\r
-\r
- void addImplementation(RpcService implementation);\r
-\r
- void removeImplementation(RpcService implementation);\r
- }\r
-}\r
+/*
+ * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.controller.sal.binding.api;
+
+import org.opendaylight.controller.sal.binding.api.data.DataBrokerService;
+import org.opendaylight.controller.sal.binding.api.data.DataProviderService;
+import org.opendaylight.yangtools.yang.binding.RpcService;
+import org.osgi.framework.BundleContext;
+
+/**
+ * Binding-aware core of the SAL layer responsible for wiring the SAL consumers.
+ *
+ * The responsibility of the broker is to maintain registration of SAL
+ * functionality {@link Consumer}s and {@link Provider}s, store provider and
+ * consumer specific context and functionality registration via
+ * {@link ConsumerContext} and provide access to infrastructure services, which
+ * removes direct dependencies between providers and consumers.
+ *
+ * The Binding-aware broker is also responsible for translation from Java
+ * classes modeling the functionality and data to binding-indpenedent form which
+ * is used in SAL Core.
+ *
+ *
+ * <h3>Infrastructure services</h3> Some examples of infrastructure services:
+ *
+ * <ul>
+ * <li>YANG Module service - see {@link ConsumerContext#getRpcService(Class)},
+ * {@link ProviderContext}
+ * <li>Notification Service - see {@link NotificationService} and
+ * {@link NotificationProviderService}
+ * <li>Functionality and Data model
+ * <li>Data Store access and modification - see {@link DataBrokerService} and
+ * {@link DataProviderService}
+ * </ul>
+ *
+ * The services are exposed via session.
+ *
+ * <h3>Session-based access</h3>
+ *
+ * The providers and consumers needs to register in order to use the
+ * binding-independent SAL layer and to expose functionality via SAL layer.
+ *
+ * For more information about session-based access see {@link ConsumerContext}
+ * and {@link ProviderContext}
+ *
+ *
+ *
+ */
+public interface BindingAwareBroker {
+ /**
+ * Registers the {@link BindingAwareConsumer}, which will use the SAL layer.
+ *
+ * <p>
+ * Note that consumer could register additional functionality at later point
+ * by using service and functionality specific APIs.
+ *
+ * <p>
+ * The consumer is required to use returned session for all communication
+ * with broker or one of the broker services. The session is announced to
+ * the consumer by invoking
+ * {@link Consumer#onSessionInitiated(ConsumerContext)}.
+ *
+ * @param cons
+ * Consumer to be registered.
+ * @return a session specific to consumer registration
+ * @throws IllegalArgumentException
+ * If the consumer is <code>null</code>.
+ * @throws IllegalStateException
+ * If the consumer is already registered.
+ */
+ ConsumerContext registerConsumer(BindingAwareConsumer consumer, BundleContext ctx);
+
+ /**
+ * Registers the {@link BindingAwareProvider}, which will use the SAL layer.
+ *
+ * <p>
+ * During the registration, the broker obtains the initial functionality
+ * from consumer, using the
+ * {@link BindingAwareProvider#getImplementations()}, and register that
+ * functionality into system and concrete infrastructure services.
+ *
+ * <p>
+ * Note that provider could register additional functionality at later point
+ * by using service and functionality specific APIs.
+ *
+ * <p>
+ * The consumer is <b>required to use</b> returned session for all
+ * communication with broker or one of the broker services. The session is
+ * announced to the consumer by invoking
+ * {@link BindingAwareProvider#onSessionInitiated(ProviderContext)}.
+ *
+ *
+ * @param prov
+ * Provider to be registered.
+ * @return a session unique to the provider registration.
+ * @throws IllegalArgumentException
+ * If the provider is <code>null</code>.
+ * @throws IllegalStateException
+ * If the consumer is already registered.
+ */
+ ProviderContext registerProvider(BindingAwareProvider provider, BundleContext ctx);
+
+ /**
+ * {@link BindingAwareConsumer} specific access to the SAL functionality.
+ *
+ * <p>
+ * ConsumerSession is {@link BindingAwareConsumer}-specific access to the
+ * SAL functionality and infrastructure services.
+ *
+ * <p>
+ * The session serves to store SAL context (e.g. registration of
+ * functionality) for the consumer and provides access to the SAL
+ * infrastructure services and other functionality provided by
+ * {@link Provider}s.
+ *
+ *
+ *
+ */
+ public interface ConsumerContext {
+
+ /**
+ * Returns a session specific instance (implementation) of requested
+ * binding-aware infrastructural service
+ *
+ * @param service
+ * Broker service
+ * @return Session specific implementation of service
+ */
+ <T extends BindingAwareService> T getSALService(Class<T> service);
+
+ /**
+ * Returns a session specific instance (implementation) of requested
+ * YANG module implentation / service provided by consumer.
+ *
+ * @param service
+ * Broker service
+ * @return Session specific implementation of service
+ */
+ <T extends RpcService> T getRpcService(Class<T> module);
+ }
+
+ /**
+ * {@link BindingAwareProvider} specific access to the SAL functionality.
+ *
+ * <p>
+ * ProviderSession is {@link BindingAwareProvider}-specific access to the
+ * SAL functionality and infrastructure services, which also allows for
+ * exposing the provider's functionality to the other
+ * {@link BindingAwareConsumer}s.
+ *
+ * <p>
+ * The session serves to store SAL context (e.g. registration of
+ * functionality) for the providers and exposes access to the SAL
+ * infrastructure services, dynamic functionality registration and any other
+ * functionality provided by other {@link BindingAwareConsumer}s.
+ *
+ */
+ public interface ProviderContext extends ConsumerContext {
+
+ <T extends RpcService> RpcServiceRegistration<T> addRpcImplementation(Class<T> type, T implementation);
+ }
+
+ public interface RpcServiceRegistration<T extends RpcService> {
+
+ T getService();
+
+ void unregister();
+ }
+}