Merge "Devices dashlet show port total numbers, modal shows collapsible list Replaced...
[controller.git] / opendaylight / sal / yang-prototype / sal / sal-core-api / src / main / java / org / opendaylight / controller / sal / core / api / Broker.java
index 9b3b47f8b17e8f312cb77b0688973b0d702e129a..f26ed901a569f9c585b9b18be456acbb055de257 100644 (file)
-/*\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.core.api;\r
-\r
-import java.util.concurrent.Future;\r
-\r
-import org.opendaylight.controller.sal.core.api.data.DataBrokerService;\r
-import org.opendaylight.controller.sal.core.api.data.DataProviderService;\r
-import org.opendaylight.controller.sal.core.api.notify.NotificationProviderService;\r
-import org.opendaylight.controller.sal.core.api.notify.NotificationService;\r
-import org.opendaylight.controller.yang.common.QName;\r
-import org.opendaylight.controller.yang.common.RpcResult;\r
-import org.opendaylight.controller.yang.data.api.CompositeNode;\r
-\r
-\r
-/**\r
- * Core component 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
- * \r
- * <h3>Infrastructure services</h3> Some examples of infrastructure services:\r
- * \r
- * <ul>\r
- * <li>RPC Invocation - see {@link ConsumerSession#rpc(QName, CompositeNode)},\r
- * {@link ProviderSession#addRpcImplementation(QName, RpcImplementation)} and\r
- * {@link RpcImplementation}\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
-public interface Broker {\r
-\r
-    /**\r
-     * Registers the {@link Consumer}, which will use the SAL layer.\r
-     * \r
-     * <p>\r
-     * During the registration, the broker obtains the initial functionality\r
-     * from consumer, using the {@link Consumer#getConsumerFunctionality()}, and\r
-     * register that functionality into system and concrete infrastructure\r
-     * services.\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(Consumer cons);\r
-\r
-    /**\r
-     * Registers the {@link Provider}, which will use the SAL layer.\r
-     * \r
-     * <p>\r
-     * During the registration, the broker obtains the initial functionality\r
-     * from consumer, using the {@link Provider#getProviderFunctionality()}, and\r
-     * register that functionality into system and concrete infrastructure\r
-     * services.\r
-     * \r
-     * <p>\r
-     * Note that consumer could register additional functionality at later point\r
-     * by using service and functionality specific APIs (e.g.\r
-     * {@link ProviderSession#addRpcImplementation(QName, RpcImplementation)}\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 Provider#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(Provider prov);\r
-\r
-    /**\r
-     * {@link Consumer} specific access to the SAL functionality.\r
-     * \r
-     * <p>\r
-     * ConsumerSession is {@link Consumer}-specific access to the SAL\r
-     * 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
-         * Sends an RPC to other components registered to the broker.\r
-         * \r
-         * @see RpcImplementation\r
-         * @param rpc\r
-         *            Name of RPC\r
-         * @param input\r
-         *            Input data to the RPC\r
-         * @return Result of the RPC call\r
-         */\r
-        Future<RpcResult<CompositeNode>> rpc(QName rpc, CompositeNode input);\r
-\r
-        boolean isClosed();\r
-\r
-        /**\r
-         * Returns a session specific instance (implementation) of requested\r
-         * service\r
-         * \r
-         * @param service\r
-         *            Broker service\r
-         * @return Session specific implementation of service\r
-         */\r
-        <T extends BrokerService> T getService(Class<T> service);\r
-\r
-        /**\r
-         * Closes a session between consumer and broker.\r
-         * \r
-         * <p>\r
-         * The close operation unregisters a consumer and remove all registered\r
-         * functionality of the consumer from the system.\r
-         * \r
-         */\r
-        void close();\r
-    }\r
-\r
-    /**\r
-     * {@link Provider} specific access to the SAL functionality.\r
-     * \r
-     * <p>\r
-     * ProviderSession is {@link Provider}-specific access to the SAL\r
-     * functionality and infrastructure services, which also allows for exposing\r
-     * the provider's functionality to the other {@link Consumer}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 Provider}s.\r
-     * \r
-     */\r
-    public interface ProviderSession extends ConsumerSession {\r
-        /**\r
-         * Registers an implementation of the rpc.\r
-         * \r
-         * <p>\r
-         * The registered rpc functionality will be available to all other\r
-         * consumers and providers registered to the broker, which are aware of\r
-         * the {@link QName} assigned to the rpc.\r
-         * \r
-         * <p>\r
-         * There is no assumption that rpc type is in the set returned by\r
-         * invoking {@link RpcImplementation#getSupportedRpcs()}. This allows\r
-         * for dynamic rpc implementations.\r
-         * \r
-         * @param rpcType\r
-         *            Name of Rpc\r
-         * @param implementation\r
-         *            Provider's Implementation of the RPC functionality\r
-         * @throws IllegalArgumentException\r
-         *             If the name of RPC is invalid\r
-         */\r
-        void addRpcImplementation(QName rpcType,\r
-                RpcImplementation implementation)\r
-                throws IllegalArgumentException;\r
-\r
-        /**\r
-         * Unregisters an Rpc implementation\r
-         * \r
-         * @param rpcType\r
-         *            Name of Rpc\r
-         * @param implementation\r
-         *            Registered Implementation of the Rpc functionality\r
-         * @throws IllegalArgumentException\r
-         */\r
-        void removeRpcImplementation(QName rpcType,\r
-                RpcImplementation implementation)\r
-                throws IllegalArgumentException;\r
-\r
-        /**\r
-         * Closes a session between provider and SAL.\r
-         * \r
-         * <p>\r
-         * The close operation unregisters a provider and remove all registered\r
-         * functionality of the provider from the system.\r
-         */\r
-        @Override\r
-        public void close();\r
-\r
-        @Override\r
-        boolean isClosed();\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.core.api;
+
+import java.util.concurrent.Future;
+
+import org.opendaylight.controller.sal.core.api.data.DataBrokerService;
+import org.opendaylight.controller.sal.core.api.data.DataProviderService;
+import org.opendaylight.controller.sal.core.api.notify.NotificationProviderService;
+import org.opendaylight.controller.sal.core.api.notify.NotificationService;
+import org.opendaylight.yangtools.yang.common.QName;
+import org.opendaylight.yangtools.yang.common.RpcResult;
+import org.opendaylight.yangtools.yang.data.api.CompositeNode;
+
+
+/**
+ * Core component 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 ConsumerSession} and provide access to infrastructure services, which
+ * removes direct dependencies between providers and consumers.
+ * 
+ * 
+ * <h3>Infrastructure services</h3> Some examples of infrastructure services:
+ * 
+ * <ul>
+ * <li>RPC Invocation - see {@link ConsumerSession#rpc(QName, CompositeNode)},
+ * {@link ProviderSession#addRpcImplementation(QName, RpcImplementation)} and
+ * {@link RpcImplementation}
+ * <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 ConsumerSession}
+ * and {@link ProviderSession}
+ * 
+ * 
+ * 
+ */
+public interface Broker {
+
+    /**
+     * Registers the {@link Consumer}, which will use the SAL layer.
+     * 
+     * <p>
+     * During the registration, the broker obtains the initial functionality
+     * from consumer, using the {@link Consumer#getConsumerFunctionality()}, and
+     * register that functionality into system and concrete infrastructure
+     * services.
+     * 
+     * <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(ConsumerSession)}.
+     * 
+     * @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.
+     */
+    ConsumerSession registerConsumer(Consumer cons);
+
+    /**
+     * Registers the {@link Provider}, which will use the SAL layer.
+     * 
+     * <p>
+     * During the registration, the broker obtains the initial functionality
+     * from consumer, using the {@link Provider#getProviderFunctionality()}, and
+     * register that functionality into system and concrete infrastructure
+     * services.
+     * 
+     * <p>
+     * Note that consumer could register additional functionality at later point
+     * by using service and functionality specific APIs (e.g.
+     * {@link ProviderSession#addRpcImplementation(QName, RpcImplementation)}
+     * 
+     * <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 Provider#onSessionInitiated(ProviderSession)}.
+     * 
+     * 
+     * @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.
+     */
+    ProviderSession registerProvider(Provider prov);
+
+    /**
+     * {@link Consumer} specific access to the SAL functionality.
+     * 
+     * <p>
+     * ConsumerSession is {@link Consumer}-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 ConsumerSession {
+
+        /**
+         * Sends an RPC to other components registered to the broker.
+         * 
+         * @see RpcImplementation
+         * @param rpc
+         *            Name of RPC
+         * @param input
+         *            Input data to the RPC
+         * @return Result of the RPC call
+         */
+        Future<RpcResult<CompositeNode>> rpc(QName rpc, CompositeNode input);
+
+        boolean isClosed();
+
+        /**
+         * Returns a session specific instance (implementation) of requested
+         * service
+         * 
+         * @param service
+         *            Broker service
+         * @return Session specific implementation of service
+         */
+        <T extends BrokerService> T getService(Class<T> service);
+
+        /**
+         * Closes a session between consumer and broker.
+         * 
+         * <p>
+         * The close operation unregisters a consumer and remove all registered
+         * functionality of the consumer from the system.
+         * 
+         */
+        void close();
+    }
+
+    /**
+     * {@link Provider} specific access to the SAL functionality.
+     * 
+     * <p>
+     * ProviderSession is {@link Provider}-specific access to the SAL
+     * functionality and infrastructure services, which also allows for exposing
+     * the provider's functionality to the other {@link Consumer}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 Provider}s.
+     * 
+     */
+    public interface ProviderSession extends ConsumerSession {
+        /**
+         * Registers an implementation of the rpc.
+         * 
+         * <p>
+         * The registered rpc functionality will be available to all other
+         * consumers and providers registered to the broker, which are aware of
+         * the {@link QName} assigned to the rpc.
+         * 
+         * <p>
+         * There is no assumption that rpc type is in the set returned by
+         * invoking {@link RpcImplementation#getSupportedRpcs()}. This allows
+         * for dynamic rpc implementations.
+         * 
+         * @param rpcType
+         *            Name of Rpc
+         * @param implementation
+         *            Provider's Implementation of the RPC functionality
+         * @throws IllegalArgumentException
+         *             If the name of RPC is invalid
+         */
+        void addRpcImplementation(QName rpcType,
+                RpcImplementation implementation)
+                throws IllegalArgumentException;
+
+        /**
+         * Unregisters an Rpc implementation
+         * 
+         * @param rpcType
+         *            Name of Rpc
+         * @param implementation
+         *            Registered Implementation of the Rpc functionality
+         * @throws IllegalArgumentException
+         */
+        void removeRpcImplementation(QName rpcType,
+                RpcImplementation implementation)
+                throws IllegalArgumentException;
+
+        /**
+         * Closes a session between provider and SAL.
+         * 
+         * <p>
+         * The close operation unregisters a provider and remove all registered
+         * functionality of the provider from the system.
+         */
+        @Override
+        public void close();
+
+        @Override
+        boolean isClosed();
+    }
+}