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.DataContainer
12 import org.opendaylight.yangtools.yang.binding.RpcImplementation
14 class RpcRouterCodegenInstance<T extends RpcService> implements RpcRouter<T> {
20 val RpcImplementation invokerDelegate;
23 val Class<T> serviceType
26 val Set<Class<? extends BaseIdentity>> contexts
29 val Set<Class<? extends DataContainer>> supportedInputs;
31 val routingTables = new HashMap<Class<? extends BaseIdentity>, RpcRoutingTableImpl<? extends BaseIdentity, ? extends RpcService>>;
36 new(Class<T> type, T routerImpl, Set<Class<? extends BaseIdentity>> contexts,
37 Set<Class<? extends DataContainer>> inputs) {
39 _invocationProxy = routerImpl
40 _invokerDelegate = routerImpl as RpcImplementation
42 _supportedInputs = inputs;
44 for (ctx : contexts) {
45 val table = XtendHelper.createRoutingTable(ctx)
46 invocationProxy.setRoutingTable(ctx, table.routes);
47 routingTables.put(ctx, table);
51 override <C extends BaseIdentity> getRoutingTable(Class<C> table) {
52 routingTables.get(table) as RpcRoutingTable<C,T>
55 override getService(Class<? extends BaseIdentity> context, InstanceIdentifier<?> path) {
56 val table = getRoutingTable(context);
57 return table.getRoute(path);
60 override <T extends DataContainer> invoke(Class<T> type, T input) {
61 return invokerDelegate.invoke(type, input);