Initial opendaylight infrastructure commit!!
[controller.git] / opendaylight / sal / yang-prototype / sal / sal-core-api / src / main / java / org / opendaylight / controller / sal / core / api / RpcImplementation.java
1 /*\r
2  * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.\r
3  *\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
7  */\r
8 package org.opendaylight.controller.sal.core.api;\r
9 \r
10 import java.util.Set;\r
11 \r
12 import org.opendaylight.controller.sal.core.api.Broker.ConsumerSession;\r
13 import org.opendaylight.controller.sal.core.api.Broker.ProviderSession;\r
14 import org.opendaylight.controller.yang.common.QName;\r
15 import org.opendaylight.controller.yang.common.RpcResult;\r
16 import org.opendaylight.controller.yang.data.api.CompositeNode;\r
17 \r
18 /**\r
19  * {@link Provider}'s implementation of rpc.\r
20  * \r
21  * In order to expose the rpc to other components, the provider MUST register\r
22  * concrete implementation of this interface\r
23  * \r
24  * The registration could be done by :\r
25  * <ul>\r
26  * <li>returning an instance of implementation in the return value of\r
27  * {@link Provider#getProviderFunctionality()}\r
28  * <li>passing an instance of implementation and {@link QName} of rpc as\r
29  * arguments to the\r
30  * {@link ProviderSession#addRpcImplementation(QName, RpcImplementation)}\r
31  * </ul>\r
32  * \r
33  * The simplified process of the invocation of rpc is following:\r
34  * \r
35  * <ol>\r
36  * <li> {@link Consumer} invokes\r
37  * {@link ConsumerSession#rpc(QName, CompositeNode)}\r
38  * <li> {@link Broker} finds registered {@link RpcImplementation}s\r
39  * <li> {@link Broker} invokes\r
40  * {@link RpcImplementation#invokeRpc(QName, CompositeNode)}\r
41  * <li> {@link RpcImplementation} processes the data and returns a\r
42  * {@link RpcResult}\r
43  * <li> {@link Broker} returns the {@link RpcResult} to {@link Consumer}\r
44  * </ol>\r
45  * \r
46  * \r
47  */\r
48 public interface RpcImplementation extends Provider.ProviderFunctionality {\r
49 \r
50     /**\r
51      * A set of rpc types supported by implementation.\r
52      * \r
53      * The set of rpc {@link QName}s which are supported by this implementation.\r
54      * This set is used, when {@link Provider} is registered to the SAL, to\r
55      * register and expose the implementation of the returned rpcs.\r
56      * \r
57      * @return Set of QNames identifying supported RPCs\r
58      */\r
59     Set<QName> getSupportedRpcs();\r
60 \r
61     /**\r
62      * Invokes a implementation of specified rpc.\r
63      * \r
64      * \r
65      * @param rpc\r
66      *            Rpc to be invoked\r
67      * @param input\r
68      *            Input data for rpc.\r
69      * \r
70      * @throws IllegalArgumentException\r
71      *             <ul>\r
72      *             <li>If rpc is null.\r
73      *             <li>If input is not <code>null</code> and\r
74      *             <code>false == rpc.equals(input.getNodeType)</code>\r
75      *             </ul>\r
76      * @return RpcResult containing the output of rpc if was executed\r
77      *         successfully, the list of errors otherwise.\r
78      */\r
79     RpcResult<CompositeNode> invokeRpc(QName rpc, CompositeNode input);\r
80 \r
81 }\r