当前位置: 首页>>代码示例>>Java>>正文


Java SchemaContext类代码示例

本文整理汇总了Java中org.opendaylight.yangtools.yang.model.api.SchemaContext的典型用法代码示例。如果您正苦于以下问题:Java SchemaContext类的具体用法?Java SchemaContext怎么用?Java SchemaContext使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


SchemaContext类属于org.opendaylight.yangtools.yang.model.api包,在下文中一共展示了SchemaContext类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: findSIE

import org.opendaylight.yangtools.yang.model.api.SchemaContext; //导入依赖的package包/类
private static ServiceInterfaceEntry findSIE(final String prefixAndIdentityLocalName, final Module currentModule,
        final Map<QName, ServiceInterfaceEntry> qNamesToSIEs, final SchemaContext schemaContext) {

    Matcher m = PREFIX_COLON_LOCAL_NAME.matcher(prefixAndIdentityLocalName);
    Module foundModule;
    String localSIName;
    if (m.matches()) {
        // if there is a prefix, look for ModuleImport with this prefix. Get
        // Module from SchemaContext
        String prefix = m.group(1);
        ModuleImport moduleImport = findModuleImport(currentModule, prefix);
        foundModule = schemaContext.findModuleByName(moduleImport.getModuleName(), moduleImport.getRevision());
        checkNotNull(foundModule, format("Module not found in SchemaContext by %s", moduleImport));
        localSIName = m.group(2);
    } else {
        foundModule = currentModule; // no prefix => SIE is in currentModule
        localSIName = prefixAndIdentityLocalName;
    }
    QName siQName = QName.create(foundModule.getNamespace(), foundModule.getRevision(), localSIName);
    ServiceInterfaceEntry sie = qNamesToSIEs.get(siQName);
    checkState(sie != null, "Cannot find referenced Service Interface by " + prefixAndIdentityLocalName);
    return sie;
}
 
开发者ID:hashsdn,项目名称:hashsdn-controller,代码行数:24,代码来源:ModuleMXBeanEntryBuilder.java

示例2: parseDataElement

import org.opendaylight.yangtools.yang.model.api.SchemaContext; //导入依赖的package包/类
public NormalizedNode<?, ?> parseDataElement(final Element element, final DataSchemaNode dataSchema,
        final SchemaContext schemaContext) throws XMLStreamException, IOException, ParserConfigurationException,
        SAXException, URISyntaxException {
    final NormalizedNodeResult resultHolder = new NormalizedNodeResult();
    final NormalizedNodeStreamWriter writer = ImmutableNormalizedNodeStreamWriter.from(resultHolder);
    final XmlParserStream xmlParser = XmlParserStream.create(writer, schemaContext, dataSchema);
    xmlParser.traverse(new DOMSource(element));

    final NormalizedNode<?, ?> result = resultHolder.getResult();
    if (result instanceof MapNode) {
        final MapNode mapNode = (MapNode) result;
        final MapEntryNode mapEntryNode = mapNode.getValue().iterator().next();
        return mapEntryNode;
    }

    return result;
}
 
开发者ID:hashsdn,项目名称:hashsdn-controller,代码行数:18,代码来源:BindingContext.java

示例3: parsePossibleDefaultAppConfigElement

import org.opendaylight.yangtools.yang.model.api.SchemaContext; //导入依赖的package包/类
@Nullable
private NormalizedNode<?, ?> parsePossibleDefaultAppConfigElement(final SchemaContext schemaContext,
        final DataSchemaNode dataSchema) throws URISyntaxException, IOException, ParserConfigurationException,
        SAXException, XMLStreamException {
    if (defaultAppConfigElement == null) {
        return null;
    }

    LOG.debug("{}: parsePossibleDefaultAppConfigElement for {}", logName(), bindingContext.bindingQName);

    LOG.debug("{}: Got app config schema: {}", logName(), dataSchema);

    NormalizedNode<?, ?> dataNode = bindingContext.parseDataElement(defaultAppConfigElement, dataSchema,
            schemaContext);

    LOG.debug("{}: Parsed data node: {}", logName(), dataNode);

    return dataNode;
}
 
开发者ID:hashsdn,项目名称:hashsdn-controller,代码行数:20,代码来源:DataStoreAppConfigMetadata.java

示例4: retrievedSchemaContext

