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