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;
}
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);
}
}
}
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;
}
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();
}
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;
}
Aggregations