diff options
author | Michal Cmarada <michal.cmarada@pantheon.tech> | 2018-09-25 11:15:35 +0200 |
---|---|---|
committer | Michal Cmarada <michal.cmarada@pantheon.tech> | 2018-09-25 11:22:18 +0200 |
commit | 556a0f59abc9b09005d40945bc20948d69e4f98e (patch) | |
tree | 76d795ae59aba49521fc4fdc7d65062c946147be /infra/minimal-distribution-core/src/main/java/io/fd/honeycomb/infra/distro/schema/SchemaServiceProvider.java | |
parent | 46bcceb927b1bce07c1c9517f45470703293eb84 (diff) |
Bump ODL dependencies to Fluorine (HONEYCOMB-433)
Change-Id: I142ebd2899272feff00abe7d4bae708f093ee3ec
Signed-off-by: Michal Cmarada <michal.cmarada@pantheon.tech>
Diffstat (limited to 'infra/minimal-distribution-core/src/main/java/io/fd/honeycomb/infra/distro/schema/SchemaServiceProvider.java')
-rw-r--r-- | infra/minimal-distribution-core/src/main/java/io/fd/honeycomb/infra/distro/schema/SchemaServiceProvider.java | 49 |
1 files changed, 27 insertions, 22 deletions
diff --git a/infra/minimal-distribution-core/src/main/java/io/fd/honeycomb/infra/distro/schema/SchemaServiceProvider.java b/infra/minimal-distribution-core/src/main/java/io/fd/honeycomb/infra/distro/schema/SchemaServiceProvider.java index fe1006df1..22fe023de 100644 --- a/infra/minimal-distribution-core/src/main/java/io/fd/honeycomb/infra/distro/schema/SchemaServiceProvider.java +++ b/infra/minimal-distribution-core/src/main/java/io/fd/honeycomb/infra/distro/schema/SchemaServiceProvider.java @@ -16,60 +16,55 @@ package io.fd.honeycomb.infra.distro.schema; +import com.google.common.collect.ClassToInstanceMap; +import com.google.common.collect.ImmutableClassToInstanceMap; +import com.google.common.util.concurrent.ListenableFuture; import com.google.inject.Inject; import io.fd.honeycomb.binding.init.ProviderTrait; -import org.opendaylight.controller.sal.core.api.model.SchemaService; import org.opendaylight.mdsal.binding.generator.impl.ModuleInfoBackedContext; +import org.opendaylight.mdsal.dom.api.DOMSchemaService; +import org.opendaylight.mdsal.dom.api.DOMSchemaServiceExtension; +import org.opendaylight.mdsal.dom.api.DOMYangTextSourceProvider; import org.opendaylight.yangtools.concepts.ListenerRegistration; -import org.opendaylight.yangtools.yang.model.api.Module; import org.opendaylight.yangtools.yang.model.api.SchemaContext; import org.opendaylight.yangtools.yang.model.api.SchemaContextListener; +import org.opendaylight.yangtools.yang.model.repo.api.SourceIdentifier; +import org.opendaylight.yangtools.yang.model.repo.api.YangTextSchemaSource; -// TODO: provide DOMSchemaService instead, but first Netconf's RestconfProviderImpl should not use it -public final class SchemaServiceProvider extends ProviderTrait<SchemaService> { +public final class SchemaServiceProvider extends ProviderTrait<DOMSchemaService> { @Inject private ModuleInfoBackedContext mibCtx; @Override public StaticSchemaService create() { - return new StaticSchemaService(mibCtx.getSchemaContext()); + return new StaticSchemaService(mibCtx); } /** * Static schema context provider service. */ - private static final class StaticSchemaService implements SchemaService { - private final SchemaContext schemaContext; + private static final class StaticSchemaService implements DOMSchemaService, DOMYangTextSourceProvider { + private final ModuleInfoBackedContext moduleInfoBackedContext; - StaticSchemaService(SchemaContext schemaContext) { - this.schemaContext = schemaContext; - } - - @Override - public void addModule(final Module module) { - throw new UnsupportedOperationException("Static service"); - } - - @Override - public void removeModule(final Module module) { - throw new UnsupportedOperationException("Static service"); + StaticSchemaService(ModuleInfoBackedContext moduleInfoBackedContext) { + this.moduleInfoBackedContext = moduleInfoBackedContext; } @Override public SchemaContext getSessionContext() { - return schemaContext; + return moduleInfoBackedContext.getSchemaContext(); } @Override public SchemaContext getGlobalContext() { - return schemaContext; + return moduleInfoBackedContext.getSchemaContext(); } @Override public ListenerRegistration<SchemaContextListener> registerSchemaContextListener( final SchemaContextListener listener) { - listener.onGlobalContextUpdated(schemaContext); + listener.onGlobalContextUpdated(moduleInfoBackedContext.getSchemaContext()); return new ListenerRegistration<SchemaContextListener>() { @Override public void close() {} @@ -81,5 +76,15 @@ public final class SchemaServiceProvider extends ProviderTrait<SchemaService> { }; } + + @Override + public ClassToInstanceMap<DOMSchemaServiceExtension> getExtensions() { + return ImmutableClassToInstanceMap.of(DOMYangTextSourceProvider.class, this); + } + + @Override + public ListenableFuture<? extends YangTextSchemaSource> getSource(final SourceIdentifier sourceIdentifier) { + return moduleInfoBackedContext.getSource(sourceIdentifier); + } } } |