本文整理了Java中org.opendaylight.yangtools.yang.model.api.Module.getRpcs()
方法的一些代码示例,展示了Module.getRpcs()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Module.getRpcs()
方法的具体详情如下:
包路径:org.opendaylight.yangtools.yang.model.api.Module
类名称:Module
方法名:getRpcs
[英]Returns RpcDefinition
instances which contain data from rpc statements defined in the module.
[中]返回RpcDefinition
实例,其中包含模块中定义的rpc语句中的数据。
代码示例来源:origin: org.opendaylight.yangtools/yang-model-util
@Override
public Set<RpcDefinition> getOperations() {
final Set<RpcDefinition> rpcs = new HashSet<>();
for (Module m : getModules()) {
rpcs.addAll(m.getRpcs());
}
return rpcs;
}
代码示例来源:origin: opendaylight/yangtools
@Override
public Set<RpcDefinition> getOperations() {
final Set<RpcDefinition> rpcs = new HashSet<>();
for (Module m : getModules()) {
rpcs.addAll(m.getRpcs());
}
return rpcs;
}
代码示例来源:origin: org.opendaylight.yangtools/yang-model-util
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;
}
代码示例来源:origin: opendaylight/controller
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;
}
}
代码示例来源:origin: org.opendaylight.controller/mdsal-netconf-connector
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();
}
代码示例来源:origin: org.opendaylight.netconf/mdsal-netconf-connector
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();
}
代码示例来源:origin: opendaylight/yangtools
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;
}
代码示例来源:origin: org.opendaylight.controller/sal-broker-impl
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;
}
代码示例来源:origin: org.opendaylight.controller/sal-rest-connector
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;
}
代码示例来源:origin: org.opendaylight.controller/sal-remoterpc-connector
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);
}
代码示例来源:origin: org.opendaylight.controller/sal-binding-broker-impl
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();
}
代码示例来源:origin: org.opendaylight.mdsal/mdsal-binding-dom-adapter
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();
}
代码示例来源:origin: org.opendaylight.controller/blueprint
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));
}
代码示例来源:origin: org.opendaylight.mdsal/mdsal-binding-dom-codec
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.");
}
代码示例来源:origin: org.opendaylight.controller/sal-binding-broker-impl
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();
}
代码示例来源:origin: org.opendaylight.mdsal/mdsal-binding-dom-adapter
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();
}
代码示例来源:origin: org.opendaylight.mdsal/mdsal-binding2-dom-codec
/**
* 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();
}
代码示例来源:origin: org.opendaylight.mdsal/mdsal-binding2-dom-codec
/**
* 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();
}
代码示例来源:origin: org.opendaylight.mdsal/mdsal-binding-generator-impl
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;
}
代码示例来源:origin: org.opendaylight.yangtools/yang-model-export
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());
}
内容来源于网络,如有侵权,请联系作者删除!