Search in sources :

Example 6 with Module

use of org.opendaylight.yangtools.yang.model.api.Module in project controller by opendaylight.

the class RpcUtil method decomposeRpcService.

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).get();
    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;
}
Also used : RpcRoutingStrategy(org.opendaylight.controller.md.sal.dom.broker.spi.rpc.RpcRoutingStrategy) RpcDefinition(org.opendaylight.yangtools.yang.model.api.RpcDefinition) SchemaPath(org.opendaylight.yangtools.yang.model.api.SchemaPath) ArrayList(java.util.ArrayList) QNameModule(org.opendaylight.yangtools.yang.common.QNameModule) Module(org.opendaylight.yangtools.yang.model.api.Module) QNameModule(org.opendaylight.yangtools.yang.common.QNameModule)

Example 7 with Module

use of org.opendaylight.yangtools.yang.model.api.Module in project controller by opendaylight.

the class YangStoreService method notifyListeners.

void notifyListeners(final YangStoreSnapshot previous, final YangStoreSnapshot current) {
    final Set<Module> prevModules = previous.getModules();
    final Set<Module> currModules = current.getModules();
    final Set<Module> removed = Sets.difference(prevModules, currModules);
    final Set<Module> added = Sets.difference(currModules, prevModules);
    final Set<Capability> addedCaps = toCapabilities(added, current);
    final Set<Capability> removedCaps = toCapabilities(removed, current);
    synchronized (this.listeners) {
        for (final ModuleListener listener : this.listeners) {
            listener.onCapabilitiesChanged(addedCaps, removedCaps);
        }
    }
}
Also used : ModuleListener(org.opendaylight.controller.config.util.capability.ModuleListener) Capability(org.opendaylight.controller.config.util.capability.Capability) YangModuleCapability(org.opendaylight.controller.config.util.capability.YangModuleCapability) Module(org.opendaylight.yangtools.yang.model.api.Module)

Example 8 with Module

use of org.opendaylight.yangtools.yang.model.api.Module in project controller by opendaylight.

the class BindingToNormalizedNodeCodec method getModuleBlocking.

private Module getModuleBlocking(final Class<?> modeledClass) {
    final QNameModule moduleName = BindingReflections.getQNameModule(modeledClass);
    Module module = runtimeContext().getSchemaContext().findModule(moduleName).orElse(null);
    if (module == null && this.futureSchema.waitForSchema(moduleName)) {
        module = runtimeContext().getSchemaContext().findModule(moduleName).orElse(null);
    }
    Preconditions.checkState(module != null, "Schema for %s is not available.", modeledClass);
    return module;
}
Also used : QNameModule(org.opendaylight.yangtools.yang.common.QNameModule) QNameModule(org.opendaylight.yangtools.yang.common.QNameModule) Module(org.opendaylight.yangtools.yang.model.api.Module)

Example 9 with Module

use of org.opendaylight.yangtools.yang.model.api.Module in project controller by opendaylight.

the class SchemaServiceImplSingletonModule method createInstance.

@Override
public AutoCloseable createInstance() {
    final WaitingServiceTracker<SchemaService> schemaServiceTracker = WaitingServiceTracker.create(SchemaService.class, bundleContext);
    final SchemaService schemaService = schemaServiceTracker.waitForService(WaitingServiceTracker.FIVE_MINUTES);
    final WaitingServiceTracker<YangTextSourceProvider> sourceProviderTracker = WaitingServiceTracker.create(YangTextSourceProvider.class, bundleContext);
    final YangTextSourceProvider sourceProvider = sourceProviderTracker.waitForService(WaitingServiceTracker.FIVE_MINUTES);
    class GlobalSchemaServiceProxy implements AutoCloseable, SchemaService, YangTextSourceProvider {

        @Override
        public void close() {
            schemaServiceTracker.close();
            sourceProviderTracker.close();
        }

        @Override
        public void addModule(final Module arg0) {
            schemaService.addModule(arg0);
        }

        @Override
        public SchemaContext getGlobalContext() {
            return schemaService.getGlobalContext();
        }

        @Override
        public SchemaContext getSessionContext() {
            return schemaService.getSessionContext();
        }

        @Override
        public ListenerRegistration<SchemaContextListener> registerSchemaContextListener(final SchemaContextListener arg0) {
            return schemaService.registerSchemaContextListener(arg0);
        }

        @Override
        public void removeModule(final Module arg0) {
            schemaService.removeModule(arg0);
        }

        @Override
        public ListenableFuture<? extends YangTextSchemaSource> getSource(final SourceIdentifier sourceIdentifier) {
            return sourceProvider.getSource(sourceIdentifier);
        }
    }
    return new GlobalSchemaServiceProxy();
}
Also used : YangTextSourceProvider(org.opendaylight.controller.sal.core.api.model.YangTextSourceProvider) SchemaService(org.opendaylight.controller.sal.core.api.model.SchemaService) SourceIdentifier(org.opendaylight.yangtools.yang.model.repo.api.SourceIdentifier) Module(org.opendaylight.yangtools.yang.model.api.Module) SchemaContextListener(org.opendaylight.yangtools.yang.model.api.SchemaContextListener)