import org.opendaylight.yangtools.yang.model.api.SchemaContext; //导入依赖的package包/类
private void retrievedSchemaContext(final SchemaContext schemaContext) {
    log.debug("{}: retrievedSchemaContext", logName());

    final Collection<SchemaPath> schemaPaths = RpcUtil.decomposeRpcService(rpcInterface, schemaContext,
        rpcFilter());
    if (schemaPaths.isEmpty()) {
        log.warn("{}: interface {} has no accptable entries, assuming it is satisfied", logName(), rpcInterface);
        setSatisfied();
        return;
    }

    rpcSchemaPaths = ImmutableSet.copyOf(schemaPaths);
    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, this::retrievedDOMRpcService);
}
 
开发者ID:hashsdn,项目名称:hashsdn-controller,代码行数:19,代码来源:AbstractInvokableServiceMetadata.java

示例5: createDefaultInstance

import org.opendaylight.yangtools.yang.model.api.SchemaContext; //导入依赖的package包/类
@SuppressWarnings("unchecked")
public T createDefaultInstance(final FallbackConfigProvider fallback) throws ConfigXMLReaderException,
        URISyntaxException, ParserConfigurationException, XMLStreamException, SAXException, IOException {
    YangInstanceIdentifier yangPath = bindingSerializer.toYangInstanceIdentifier(bindingContext.appConfigPath);

    LOG.debug("{}: Creating app config instance from path {}, Qname: {}", logName, yangPath,
            bindingContext.bindingQName);

    checkNotNull(schemaService, "%s: Could not obtain the SchemaService OSGi service", logName);

    SchemaContext schemaContext = schemaService.getGlobalContext();

    Module module = schemaContext.findModuleByNamespaceAndRevision(bindingContext.bindingQName.getNamespace(),
            bindingContext.bindingQName.getRevision());
    checkNotNull(module, "%s: Could not obtain the module schema for namespace %s, revision %s",
            logName, bindingContext.bindingQName.getNamespace(), bindingContext.bindingQName.getRevision());

    DataSchemaNode dataSchema = module.getDataChildByName(bindingContext.bindingQName);
    checkNotNull(dataSchema, "%s: Could not obtain the schema for %s", logName, bindingContext.bindingQName);

    checkCondition(bindingContext.schemaType.isAssignableFrom(dataSchema.getClass()),
            "%s: Expected schema type %s for %s but actual type is %s", logName,
            bindingContext.schemaType, bindingContext.bindingQName, dataSchema.getClass());

    NormalizedNode<?, ?> dataNode = parsePossibleDefaultAppConfigXMLFile(schemaContext, dataSchema);
    if (dataNode == null) {
        dataNode = fallback.get(schemaService.getGlobalContext(), dataSchema);
    }

    DataObject appConfig = bindingSerializer.fromNormalizedNode(yangPath, dataNode).getValue();

    // This shouldn't happen but need to handle it in case...
    checkNotNull(appConfig, "%s: Could not create instance for app config binding %s", logName,
            bindingContext.appConfigBindingClass);

    return (T) appConfig;
}
 
开发者ID:hashsdn,项目名称:hashsdn-controller,代码行数:38,代码来源:DataStoreAppConfigDefaultXMLReader.java

示例6: decomposeRpcService

import org.opendaylight.yangtools.yang.model.api.SchemaContext; //导入依赖的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;
}
 
开发者ID:hashsdn,项目名称:hashsdn-controller,代码行数:19,代码来源:RpcUtil.java

示例7: createRpcEntry

import org.opendaylight.yangtools.yang.model.api.SchemaContext; //导入依赖的package包/类
private static AbstractDOMRpcRoutingTableEntry createRpcEntry(final SchemaContext context, final SchemaPath 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);
}
 
开发者ID:hashsdn,项目名称:hashsdn-controller,代码行数:17,代码来源:DOMRpcRoutingTable.java

示例8: createTestContext

import org.opendaylight.yangtools.yang.model.api.SchemaContext; //导入依赖的package包/类
public static SchemaContext createTestContext() {
    final List<InputStream> sources;

    try {
        sources = Collections.singletonList(
            Resources.asByteSource(TestModel.class.getResource(DATASTORE_TEST_YANG)).openStream());
    } catch (IOException e1) {
        throw new ExceptionInInitializerError(e1);
    }

    try {
        return YangParserTestUtils.parseYangStreams(sources);
    }  catch (ReactorException e) {
        throw new RuntimeException("Unable to build schema context from " + sources, e);
    }
}
 
