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 static org.opendaylight.controller.sal.binding.codegen.impl.XtendHelper.* import org.opendaylight.yangtools.yang.binding.DataContainer import org.opendaylight.yangtools.yang.binding.RpcImplementation class RpcRouterCodegenInstance implements RpcRouter { @Property val T invocationProxy @Property val RpcImplementation invokerDelegate; @Property val Class serviceType @Property val Set> contexts @Property val Set> supportedInputs; val routingTables = new HashMap, RpcRoutingTableImpl>; @Property var T defaultService new(Class type, T routerImpl, Set> contexts, Set> inputs) { _serviceType = type _invocationProxy = routerImpl _invokerDelegate = routerImpl as RpcImplementation _contexts = contexts _supportedInputs = inputs; 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); } override invoke(Class type, T input) { return invokerDelegate.invoke(type, input); } }