本文整理汇总了Java中org.opendaylight.yangtools.yang.model.api.Module.getRpcs方法的典型用法代码示例。如果您正苦于以下问题:Java Module.getRpcs方法的具体用法?Java Module.getRpcs怎么用?Java Module.getRpcs使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.opendaylight.yangtools.yang.model.api.Module
的用法示例。
在下文中一共展示了Module.getRpcs方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: decomposeRpcService
import org.opendaylight.yangtools.yang.model.api.Module; //导入方法依赖的package包/类
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.findModuleByNamespaceAndRevision(moduleName.getNamespace(),
moduleName.getRevision());
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;
}
示例2: emitBodyNodes
import org.opendaylight.yangtools.yang.model.api.Module; //导入方法依赖的package包/类
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());
}
示例3: testImplicitInputAndOutput
import org.opendaylight.yangtools.yang.model.api.Module; //导入方法依赖的package包/类
@Test
public void testImplicitInputAndOutput() throws Exception {
final SchemaContext schemaContext = StmtTestUtils.parseYangSource("/rpc-stmt-test/bar.yang");
assertNotNull(schemaContext);
final Module barModule = schemaContext.findModule("bar", Revision.of("2016-11-25")).get();
final Set<RpcDefinition> rpcs = barModule.getRpcs();
assertEquals(1, rpcs.size());
final RpcDefinition barRpc = rpcs.iterator().next();
final ContainerSchemaNode input = barRpc.getInput();
assertNotNull(input);
assertEquals(2, input.getChildNodes().size());
assertEquals(StatementSource.CONTEXT, ((EffectiveStatement<?, ?>) input).getDeclared().getStatementSource());
final ContainerSchemaNode output = barRpc.getOutput();
assertNotNull(output);
assertEquals(2, output.getChildNodes().size());
assertEquals(StatementSource.CONTEXT, ((EffectiveStatement<?, ?>) output).getDeclared().getStatementSource());
}
示例4: FpcCodecUtils
import org.opendaylight.yangtools.yang.model.api.Module; //导入方法依赖的package包/类
/**
* Primary Constructor
* @param moduleInfos - Yang Module Information
* @param topPath - Top Path for the Utility to use
*/
public FpcCodecUtils(Iterable<? extends YangModuleInfo> moduleInfos,
YangInstanceIdentifier topPath) {
LOG.info("Building context");
TOP_PATH = topPath;
final ModuleInfoBackedContext moduleContext = SchemaManager.get();
moduleContext.addModuleInfos(moduleInfos);
context = moduleContext.tryToCreateSchemaContext().get();
if (context == null) {
LOG.info("Context could not be built");
} else {
LOG.info("Context built");
}
LOG.info("Building Binding Context");
bindingContext = BindingRuntimeContext.create(moduleContext, context);
LOG.info("Building Binding Codec Factory");
final BindingNormalizedNodeCodecRegistry bindingStreamCodecs = new BindingNormalizedNodeCodecRegistry(StreamWriterGenerator.create(JavassistUtils.forClassPool(ClassPool.getDefault())));
bindingStreamCodecs.onBindingRuntimeContextUpdated(bindingContext);
codecRegistry = bindingStreamCodecs;
Module fpcagent = context.findModuleByName("ietf-dmm-fpcagent", null);
Set<RpcDefinition> rpcList = fpcagent.getRpcs();
for(RpcDefinition rpc : rpcList){
if(rpc.getQName().getLocalName().equals("configure")){
CONFIGURE_OUTPUT_PATH = rpc.getOutput().getPath();
break;
}
}
LOG.info("Mapping service built");
}
示例5: findRpcDefinition
import org.opendaylight.yangtools.yang.model.api.Module; //导入方法依赖的package包/类
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;
}
示例6: getRpcMethodToSchemaPath
import org.opendaylight.yangtools.yang.model.api.Module; //导入方法依赖的package包/类
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();
}
示例7: getRpcMethodToSchema
import org.opendaylight.yangtools.yang.model.api.Module; //导入方法依赖的package包/类
public 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();
}
示例8: testValidYang11Model
import org.opendaylight.yangtools.yang.model.api.Module; //导入方法依赖的package包/类
@Test
public void testValidYang11Model() throws Exception {
final SchemaContext schemaContext = StmtTestUtils.parseYangSource("/rfc7950/bug6871/foo.yang");
assertNotNull(schemaContext);
final Module foo = schemaContext.findModule("foo", Revision.of("2016-12-14")).get();
final Set<NotificationDefinition> notifications = foo.getNotifications();
assertEquals(1, notifications.size());
final NotificationDefinition myNotification = notifications.iterator().next();
Collection<MustDefinition> mustConstraints = myNotification.getMustConstraints();
assertEquals(2, mustConstraints.size());
final Set<RpcDefinition> rpcs = foo.getRpcs();
assertEquals(1, rpcs.size());
final RpcDefinition myRpc = rpcs.iterator().next();
final ContainerSchemaNode input = myRpc.getInput();
assertNotNull(input);
mustConstraints = input.getMustConstraints();
assertEquals(2, mustConstraints.size());
final ContainerSchemaNode output = myRpc.getOutput();
assertNotNull(output);
mustConstraints = output.getMustConstraints();
assertEquals(2, mustConstraints.size());
}
示例9: getRpcByName
import org.opendaylight.yangtools.yang.model.api.Module; //导入方法依赖的package包/类
private static RpcDefinition getRpcByName(final Module module, final String name) {
for (final RpcDefinition rpc : module.getRpcs()) {
if (rpc.getQName().getLocalName().equals(name)) {
return rpc;
}
}
return null;
}
示例10: testRpc
import org.opendaylight.yangtools.yang.model.api.Module; //导入方法依赖的package包/类
@Test
public void testRpc() {
Module testModule = TestUtils.findModule(context, "ietf-netconf-monitoring").get();
Set<RpcDefinition> rpcs = testModule.getRpcs();
assertEquals(1, rpcs.size());
RpcDefinition rpc = rpcs.iterator().next();
assertEquals("get-schema", rpc.getQName().getLocalName());
assertEquals(Optional.of("This operation is used to retrieve a schema from the\n"
+ "NETCONF server.\n"
+ "\n"
+ "Positive Response:\n"
+ "The NETCONF server returns the requested schema.\n"
+ "\n"
+ "Negative Response:\n"
+ "If requested schema does not exist, the <error-tag> is\n"
+ "'invalid-value'.\n"
+ "\n"
+ "If more than one schema matches the requested parameters, the\n"
+ "<error-tag> is 'operation-failed', and <error-app-tag> is\n"
+ "'data-not-unique'."), rpc.getDescription());
ContainerSchemaNode input = rpc.getInput();
assertNotNull(input);
assertEquals(3, input.getChildNodes().size());
ContainerSchemaNode output = rpc.getOutput();
assertNotNull(output);
assertEquals(1, output.getChildNodes().size());
}
示例11: testTypedefsInRpc
import org.opendaylight.yangtools.yang.model.api.Module; //导入方法依赖的package包/类
@Test
public void testTypedefsInRpc() throws ReactorException {
final SchemaContext schemaContext = StmtTestUtils.parseYangSources(sourceForResource("/bugs/bug6410/foo.yang"));
final Set<Module> modules = schemaContext.getModules();
assertEquals(1, modules.size());
final Module module = modules.iterator().next();
final Set<RpcDefinition> rpcs = module.getRpcs();
assertEquals(1, rpcs.size());
final RpcDefinition rpc = rpcs.iterator().next();
final Set<TypeDefinition<?>> typeDefs = rpc.getTypeDefinitions();
assertEquals(2, typeDefs.size());
}
示例12: getRpcByName
import org.opendaylight.yangtools.yang.model.api.Module; //导入方法依赖的package包/类
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;
}
示例13: getIdentitiesToRpcs
import org.opendaylight.yangtools.yang.model.api.Module; //导入方法依赖的package包/类
private static Multimap<QName/* of identity */, RpcDefinition> getIdentitiesToRpcs(
final SchemaContext schemaCtx) {
Multimap<QName, RpcDefinition> result = HashMultimap.create();
for (Module currentModule : schemaCtx.getModules()) {
// Find all identities in current module for later identity->rpc mapping
Set<QName> allIdentitiesInModule =
Sets.newHashSet(Collections2.transform(currentModule.getIdentities(), SchemaNode::getQName));
for (RpcDefinition rpc : currentModule.getRpcs()) {
ContainerSchemaNode input = rpc.getInput();
if (input != null) {
for (UsesNode uses : input.getUses()) {
// Check if the rpc is config rpc by looking for input argument rpc-context-ref
Iterator<QName> pathFromRoot = uses.getGroupingPath().getPathFromRoot().iterator();
if (!pathFromRoot.hasNext() ||
!pathFromRoot.next().equals(ConfigConstants.RPC_CONTEXT_REF_GROUPING_QNAME)) {
continue;
}
for (SchemaNode refinedNode : uses.getRefines().values()) {
for (UnknownSchemaNode unknownSchemaNode : refinedNode
.getUnknownSchemaNodes()) {
if (ConfigConstants.RPC_CONTEXT_INSTANCE_EXTENSION_QNAME
.equals(unknownSchemaNode.getNodeType())) {
String localIdentityName = unknownSchemaNode
.getNodeParameter();
QName identityQName = QName.create(
currentModule.getNamespace(),
currentModule.getRevision(),
localIdentityName);
Preconditions.checkArgument(allIdentitiesInModule.contains(identityQName),
"Identity referenced by rpc not found. Identity: %s, rpc: %s", localIdentityName, rpc);
result.put(identityQName, rpc);
}
}
}
}
}
}
}
return result;
}
示例14: effectiveBuildTest
import org.opendaylight.yangtools.yang.model.api.Module; //导入方法依赖的package包/类
@Test
public void effectiveBuildTest() throws SourceException, ReactorException {
SchemaContext result = RFC7950Reactors.defaultReactor().newBuild()
.addSources(ROOT_MODULE, IMPORTED_MODULE, SUBMODULE)
.buildEffective();
assertNotNull(result);
Module rootModule = result.findModules("root").iterator().next();
assertNotNull(rootModule);
assertEquals("root-pref", rootModule.getPrefix());
assertEquals(YangVersion.VERSION_1, rootModule.getYangVersion());
assertEquals(Optional.of("cisco"), rootModule.getOrganization());
assertEquals(Optional.of("cisco email"), rootModule.getContact());
final ContainerSchemaNode contSchemaNode = (ContainerSchemaNode) rootModule.getDataChildByName(CONT);
assertNotNull(contSchemaNode);
final Set<AugmentationSchemaNode> augmentations = rootModule.getAugmentations();
assertEquals(1, augmentations.size());
assertEquals(CONT_SCHEMA_PATH, augmentations.iterator().next().getTargetPath());
final Set<ModuleImport> imports = rootModule.getImports();
assertEquals(1, imports.size());
final ModuleImport importStmt = imports.iterator().next();
assertNotNull(importStmt);
assertEquals("imported", importStmt.getModuleName());
assertEquals(Optional.of(REVISION), importStmt.getRevision());
assertEquals("imp-pref", importStmt.getPrefix());
final Set<Module> submodules = rootModule.getSubmodules();
assertEquals(1, submodules.size());
assertEquals("submod", submodules.iterator().next().getName());
final Set<NotificationDefinition> notifications = rootModule.getNotifications();
assertEquals(1, notifications.size());
assertEquals("notif1", notifications.iterator().next().getQName().getLocalName());
final Set<RpcDefinition> rpcs = rootModule.getRpcs();
assertEquals(1, rpcs.size());
assertEquals("rpc1", rpcs.iterator().next().getQName().getLocalName());
final Set<Deviation> deviations = rootModule.getDeviations();
assertEquals(1, deviations.size());
final Deviation deviationStmt = deviations.iterator().next();
assertNotNull(deviationStmt);
final QNameModule importedModuleQName = QNameModule.create(URI.create("imported"), REVISION);
final QName importedContQName = QName.create(importedModuleQName, "cont");
final SchemaPath importedContSchemaPath = SchemaPath.create(true, importedContQName);
assertEquals(importedContSchemaPath, deviationStmt.getTargetPath());
assertEquals(DeviateKind.ADD, deviationStmt.getDeviates().iterator().next().getDeviateType());
assertEquals(Optional.of("deviate reference"), deviationStmt.getReference());
final Set<IdentitySchemaNode> identities = rootModule.getIdentities();
assertEquals(1, identities.size());
assertEquals("identity1", identities.iterator().next().getQName().getLocalName());
final Set<FeatureDefinition> features = rootModule.getFeatures();
assertEquals(1, features.size());
final FeatureDefinition featureStmt = features.iterator().next();
assertNotNull(featureStmt);
assertEquals(FEATURE1, featureStmt.getQName());
assertEquals(FEATURE1_SCHEMA_PATH, featureStmt.getPath());
assertEquals(Optional.of("feature1 description"), featureStmt.getDescription());
assertEquals(Optional.of("feature1 reference"), featureStmt.getReference());
assertEquals(Status.CURRENT, featureStmt.getStatus());
final List<ExtensionDefinition> extensionSchemaNodes = rootModule.getExtensionSchemaNodes();
assertEquals(1, extensionSchemaNodes.size());
assertEquals("ext1", extensionSchemaNodes.iterator().next().getQName().getLocalName());
}