Example 10 with Module

use of org.opendaylight.yangtools.yang.model.api.Module in project controller by opendaylight.

the class ConfigSubsystemFacade method transformIdentities.

private static Map<String, Map<Optional<Revision>, IdentityMapping>> transformIdentities(final Set<Module> modules) {
    Map<String, Map<Optional<Revision>, IdentityMapping>> mappedIds = new HashMap<>();
    for (Module module : modules) {
        String namespace = module.getNamespace().toString();
        Map<Optional<Revision>, IdentityMapping> revisionsByNamespace = mappedIds.computeIfAbsent(namespace, k -> new HashMap<>());
        Optional<Revision> revision = Optional.fromJavaUtil(module.getRevision());
        IdentityMapping identityMapping = revisionsByNamespace.computeIfAbsent(revision, k -> new IdentityMapping());
        for (IdentitySchemaNode identitySchemaNode : module.getIdentities()) {
            identityMapping.addIdSchemaNode(identitySchemaNode);
        }
    }
    return mappedIds;
}
Also used : IdentityMapping(org.opendaylight.controller.config.facade.xml.mapping.IdentityMapping) Revision(org.opendaylight.yangtools.yang.common.Revision) Optional(com.google.common.base.Optional) HashMap(java.util.HashMap) Module(org.opendaylight.yangtools.yang.model.api.Module) HashMap(java.util.HashMap) Map(java.util.Map) IdentitySchemaNode(org.opendaylight.yangtools.yang.model.api.IdentitySchemaNode)

Aggregations

Module (org.opendaylight.yangtools.yang.model.api.Module)18 QName (org.opendaylight.yangtools.yang.common.QName)5 RpcDefinition (org.opendaylight.yangtools.yang.model.api.RpcDefinition)5 QNameModule (org.opendaylight.yangtools.yang.common.QNameModule)4 HashMap (java.util.HashMap)3 DataSchemaNode (org.opendaylight.yangtools.yang.model.api.DataSchemaNode)3 ImmutableBiMap (com.google.common.collect.ImmutableBiMap)2 Method (java.lang.reflect.Method)2 ArrayList (java.util.ArrayList)2 Test (org.junit.Test)2 Capability (org.opendaylight.controller.config.util.capability.Capability)2 YangModuleCapability (org.opendaylight.controller.config.util.capability.YangModuleCapability)2 TypeProviderImpl (org.opendaylight.mdsal.binding.yang.types.TypeProviderImpl)2 ContainerSchemaNode (org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode)2 IdentitySchemaNode (org.opendaylight.yangtools.yang.model.api.IdentitySchemaNode)2 LeafListSchemaNode (org.opendaylight.yangtools.yang.model.api.LeafListSchemaNode)2 LeafSchemaNode (org.opendaylight.yangtools.yang.model.api.LeafSchemaNode)2 ListSchemaNode (org.opendaylight.yangtools.yang.model.api.ListSchemaNode)2 SchemaNode (org.opendaylight.yangtools.yang.model.api.SchemaNode)2 SchemaPath (org.opendaylight.yangtools.yang.model.api.SchemaPath)2