Binding2 - Implement RpcActionProviderService
[mdsal.git] / binding2 / mdsal-binding2-api / src / main / java / org / opendaylight / mdsal / binding / javav2 / api / RpcActionProviderService.java
1 /*
2  * Copyright (c) 2017 Pantheon Technologies s.r.o. and others.  All rights reserved.
3  *
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
7  */
8
9 package org.opendaylight.mdsal.binding.javav2.api;
10
11 import com.google.common.annotations.Beta;
12 import com.google.common.collect.ImmutableSet;
13 import java.util.Set;
14 import org.opendaylight.mdsal.binding.javav2.spec.base.Action;
15 import org.opendaylight.mdsal.binding.javav2.spec.base.InstanceIdentifier;
16 import org.opendaylight.mdsal.binding.javav2.spec.base.Rpc;
17 import org.opendaylight.mdsal.binding.javav2.spec.base.TreeNode;
18 import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
19 import org.opendaylight.yangtools.concepts.ObjectRegistration;
20
21 /**
22  * Provides ability to register Remote Procedure Call (RPC) and Action service implementations.
23  * The RPCs and Actions are defined in YANG models.
24  */
25 @Beta
26 public interface RpcActionProviderService {
27
28     /**
29      * Returns class representing registration of global RPC.
30      * @param type RPC binding generated interface
31      * @param implementation RPC binding implementation
32      * @param <S> service class type
33      * @param <T> service implementation type
34      * @return returns class representing a RPC registration
35      */
36     <S extends Rpc<?, ?>, T extends S> ObjectRegistration<T> registerRpcImplementation(Class<S> type,
37         T implementation);
38
39     /**
40      * Returns class representing registration of global RPC for supported paths.
41      * @param type RPC binding generated interface
42      * @param implementation RPC binding implementation
43      * @param paths set of supported paths
44      * @param <S> service class type
45      * @param <T> service implementation type
46      * @return returns class representing a RPC registration
47      */
48     <S extends Rpc<?, ?>, T extends S> ObjectRegistration<T> registerRpcImplementation(Class<S> type,
49         T implementation, Set<InstanceIdentifier<?>> paths);
50
51     /**
52      * Returns class representing registration of Action/ListAction.
53      * @param type Action/ListAction binding generated interface
54      * @param implementation Action/ListAction binding implementation
55      * @param datastore {@link LogicalDatastoreType} on which the implementation operates
56      * @param validNodes Set of nodes this implementation is constrained to, empty if this implementation can handle
57      *                   any target node.
58      * @param <S> service class type
59      * @param <P> parent type
60      * @param <T> service implementation type
61      * @return returns class representing a Action registration
62      */
63     <S extends Action<? extends TreeNode, ?, ?, ?>, T extends S, P extends TreeNode> ObjectRegistration<T>
64             registerActionImplementation(
65         Class<S> type, T implementation, LogicalDatastoreType datastore, Set<DataTreeIdentifier<P>> validNodes);
66
67     default <S extends Action<? extends TreeNode, ?, ?, ?>, T extends S> ObjectRegistration<T>
68             registerActionImplementation(Class<S> type, T implementation, LogicalDatastoreType datastore) {
69         return registerActionImplementation(type, implementation, datastore, ImmutableSet.of());
70     }
71
72     default <S extends Action<? extends TreeNode, ?, ?, ?>, T extends S> ObjectRegistration<T>
73             registerActionImplementation(Class<S> type, T implementation) {
74         return registerActionImplementation(type, implementation, LogicalDatastoreType.OPERATIONAL, ImmutableSet.of());
75     }
76 }