Remove BindingRuntimeContext{Listener,Service}
[mdsal.git] / binding / mdsal-binding-dom-codec-osgi / src / main / java / org / opendaylight / mdsal / binding / dom / codec / osgi / impl / OsgiModuleInfoRegistry.java
index 4ea13e313a0caaeeb826ec6d24fd8cad78cdcbaa..b001583f70912389bf25702673bed5e4bac0fecd 100644 (file)
@@ -10,7 +10,8 @@ package org.opendaylight.mdsal.binding.dom.codec.osgi.impl;
 import static java.util.Objects.requireNonNull;
 
 import org.checkerframework.checker.lock.qual.GuardedBy;
-import org.opendaylight.mdsal.binding.generator.api.ModuleInfoRegistry;
+import org.opendaylight.binding.runtime.spi.ModuleInfoBackedContext;
+import org.opendaylight.binding.runtime.spi.ModuleInfoRegistry;
 import org.opendaylight.yangtools.concepts.ObjectRegistration;
 import org.opendaylight.yangtools.yang.binding.YangModuleInfo;
 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
@@ -25,21 +26,24 @@ import org.slf4j.LoggerFactory;
 final class OsgiModuleInfoRegistry implements ModuleInfoRegistry {
     private static final Logger LOG = LoggerFactory.getLogger(OsgiModuleInfoRegistry.class);
 
-    private final SimpleBindingRuntimeContextService runtimeContext;
     private final SchemaContextProvider schemaContextProvider;
-    private final ModuleInfoRegistry moduleInfoRegistry;
+    private final ModuleInfoBackedContext moduleInfoRegistry;
 
     @GuardedBy("this")
     private ServiceRegistration<?> registration;
     @GuardedBy("this")
     private long generation;
 
-    OsgiModuleInfoRegistry(final ModuleInfoRegistry moduleInfoRegistry,
-        final SchemaContextProvider schemaContextProvider, final SimpleBindingRuntimeContextService runtimeContext) {
+    OsgiModuleInfoRegistry(final ModuleInfoBackedContext moduleInfoRegistry,
+        final SchemaContextProvider schemaContextProvider) {
 
         this.moduleInfoRegistry = requireNonNull(moduleInfoRegistry);
         this.schemaContextProvider = requireNonNull(schemaContextProvider);
-        this.runtimeContext = requireNonNull(runtimeContext);
+    }
+
+    @Override
+    public ObjectRegistration<YangModuleInfo> registerModuleInfo(final YangModuleInfo yangModuleInfo) {
+        return new ObjectRegistrationWrapper(registerInfo(yangModuleInfo));
     }
 
     @SuppressWarnings("checkstyle:illegalCatch")
@@ -52,18 +56,17 @@ final class OsgiModuleInfoRegistry implements ModuleInfoRegistry {
             LOG.error("Error updating the schema context", e);
             return;
         }
+        LOG.trace("Assembled context {}", context);
 
-        try {
-            runtimeContext.updateBindingRuntimeContext(context);
-        } catch (final RuntimeException e) {
-            LOG.error("Error updating binding runtime context", e);
-            return;
-        }
+        //        // FIXME: MDSAL-392: UGH, this should be a snapshot
+        //        final BindingRuntimeContext next = DefaultBindingRuntimeContext.create(
+        //            new DefaultBindingRuntimeGenerator().generateTypeMapping(context), moduleInfoRegistry);
+
+        // FIXME: publish new the new context, remove the old one
     }
 
-    @Override
-    public ObjectRegistration<YangModuleInfo> registerModuleInfo(final YangModuleInfo yangModuleInfo) {
-        return new ObjectRegistrationWrapper(moduleInfoRegistry.registerModuleInfo(yangModuleInfo));
+    ObjectRegistration<YangModuleInfo> registerInfo(final YangModuleInfo yangModuleInfo) {
+        return moduleInfoRegistry.registerModuleInfo(yangModuleInfo);
     }
 
     private class ObjectRegistrationWrapper implements ObjectRegistration<YangModuleInfo> {