1 package org.opendaylight.controller.sal.binding.codegen.impl
3 import org.opendaylight.yangtools.yang.binding.RpcService
4 import org.opendaylight.controller.sal.binding.spi.RpcRouter
5 import org.opendaylight.yangtools.yang.binding.BaseIdentity
6 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier
7 import static extension org.opendaylight.controller.sal.binding.codegen.RuntimeCodeHelper.*
9 import java.util.HashMap
10 import org.opendaylight.controller.sal.binding.spi.RpcRoutingTable
11 import org.opendaylight.yangtools.yang.binding.DataObject
12 import static org.opendaylight.controller.sal.binding.codegen.impl.XtendHelper.*
14 class RpcRouterCodegenInstance<T extends RpcService> implements RpcRouter<T> {
20 val Class<T> rpcServiceType
23 val Set<Class<? extends BaseIdentity>> contexts
25 val routingTables = new HashMap<Class<? extends BaseIdentity>, RpcRoutingTableImpl<? extends BaseIdentity, ?>>;
30 new(Class<T> type, T routerImpl, Set<Class<? extends BaseIdentity>> contexts) {
31 _rpcServiceType = type
32 _invocationProxy = routerImpl
35 for (ctx : contexts) {
36 val table = XtendHelper.createRoutingTable(ctx)
37 invocationProxy.setRoutingTable(ctx, table.routes);
38 routingTables.put(ctx, table);
42 override <C extends BaseIdentity> getRoutingTable(Class<C> table) {
43 routingTables.get(table) as RpcRoutingTable<C,T>
46 override getService(Class<? extends BaseIdentity> context, InstanceIdentifier<?> path) {
47 val table = getRoutingTable(context);
48 return table.getRoute(path);