Merge "increased test coverage"
[controller.git] / opendaylight / md-sal / sal-binding-api / src / main / java / org / opendaylight / controller / sal / binding / api / rpc / RpcRouter.java
1 /*
2  * Copyright (c) 2013 Cisco Systems, Inc. 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 package org.opendaylight.controller.sal.binding.api.rpc;
9
10 import java.util.Set;
11
12 import org.opendaylight.controller.md.sal.common.api.routing.RouteChangePublisher;
13 import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.RoutedRpcRegistration;
14 import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.RpcRegistration;
15 import org.opendaylight.yangtools.yang.binding.BaseIdentity;
16 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
17 import org.opendaylight.yangtools.yang.binding.RpcImplementation;
18 import org.opendaylight.yangtools.yang.binding.RpcService;
19
20 /**
21  * RpcRouter is responsible for selecting RpcService based on provided routing
22  * context identifier {@link RpcRoutingTable#getContextIdentifier()} and path in
23  * overal data tree (@link {@link InstanceIdentifier}.
24  * 
25  * 
26  * @author Tony Tkacik <ttkacik@cisco.com>
27  * 
28  * @param <T>
29  *            Type of RpcService for which router provides routing information
30  *            and route selection.
31  */
32 public interface RpcRouter<T extends RpcService> extends //
33         RouteChangePublisher<Class<? extends BaseIdentity>, InstanceIdentifier<?>> {
34
35     /**
36      * Returns a type of RpcService which is served by this instance of router.
37      * 
38      * @return type of RpcService which is served by this instance of router.
39      */
40     Class<T> getServiceType();
41     
42     
43     /**
44      * Returns a instance of T which is associated with this router instance
45      * and routes messages based on routing tables.
46      * 
47      * @return type of RpcService which is served by this instance of router.
48      */
49     T getInvocationProxy();
50
51     /**
52      * Returns a routing table for particular route context
53      * 
54      * @param routeContext
55      * @return Routing Table for particular route context.
56      */
57     <C extends BaseIdentity> RpcRoutingTable<C, T> getRoutingTable(Class<C> routeContext);
58
59     /**
60      * Returns an instance of RpcService which is responsible for processing
61      * particular path.
62      * 
63      * @param context
64      *            Rpc Routing Context
65      * @param path
66      *            Instance Identifier which is used as a selector of instance.
67      * @return instance of RpcService which is responsible for processing
68      *         particular path.
69      */
70     T getService(Class<? extends BaseIdentity> context, InstanceIdentifier<?> path);
71
72     /**
73      * Returns a default fallback instance of RpcService which is responsible
74      * for handling all unknown imports.
75      * 
76      * @return default instance responsible for processing RPCs.
77      */
78     T getDefaultService();
79
80     Set<Class<? extends BaseIdentity>> getContexts();
81     
82     RoutedRpcRegistration<T> addRoutedRpcImplementation(T service);
83     
84     RpcRegistration<T> registerDefaultService(T service);
85
86 }