use of org.opendaylight.mdsal.dom.spi.RpcRoutingStrategy in project controller by opendaylight.
the class ActionProviderBean method registerFallback.
private void registerFallback(final Class<RpcService> interfaceClass) {
final Collection<QName> paths = RpcUtil.decomposeRpcService(interfaceClass, schemaService.getGlobalContext(), RpcRoutingStrategy::isContextBasedRouted);
if (paths.isEmpty()) {
LOG.warn("{}: interface {} has no actions defined", ACTION_PROVIDER, interfaceClass);
return;
}
final Set<DOMRpcIdentifier> rpcs = ImmutableSet.copyOf(Collections2.transform(paths, DOMRpcIdentifier::create));
reg = domRpcProvider.registerRpcImplementation((rpc, input) -> FluentFutures.immediateFailedFluentFuture(new DOMRpcImplementationNotAvailableException("Action %s has no instance matching %s", rpc, input)), rpcs);
LOG.debug("Registered provider for {}", interfaceName);
}
use of org.opendaylight.mdsal.dom.spi.RpcRoutingStrategy in project controller by opendaylight.
the class RpcUtil method decomposeRpcService.
static Collection<QName> decomposeRpcService(final Class<RpcService> service, final SchemaContext schemaContext, final Predicate<RpcRoutingStrategy> filter) {
final QNameModule moduleName = BindingReflections.getQNameModule(service);
final Module module = schemaContext.findModule(moduleName).orElseThrow(() -> new IllegalArgumentException("Module not found in SchemaContext: " + moduleName + "; service: " + service));
LOG.debug("Resolved service {} to module {}", service, module);
final Collection<? extends RpcDefinition> rpcs = module.getRpcs();
final Collection<QName> ret = new ArrayList<>(rpcs.size());
for (RpcDefinition rpc : rpcs) {
final RpcRoutingStrategy strategy = RpcRoutingStrategy.from(rpc);
if (filter.test(strategy)) {
ret.add(rpc.getQName());
}
}
return ret;
}
use of org.opendaylight.mdsal.dom.spi.RpcRoutingStrategy in project mdsal by opendaylight.
the class RpcServiceAdapter method createStrategy.
private RpcInvocationStrategy createStrategy(final Method method, final RpcDefinition schema) {
final QName rpcType = schema.getQName();
final RpcRoutingStrategy strategy = RpcRoutingStrategy.from(schema);
return strategy.isContextBasedRouted() ? new RoutedStrategy(rpcType, method, strategy.getLeaf()) : new NonRoutedStrategy(rpcType);
}
use of org.opendaylight.mdsal.dom.spi.RpcRoutingStrategy in project mdsal by opendaylight.
the class DOMRpcRoutingTable method createOperationEntry.
@Override
AbstractDOMRpcRoutingTableEntry createOperationEntry(final EffectiveModelContext context, final QName key, final Map<YangInstanceIdentifier, List<DOMRpcImplementation>> implementations) {
final RpcDefinition rpcDef = findRpcDefinition(context, key);
if (rpcDef == null) {
return new UnknownDOMRpcRoutingTableEntry(key, implementations);
}
final RpcRoutingStrategy strategy = RpcRoutingStrategy.from(rpcDef);
if (strategy.isContextBasedRouted()) {
return new RoutedDOMRpcRoutingTableEntry(rpcDef, YangInstanceIdentifier.of(strategy.getLeaf()), implementations);
}
return new GlobalDOMRpcRoutingTableEntry(rpcDef, implementations);
}
Aggregations