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 static org.opendaylight.controller.sal.binding.codegen.impl.XtendHelper.*
12 import org.opendaylight.yangtools.yang.binding.DataContainer
13 import org.opendaylight.yangtools.yang.binding.RpcImplementation
15 class RpcRouterCodegenInstance<T extends RpcService> implements RpcRouter<T> {
21 val RpcImplementation invokerDelegate;
24 val Class<T> serviceType
27 val Set<Class<? extends BaseIdentity>> contexts
30 val Set<Class<? extends DataContainer>> supportedInputs;
32 val routingTables = new HashMap<Class<? extends BaseIdentity>, RpcRoutingTableImpl<? extends BaseIdentity, ? extends RpcService>>;
37 new(Class<T> type, T routerImpl, Set<Class<? extends BaseIdentity>> contexts,
38 Set<Class<? extends DataContainer>> inputs) {
40 _invocationProxy = routerImpl
41 _invokerDelegate = routerImpl as RpcImplementation
43 _supportedInputs = inputs;
45 for (ctx : contexts) {
46 val table = XtendHelper.createRoutingTable(ctx)
47 invocationProxy.setRoutingTable(ctx, table.routes);
48 routingTables.put(ctx, table);
52 override <C extends BaseIdentity> getRoutingTable(Class<C> table) {
53 routingTables.get(table) as RpcRoutingTable<C,T>
56 override getService(Class<? extends BaseIdentity> context, InstanceIdentifier<?> path) {
57 val table = getRoutingTable(context);
58 return table.getRoute(path);
61 override <T extends DataContainer> invoke(Class<T> type, T input) {
62 return invokerDelegate.invoke(type, input);