Use YANG binding from YANG Tools
[mdsal.git] / dom / mdsal-dom-schema-osgi / src / main / java / org / opendaylight / mdsal / dom / schema / osgi / impl / OSGiDOMSchemaService.java
index d55f6a2f123e93319f07c25472c756a3f787029e..5abb5680672047898dcae77595b1bd3a173d917f 100644 (file)
@@ -16,9 +16,9 @@ import java.util.concurrent.CopyOnWriteArrayList;
 import java.util.concurrent.atomic.AtomicReference;
 import java.util.function.Consumer;
 import org.eclipse.jdt.annotation.NonNull;
-import org.opendaylight.mdsal.binding.runtime.api.ModuleInfoSnapshot;
 import org.opendaylight.mdsal.dom.api.DOMSchemaService;
-import org.opendaylight.mdsal.dom.schema.osgi.OSGiModuleInfoSnapshot;
+import org.opendaylight.yangtools.binding.runtime.api.ModuleInfoSnapshot;
+import org.opendaylight.yangtools.binding.runtime.osgi.OSGiModuleInfoSnapshot;
 import org.opendaylight.yangtools.concepts.AbstractRegistration;
 import org.opendaylight.yangtools.concepts.Registration;
 import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
@@ -70,19 +70,19 @@ public final class OSGiDOMSchemaService implements DOMSchemaService, DOMSchemaSe
 
     @Reference(policy = ReferencePolicy.DYNAMIC, policyOption = ReferencePolicyOption.GREEDY)
     void bindSnapshot(final OSGiModuleInfoSnapshot newContext) {
-        LOG.info("Updating context to generation {}", newContext.getGeneration());
-        final var snapshot = newContext.getService();
+        LOG.info("Updating context to generation {}", newContext.generation());
+        final var snapshot = newContext.service();
         final var modelContext = snapshot.modelContext();
         final var previous = currentSnapshot.getAndSet(snapshot);
         LOG.debug("Snapshot updated from {} to {}", previous, snapshot);
 
-        listeners.forEach(listener -> notifyListener(modelContext, listener));
+        listeners.forEach(listener -> listener.onModelContextUpdated(modelContext));
     }
 
     void unbindSnapshot(final OSGiModuleInfoSnapshot oldContext) {
-        final var snapshot = oldContext.getService();
+        final var snapshot = oldContext.service();
         if (currentSnapshot.compareAndSet(snapshot, null) && !deactivated) {
-            LOG.info("Lost final generation {}", oldContext.getGeneration());
+            LOG.info("Lost final generation {}", oldContext.generation());
         }
     }
 
@@ -123,14 +123,4 @@ public final class OSGiDOMSchemaService implements DOMSchemaService, DOMSchemaSe
             return Futures.immediateFailedFuture(e);
         }
     }
-
-    @SuppressWarnings("checkstyle:illegalCatch")
-    private static void notifyListener(final @NonNull EffectiveModelContext modelContext,
-            final ModelContextListener listener) {
-        try {
-            listener.onModelContextUpdated(modelContext);
-        } catch (RuntimeException e) {
-            LOG.warn("Failed to notify listener {}", listener, e);
-        }
-    }
 }