@Override public SchemaPath getPath() { return delegate.getPath(); }
@Override public DOMRpcIdentifier apply(final RpcDefinition input) { // TODO add support for routed rpcs ... is it necessary in this case ? return DOMRpcIdentifier.create(input.getPath()); } };
/** * Get RPC schema path. * * @param type * - RPC implementation class type * @return schema path of RPC */ public SchemaPath getRpcPath(final Class<? extends Rpc<?, ?>> type) { final RpcDefinition schema = runtimeContext.getRpcDefinition(type); checkArgument(schema != null, "Failed to find schema for %s", type); return schema.getPath(); }
/** * Add all the locally registered RPCs in the clustered routing table */ private void announceSupportedRpcs(){ LOG.debug("Adding all supported rpcs to routing table"); final Set<RpcDefinition> currentlySupportedRpc = schemaContext.getOperations(); final List<DOMRpcIdentifier> rpcs = new ArrayList<>(); for (final RpcDefinition rpcDef : currentlySupportedRpc) { rpcs.add(DOMRpcIdentifier.create(rpcDef.getPath())); } if(!rpcs.isEmpty()) { rpcListener.onRpcAvailable(rpcs); } }
static Collection<SchemaPath> 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<RpcDefinition> rpcs = module.getRpcs(); final Collection<SchemaPath> ret = new ArrayList<>(rpcs.size()); for (RpcDefinition rpc : rpcs) { final RpcRoutingStrategy strategy = RpcRoutingStrategy.from(rpc); if (filter.test(strategy)) { ret.add(rpc.getPath()); } } return ret; } }
private RpcInvocationStrategy createStrategy(final Class<? extends Rpc<?, ?>> rpcInterface) { final RpcDefinition rpc = codec.getRpcDefinition(rpcInterface); final RpcRoutingStrategy domStrategy = RpcRoutingStrategy.from(rpc); if (domStrategy.isContextBasedRouted()) { try { return new RoutedStrategy(rpc.getPath(), rpcInterface.getMethod("invoke", Input.class, RpcCallback.class), domStrategy.getLeaf()); } catch (final NoSuchMethodException e) { throw new IllegalStateException("Can not find 'invoke' method", e); } } return new NonRoutedStrategy(rpc.getPath()); }
private void registerRoutedRpcDelegate() { final Set<DOMRpcIdentifier> rpcIdentifiers = new HashSet<>(); final Set<Module> modules = schemaContext.getModules(); for(final Module module : modules){ for(final RpcDefinition rpcDefinition : module.getRpcs()){ if(RpcRoutingStrategy.from(rpcDefinition).isContextBasedRouted()) { LOG.debug("Adding routed rpcDefinition for path {}", rpcDefinition.getPath()); rpcIdentifiers.add(DOMRpcIdentifier.create(rpcDefinition.getPath(), YangInstanceIdentifier.EMPTY)); } } } rpcProvisionRegistry.registerRpcImplementation(rpcImplementation, rpcIdentifiers); }
private RpcInvocationStrategy createStrategy(final Method method, final RpcDefinition schema) { final RpcRoutingStrategy strategy = RpcRoutingStrategy.from(schema); if (strategy.isContextBasedRouted()) { return new RoutedStrategy(schema.getPath(), method, strategy.getLeaf()); } return new NonRoutedStrategy(schema.getPath()); }
private RpcInvocationStrategy createStrategy(final Method method, final RpcDefinition schema) { final RpcRoutingStrategy strategy = RpcRoutingStrategy.from(schema); if (strategy.isContextBasedRouted()) { return new RoutedStrategy(schema.getPath(), method, strategy.getLeaf()); } return new NonRoutedStrategy(schema.getPath()); }
private void retrievedSchemaContext(SchemaContext schemaContext) { LOG.debug("{}: retrievedSchemaContext", logName()); QNameModule moduleName = BindingReflections.getQNameModule(rpcInterface); Module module = schemaContext.findModuleByNamespaceAndRevision(moduleName.getNamespace(), moduleName.getRevision()); LOG.debug("{}: Got Module: {}", logName(), module); rpcSchemaPaths = new HashSet<>(); for(RpcDefinition rpcDef : module.getRpcs()) { rpcSchemaPaths.add(rpcDef.getPath()); } LOG.debug("{}: Got SchemaPaths: {}", logName(), rpcSchemaPaths); // First get the DOMRpcService OSGi service. This will be used to register a listener to be notified // when the underlying DOM RPC service is available. retrieveService("DOMRpcService", DOMRpcService.class, service -> retrievedDOMRpcService((DOMRpcService)service)); }
public final ImmutableBiMap<Method, SchemaPath> getRpcMethodToSchemaPath(final Class<? extends RpcService> key) { final Module module = getModuleBlocking(key); final ImmutableBiMap.Builder<Method, SchemaPath> ret = ImmutableBiMap.builder(); try { for (final RpcDefinition rpcDef : module.getRpcs()) { final Method method = findRpcMethod(key, rpcDef); ret.put(method, rpcDef.getPath()); } } catch (final NoSuchMethodException e) { throw new IllegalStateException("Rpc defined in model does not have representation in generated class.", e); } return ret.build(); }
public ImmutableBiMap<Method, SchemaPath> getRpcMethodToSchemaPath(final Class<? extends RpcService> key) { final Module module = getModuleBlocking(key); final ImmutableBiMap.Builder<Method, SchemaPath> ret = ImmutableBiMap.<Method, SchemaPath>builder(); try { for (final RpcDefinition rpcDef : module.getRpcs()) { final Method method = findRpcMethod(key, rpcDef); ret.put(method, rpcDef.getPath()); } } catch (final NoSuchMethodException e) { throw new IllegalStateException("Rpc defined in model does not have representation in generated class.", e); } return ret.build(); }
/** * Resolve method with path of specific RPC as binding object. * * @param key * - RPC as binding object * @return map of method with path of specific RPC */ @Deprecated public ImmutableBiMap<Method, SchemaPath> getRPCMethodToSchemaPath(final Class<?> key) { final Module module = getModuleBlocking(key); final ImmutableBiMap.Builder<Method, SchemaPath> ret = ImmutableBiMap.builder(); try { for (final RpcDefinition rpcDef : module.getRpcs()) { final Method method = runtimeContext.findOperationMethod(key, rpcDef); ret.put(method, rpcDef.getPath()); } } catch (final NoSuchMethodException e) { throw new IllegalStateException("RPC defined in model does not have representation in generated class.", e); } return ret.build(); }