package org.opendaylight.controller.sal.binding.codegen.impl import org.opendaylight.yangtools.yang.binding.RpcService import org.opendaylight.controller.sal.binding.spi.RpcRouter import org.opendaylight.yangtools.yang.binding.BaseIdentity import org.opendaylight.yangtools.yang.binding.InstanceIdentifier import static extension org.opendaylight.controller.sal.binding.codegen.RuntimeCodeHelper.* import java.util.Set import java.util.HashMap import org.opendaylight.controller.sal.binding.spi.RpcRoutingTable import org.opendaylight.yangtools.yang.binding.DataObject import static org.opendaylight.controller.sal.binding.codegen.impl.XtendHelper.* class RpcRouterCodegenInstance implements RpcRouter { @Property val T invocationProxy @Property val Class rpcServiceType @Property val Set> contexts val routingTables = new HashMap, RpcRoutingTableImpl>; @Property var T defaultService new(Class type, T routerImpl, Set> contexts) { _rpcServiceType = type _invocationProxy = routerImpl _contexts = contexts for (ctx : contexts) { val table = XtendHelper.createRoutingTable(ctx) invocationProxy.setRoutingTable(ctx, table.routes); routingTables.put(ctx, table); } } override getRoutingTable(Class table) { routingTables.get(table) as RpcRoutingTable } override getService(Class context, InstanceIdentifier path) { val table = getRoutingTable(context); return table.getRoute(path); } }