X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=netconf%2Fmdsal-netconf-connector%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fnetconf%2Fmdsal%2Fconnector%2FCurrentSchemaContext.java;h=33109371344fe5ea729a2691824610bdedf29440;hb=f402dcd49a468e018192c96151bef3a0cdf70d62;hp=8ec0d42d1cd99a82fa7bc683c4fc04bb1730568d;hpb=61613842c6f3ab0aa74360eb6539d930e1c110eb;p=netconf.git diff --git a/netconf/mdsal-netconf-connector/src/main/java/org/opendaylight/netconf/mdsal/connector/CurrentSchemaContext.java b/netconf/mdsal-netconf-connector/src/main/java/org/opendaylight/netconf/mdsal/connector/CurrentSchemaContext.java index 8ec0d42d1c..3310937134 100644 --- a/netconf/mdsal-netconf-connector/src/main/java/org/opendaylight/netconf/mdsal/connector/CurrentSchemaContext.java +++ b/netconf/mdsal-netconf-connector/src/main/java/org/opendaylight/netconf/mdsal/connector/CurrentSchemaContext.java @@ -5,42 +5,42 @@ * terms of the Eclipse Public License v1.0 which accompanies this distribution, * and is available at http://www.eclipse.org/legal/epl-v10.html */ - package org.opendaylight.netconf.mdsal.connector; -import com.google.common.base.Preconditions; -import com.google.common.collect.Sets; +import static com.google.common.base.Preconditions.checkState; + import java.util.Collections; +import java.util.HashSet; import java.util.Set; import java.util.concurrent.atomic.AtomicReference; -import org.opendaylight.controller.config.util.capability.Capability; -import org.opendaylight.controller.sal.core.api.model.SchemaService; +import org.opendaylight.mdsal.dom.api.DOMSchemaService; +import org.opendaylight.netconf.api.capability.Capability; import org.opendaylight.netconf.api.monitoring.CapabilityListener; import org.opendaylight.yangtools.concepts.ListenerRegistration; -import org.opendaylight.yangtools.yang.model.api.SchemaContext; -import org.opendaylight.yangtools.yang.model.api.SchemaContextListener; +import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext; +import org.opendaylight.yangtools.yang.model.api.EffectiveModelContextListener; import org.opendaylight.yangtools.yang.model.repo.api.YangTextSchemaSource; import org.opendaylight.yangtools.yang.model.repo.spi.SchemaSourceProvider; -public class CurrentSchemaContext implements SchemaContextListener, AutoCloseable { - private final AtomicReference currentContext = new AtomicReference(); - private final ListenerRegistration schemaContextListenerListenerRegistration; - private final Set listeners1 = Collections.synchronizedSet(Sets.newHashSet()); +public class CurrentSchemaContext implements EffectiveModelContextListener, AutoCloseable { + private final AtomicReference currentContext = new AtomicReference<>(); + private final ListenerRegistration schemaContextListenerListenerRegistration; + private final Set listeners1 = Collections.synchronizedSet(new HashSet<>()); private final SchemaSourceProvider rootSchemaSourceProvider; - public SchemaContext getCurrentContext() { - Preconditions.checkState(currentContext.get() != null, "Current context not received"); + public EffectiveModelContext getCurrentContext() { + checkState(currentContext.get() != null, "Current context not received"); return currentContext.get(); } - public CurrentSchemaContext(final SchemaService schemaService, + public CurrentSchemaContext(final DOMSchemaService schemaService, final SchemaSourceProvider rootSchemaSourceProvider) { this.rootSchemaSourceProvider = rootSchemaSourceProvider; schemaContextListenerListenerRegistration = schemaService.registerSchemaContextListener(this); } @Override - public void onGlobalContextUpdated(final SchemaContext schemaContext) { + public void onModelContextUpdated(final EffectiveModelContext schemaContext) { currentContext.set(schemaContext); // FIXME is notifying all the listeners from this callback wise ? final Set addedCaps = MdsalNetconfOperationServiceFactory.transformCapabilities( @@ -51,7 +51,7 @@ public class CurrentSchemaContext implements SchemaContextListener, AutoCloseabl } @Override - public void close() throws Exception { + public void close() { listeners1.clear(); schemaContextListenerListenerRegistration.close(); currentContext.set(null); @@ -63,4 +63,4 @@ public class CurrentSchemaContext implements SchemaContextListener, AutoCloseabl listeners1.add(listener); return () -> listeners1.remove(listener); } -} \ No newline at end of file +}