开发者ID:hashsdn,项目名称:hashsdn-controller,代码行数:17,代码来源:TestModel.java

示例9: setupDistributedDataStoreWithoutConfig

import org.opendaylight.yangtools.yang.model.api.SchemaContext; //导入依赖的package包/类
public DistributedDataStore setupDistributedDataStoreWithoutConfig(final String typeName,
                                                                   final SchemaContext schemaContext,
                                                                   final LogicalDatastoreType storeType) {
    final ClusterWrapper cluster = new ClusterWrapperImpl(getSystem());
    final ConfigurationImpl configuration = new ConfigurationImpl(new EmptyModuleShardConfigProvider());

    setDataStoreName(typeName);

    final DatastoreContext datastoreContext =
            getDatastoreContextBuilder().logicalStoreType(storeType).build();

    final DatastoreContextFactory mockContextFactory = Mockito.mock(DatastoreContextFactory.class);
    Mockito.doReturn(datastoreContext).when(mockContextFactory).getBaseDatastoreContext();
    Mockito.doReturn(datastoreContext).when(mockContextFactory).getShardDatastoreContext(Mockito.anyString());

    final DistributedDataStore dataStore = new DistributedDataStore(getSystem(), cluster,
            configuration, mockContextFactory, restoreFromSnapshot);

    dataStore.onGlobalContextUpdated(schemaContext);

    datastoreContextBuilder = DatastoreContext.newBuilderFrom(datastoreContext);
    return dataStore;
}
 
开发者ID:hashsdn,项目名称:hashsdn-controller,代码行数:24,代码来源:IntegrationTestKit.java

示例10: canCommit

import org.opendaylight.yangtools.yang.model.api.SchemaContext; //导入依赖的package包/类
@Override
public CheckedFuture<PostCanCommitStep, DataValidationFailedException> canCommit(final Object txId,
        final DOMDataTreeCandidate candidate, final SchemaContext ctx) {

    // Simple data validation - verify the year, if present, is >= 1990

    final DataTreeCandidateNode rootNode = candidate.getRootNode();
    final Optional<NormalizedNode<?, ?>> dataAfter = rootNode.getDataAfter();

    LOG.info("In canCommit: modificationType: {}, dataBefore: {}, dataAfter: {}", rootNode.getModificationType(),
            rootNode.getDataBefore(), dataAfter);

    // Note: we don't want to process DELETE modifications but we don't need to explicitly check the
    // ModificationType because dataAfter will not be present. Also dataAfter *should* always contain a
    // MapEntryNode but we verify anyway.
    if (dataAfter.isPresent()) {
        final NormalizedNode<?, ?> normalizedNode = dataAfter.get();
        Verify.verify(normalizedNode instanceof DataContainerNode, "Expected type DataContainerNode, actual was %s",
                normalizedNode.getClass());
        DataContainerNode<?> entryNode = (DataContainerNode<?>) normalizedNode;
        final Optional<DataContainerChild<? extends PathArgument, ?>> possibleYear =
                entryNode.getChild(YEAR_NODE_ID);
        if (possibleYear.isPresent()) {
            final Number year = (Number) possibleYear.get().getValue();

            LOG.info("year is {}", year);

            if (!(year.longValue() >= 1990)) {
                return Futures.immediateFailedCheckedFuture(new DataValidationFailedException(
                        DOMDataTreeIdentifier.class, candidate.getRootPath(),
                            String.format("Invalid year %d - year must be >= 1990", year)));
            }
        }
    }

    // Return the noop PostCanCommitStep as we're only validating input data and not participating in the
    // remaining 3PC stages (pre-commit and commit).
    return PostCanCommitStep.NOOP_SUCCESS_FUTURE;
}
 
开发者ID:hashsdn,项目名称:hashsdn-controller,代码行数:40,代码来源:CarEntryDataTreeCommitCohort.java

示例11: fillConfiguration

