Merge "Fix clustering versions"
[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.RpcService;
18
19 /**
20  * RpcRouter is responsible for selecting RpcService based on provided routing
21  * context identifier {@link RpcRoutingTable#getContextIdentifier()} and path in
22  * overall data tree (@link {@link InstanceIdentifier}.
23  *
24  *
25  * @author Tony Tkacik <ttkacik@cisco.com>
26  *
27  * @param <T>
28  *            Type of RpcService for which router provides routing information
29  *            and route selection.
30  */
31 public interface RpcRouter<T extends RpcService> extends //
32         RouteChangePublisher<Class<? extends BaseIdentity>, InstanceIdentifier<?>> {
33
34     /**
35      * Returns a type of RpcService which is served by this instance of router.
36      *
37      * @return type of RpcService which is served by this instance of router.
38      */
39     Class<T> getServiceType();
40
41
42     /**
43      * Returns a instance of T which is associated with this router instance
44      * and routes messages based on routing tables.
45      *
46      * @return type of RpcService which is served by this instance of router.
47      */
48     T getInvocationProxy();
49
50     /**
51      * Returns a routing table for particular route context
52      *
53      * @param routeContext
54      * @return Routing Table for particular route context.
55      */
56     <C extends BaseIdentity> RpcRoutingTable<C, T> getRoutingTable(Class<C> routeContext);
57
58     /**
59      * Returns an instance of RpcService which is responsible for processing
60      * particular path.
61      *
62      * @param context
63      *            Rpc Routing Context
64      * @param path
65      *            Instance Identifier which is used as a selector of instance.
66      * @return instance of RpcService which is responsible for processing
67      *         particular path.
68      */
69     T getService(Class<? extends BaseIdentity> context, InstanceIdentifier<?> path);
70
71     /**
72      * Returns a default fallback instance of RpcService which is responsible
73      * for handling all unknown imports.
74      *
75      * @return default instance responsible for processing RPCs.
76      */
77     T getDefaultService();
78
79     Set<Class<? extends BaseIdentity>> getContexts();
80
81     RoutedRpcRegistration<T> addRoutedRpcImplementation(T service);
82
83     RpcRegistration<T> registerDefaultService(T service);
84
85 }