@Override public Set<RpcDefinition> getOperations() { final Set<RpcDefinition> rpcs = new HashSet<>(); for (Module m : getModules()) { rpcs.addAll(m.getRpcs()); } return rpcs; }
@Override public Set<RpcDefinition> getOperations() { final Set<RpcDefinition> rpcs = new HashSet<>(); for (Module m : getModules()) { rpcs.addAll(m.getRpcs()); } return rpcs; }
private static RpcDefinition getRpcByName(final Module module, final QName name) { for (final RpcDefinition rpc : module.getRpcs()) { if (rpc.getQName().equals(name)) { return rpc; } } return null; }
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 Optional<RpcDefinition> getRpcDefinitionFromModule(Module module, URI namespaceURI, String name) { for (RpcDefinition rpcDef : module.getRpcs()) { if (rpcDef.getQName().getNamespace().equals(namespaceURI) && rpcDef.getQName().getLocalName().equals(name)) { return Optional.of(rpcDef); } } return Optional.absent(); }
private Optional<RpcDefinition> getRpcDefinitionFromModule(Module module, URI namespaceURI, String name) { for (RpcDefinition rpcDef : module.getRpcs()) { if (rpcDef.getQName().getNamespace().equals(namespaceURI) && rpcDef.getQName().getLocalName().equals(name)) { return Optional.of(rpcDef); } } return Optional.absent(); }
private static RpcDefinition getRpcByName(final Module module, final QName name) { for (final RpcDefinition rpc : module.getRpcs()) { if (rpc.getQName().equals(name)) { return rpc; } } return null; }
private static RpcDefinition findRpcDefinition(final SchemaContext context, final SchemaPath schemaPath) { if (context != null) { final QName qname = schemaPath.getPathFromRoot().iterator().next(); final Module module = context.findModuleByNamespaceAndRevision(qname.getNamespace(), qname.getRevision()); if (module != null && module.getRpcs() != null) { for (RpcDefinition rpc : module.getRpcs()) { if (qname.equals(rpc.getQName())) { return rpc; } } } } return null; }
private static RpcDefinition findRpc(final SchemaContext schemaContext, final String identifierDecoded) { final String[] splittedIdentifier = identifierDecoded.split(":"); if (splittedIdentifier.length != 2) { final String errMsg = identifierDecoded + " couldn't be splitted to 2 parts (module:rpc name)"; LOG.debug(errMsg); throw new RestconfDocumentedException(errMsg, ErrorType.APPLICATION, ErrorTag.INVALID_VALUE); } for (final Module module : schemaContext.getModules()) { if (module.getName().equals(splittedIdentifier[0])) { for (final RpcDefinition rpcDefinition : module.getRpcs()) { if (rpcDefinition.getQName().getLocalName().equals(splittedIdentifier[1])) { return rpcDefinition; } } } } return null; }
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); }
protected ImmutableBiMap<Method, RpcDefinition> getRpcMethodToSchema(final Class<? extends RpcService> key) { final Module module = getModuleBlocking(key); final ImmutableBiMap.Builder<Method, RpcDefinition> ret = ImmutableBiMap.builder(); try { for (final RpcDefinition rpcDef : module.getRpcs()) { final Method method = findRpcMethod(key, rpcDef); ret.put(method, rpcDef); } } catch (final NoSuchMethodException e) { throw new IllegalStateException("Rpc defined in model does not have representation in generated class.", e); } return ret.build(); }
protected ImmutableBiMap<Method, RpcDefinition> getRpcMethodToSchema(final Class<? extends RpcService> key) { final Module module = getModuleBlocking(key); final ImmutableBiMap.Builder<Method, RpcDefinition> ret = ImmutableBiMap.builder(); try { for (final RpcDefinition rpcDef : module.getRpcs()) { final Method method = findRpcMethod(key, rpcDef); ret.put(method, rpcDef); } } catch (final NoSuchMethodException e) { throw new IllegalStateException("Rpc defined in model does not have representation in generated class.", e); } return ret.build(); }
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)); }
ContainerNodeCodecContext<?> createRpcDataContext(final Class<?> key) { checkArgument(DataContainer.class.isAssignableFrom(key)); final QName qname = BindingReflections.findQName(key); final QNameModule qnameModule = qname.getModule(); final Module module = getSchema().findModule(qnameModule) .orElseThrow(() -> new IllegalArgumentException("Failed to find module for " + qnameModule)); final String className = BindingMapping.getClassName(qname); for (final RpcDefinition potential : module.getRpcs()) { final QName potentialQName = potential.getQName(); /* * Check if rpc and class represents data from same module and then checks if rpc local name produces same * class name as class name appended with Input/Output based on QName associated with binding class. * * FIXME: Rework this to have more precise logic regarding Binding Specification. */ if (key.getSimpleName().equals(BindingMapping.getClassName(potentialQName) + className)) { final ContainerSchemaNode schema = SchemaNodeUtils.getRpcDataSchema(potential, qname); checkArgument(schema != null, "Schema for %s does not define input / output.", potential.getQName()); return (ContainerNodeCodecContext<?>) DataContainerCodecPrototype.from(key, schema, factory()).get(); } } throw new IllegalArgumentException("Supplied class " + key + " is not valid RPC class."); }
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(); }
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(); }
/** * 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(); }
/** * Resolve method with definition of specific RPC as binding object. * * @param key * - RPC as binding object * @return map of method with definition of specific RPC */ public ImmutableBiMap<Method, OperationDefinition> getRPCMethodToSchema(final Class<?> key) { final Module module = getModuleBlocking(key); final ImmutableBiMap.Builder<Method, OperationDefinition> ret = ImmutableBiMap.builder(); try { for (final RpcDefinition rpcDef : module.getRpcs()) { final Method method = runtimeContext.findOperationMethod(key, rpcDef); ret.put(method, rpcDef); } } catch (final NoSuchMethodException e) { throw new IllegalStateException("RPC defined in model does not have representation in generated class.", e); } return ret.build(); }
static List<TypeDefinition<?>> getAllTypedefs(final Module module) { final List<TypeDefinition<?>> ret = new ArrayList<>(); fillRecursively(ret, module); final Set<NotificationDefinition> notifications = module.getNotifications(); for (NotificationDefinition notificationDefinition : notifications) { fillRecursively(ret, notificationDefinition); } final Set<RpcDefinition> rpcs = module.getRpcs(); for (RpcDefinition rpcDefinition : rpcs) { ret.addAll(rpcDefinition.getTypeDefinitions()); fillRecursively(ret, rpcDefinition.getInput()); fillRecursively(ret, rpcDefinition.getOutput()); } return ret; }
private void emitBodyNodes(final Module input) { for (final ExtensionDefinition extension : input.getExtensionSchemaNodes()) { emitExtension(extension); } for (final FeatureDefinition definition : input.getFeatures()) { emitFeature(definition); } for (final IdentitySchemaNode identity : input.getIdentities()) { emitIdentity(identity); } for (final Deviation deviation : input.getDeviations()) { emitDeviation(deviation); } emitDataNodeContainer(input); for (final AugmentationSchemaNode augmentation : input.getAugmentations()) { emitAugment(augmentation); } for (final RpcDefinition rpc : input.getRpcs()) { emitRpc(rpc); } emitNotifications(input.getNotifications()); }