import org.opendaylight.yangtools.yang.model.api.SchemaContext; //导入依赖的package包/类
private static Map<String, AttributeIfc> fillConfiguration(final DataNodeContainer dataNodeContainer, final Module currentModule,
        final TypeProviderWrapper typeProviderWrapper, final Map<QName, ServiceInterfaceEntry> qNamesToSIEs,
        final SchemaContext schemaContext, final String packageName) {
    Map<String, AttributeIfc> yangToAttributes = new HashMap<>();
    for (DataSchemaNode attrNode : dataNodeContainer.getChildNodes()) {
        AttributeIfc attributeValue = getAttributeValue(attrNode, currentModule, qNamesToSIEs, typeProviderWrapper,
                schemaContext, packageName);
        yangToAttributes.put(attributeValue.getAttributeYangName(), attributeValue);
    }
    return yangToAttributes;
}
 
开发者ID:hashsdn,项目名称:hashsdn-controller,代码行数:12,代码来源:ModuleMXBeanEntryBuilder.java

示例12: findProvidedServices

import org.opendaylight.yangtools.yang.model.api.SchemaContext; //导入依赖的package包/类
private static Map<String, QName> findProvidedServices(final IdentitySchemaNode moduleIdentity, final Module currentModule,
        final Map<QName, ServiceInterfaceEntry> qNamesToSIEs, final SchemaContext schemaContext) {
    Map<String, QName> result = new HashMap<>();
    for (UnknownSchemaNode unknownNode : moduleIdentity.getUnknownSchemaNodes()) {
        if (ConfigConstants.PROVIDED_SERVICE_EXTENSION_QNAME.equals(unknownNode.getNodeType())) {
            String prefixAndIdentityLocalName = unknownNode.getNodeParameter();
            ServiceInterfaceEntry sie = findSIE(prefixAndIdentityLocalName, currentModule, qNamesToSIEs,
                    schemaContext);
            result.put(sie.getFullyQualifiedName(), sie.getQName());
        }
    }
    return result;
}
 
开发者ID:hashsdn,项目名称:hashsdn-controller,代码行数:14,代码来源:ModuleMXBeanEntryBuilder.java

示例13: setupWithSchema

import org.opendaylight.yangtools.yang.model.api.SchemaContext; //导入依赖的package包/类
@Override
protected void setupWithSchema(final SchemaContext context) {
    final DataBrokerTestCustomizer testCustomizer = createDataBrokerTestCustomizer();
    domNotificationRouter = testCustomizer.getDomNotificationRouter();
    notificationService = testCustomizer.createNotificationService();
    notificationPublishService = testCustomizer.createNotificationPublishService();
    bindingToNormalizedNodeCodec = testCustomizer.getBindingToNormalized();
    testCustomizer.updateSchema(context);
}
 
开发者ID:hashsdn,项目名称:hashsdn-controller,代码行数:10,代码来源:AbstractNotificationBrokerTest.java

示例14: create

import org.opendaylight.yangtools.yang.model.api.SchemaContext; //导入依赖的package包/类
/**
 * Transform module to zero or more ModuleMXBeanEntry instances. Each
 * instance must have a globally unique local name.
 *
 * @return Map of identity local names as keys, and ModuleMXBeanEntry
 *         instances as values
 */
public static Map<String/* identity local name */, ModuleMXBeanEntry> create(
        Module currentModule,
        Map<QName, ServiceInterfaceEntry> qNamesToSIEs,
        SchemaContext schemaContext,
        TypeProviderWrapper typeProviderWrapper, String packageName) {

    ModuleMXBeanEntryBuilder builder = new ModuleMXBeanEntryBuilder().setModule(currentModule).setqNamesToSIEs(qNamesToSIEs)
            .setSchemaContext(schemaContext).setTypeProviderWrapper(typeProviderWrapper)
            .setPackageName(packageName);

    return builder.build();
}
 
开发者ID:hashsdn,项目名称:hashsdn-controller,代码行数:20,代码来源:ModuleMXBeanEntry.java

示例15: findYangModuleName

import org.opendaylight.yangtools.yang.model.api.SchemaContext; //导入依赖的package包/类
private String findYangModuleName(final QName qname, final SchemaContext schemaContext)
        throws ConfigXMLReaderException {
    for (Module m : schemaContext.getModules()) {
        if (qname.getModule().equals(m.getQNameModule())) {
            return m.getName();
        }
    }
    throw new ConfigXMLReaderException(
            String.format("%s: Could not find yang module for QName %s", logName, qname));
}
 
开发者ID:hashsdn,项目名称:hashsdn-controller,代码行数:11,代码来源:DataStoreAppConfigDefaultXMLReader.java


注:本文中的org.opendaylight.yangtools.yang.model.api.SchemaContext类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。