Remove BindingRuntimeContext{Listener,Service} 17/88017/2
authorRobert Varga <robert.varga@pantheon.tech>
Sun, 23 Feb 2020 21:26:25 +0000 (22:26 +0100)
committerRobert Varga <robert.varga@pantheon.tech>
Sun, 23 Feb 2020 22:30:49 +0000 (23:30 +0100)
These are not used anywhere and we'll be publishing the context
to the SR anyway. Remove the code while preparing to have it
refactored with DS.

Change-Id: I7639a7ae64edbbc52789eaa0ce388ce7698ff2d7
JIRA: MDSAL-392
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
binding/mdsal-binding-dom-codec-osgi/src/main/java/org/opendaylight/mdsal/binding/dom/codec/osgi/BindingRuntimeContextListener.java [deleted file]
binding/mdsal-binding-dom-codec-osgi/src/main/java/org/opendaylight/mdsal/binding/dom/codec/osgi/BindingRuntimeContextService.java [deleted file]
binding/mdsal-binding-dom-codec-osgi/src/main/java/org/opendaylight/mdsal/binding/dom/codec/osgi/impl/Activator.java
binding/mdsal-binding-dom-codec-osgi/src/main/java/org/opendaylight/mdsal/binding/dom/codec/osgi/impl/OsgiModuleInfoRegistry.java
binding/mdsal-binding-dom-codec-osgi/src/main/java/org/opendaylight/mdsal/binding/dom/codec/osgi/impl/SimpleBindingRuntimeContextService.java [deleted file]

diff --git a/binding/mdsal-binding-dom-codec-osgi/src/main/java/org/opendaylight/mdsal/binding/dom/codec/osgi/BindingRuntimeContextListener.java b/binding/mdsal-binding-dom-codec-osgi/src/main/java/org/opendaylight/mdsal/binding/dom/codec/osgi/BindingRuntimeContextListener.java
deleted file mode 100644 (file)
index 42d5bca..0000000
+++ /dev/null
@@ -1,17 +0,0 @@
-/*
- * Copyright (c) 2017 Pantheon Technologies, s.r.o. and others.  All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * 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.mdsal.binding.dom.codec.osgi;
-
-import java.util.EventListener;
-import org.opendaylight.binding.runtime.api.BindingRuntimeContext;
-
-@Deprecated
-public interface BindingRuntimeContextListener extends EventListener {
-
-    void onBindingRuntimeContextUpdated(BindingRuntimeContext context);
-}
diff --git a/binding/mdsal-binding-dom-codec-osgi/src/main/java/org/opendaylight/mdsal/binding/dom/codec/osgi/BindingRuntimeContextService.java b/binding/mdsal-binding-dom-codec-osgi/src/main/java/org/opendaylight/mdsal/binding/dom/codec/osgi/BindingRuntimeContextService.java
deleted file mode 100644 (file)
index 76bb58f..0000000
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * Copyright (c) 2017 Pantheon Technologies, s.r.o. and others.  All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * 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.mdsal.binding.dom.codec.osgi;
-
-import com.google.common.annotations.Beta;
-import org.opendaylight.binding.runtime.api.BindingRuntimeContext;
-import org.opendaylight.yangtools.yang.model.repo.api.YangTextSchemaSource;
-import org.opendaylight.yangtools.yang.model.repo.spi.SchemaSourceProvider;
-
-/**
- * A {@link BindingRuntimeContext} enriched with the ability to look up {@link YangTextSchemaSource}s.
- *
- * @author Robert Varga
- *
- * @deprecated This service is exposed for transition purposes only.
- */
-@Deprecated
-@Beta
-public interface BindingRuntimeContextService extends SchemaSourceProvider<YangTextSchemaSource> {
-    /**
-     * Return the current {@link BindingRuntimeContext}.
-     *
-     * @return Current BindingRuntimeContext.
-     */
-    BindingRuntimeContext getBindingRuntimeContext();
-}
index 82d0e5af8718536533b3ebe0390c41123bfe3a0d..98e9735d3978a16207c5fbde307b2b73b00b2610 100644 (file)
@@ -12,7 +12,6 @@ import java.util.List;
 import org.opendaylight.binding.runtime.api.ClassLoadingStrategy;
 import org.opendaylight.binding.runtime.spi.GeneratedClassLoadingStrategy;
 import org.opendaylight.binding.runtime.spi.ModuleInfoBackedContext;
-import org.opendaylight.mdsal.binding.dom.codec.osgi.BindingRuntimeContextService;
 import org.osgi.framework.BundleActivator;
 import org.osgi.framework.BundleContext;
 import org.osgi.framework.ServiceRegistration;
@@ -25,7 +24,6 @@ public final class Activator implements BundleActivator {
     private final List<ServiceRegistration<?>> registrations = new ArrayList<>(2);
 
     private ModuleInfoBundleTracker bundleTracker = null;
-    private SimpleBindingRuntimeContextService service = null;
 
     @Override
     public void start(final BundleContext context) {
@@ -35,20 +33,14 @@ public final class Activator implements BundleActivator {
             // FIXME: This is the fallback strategy, it should not be needed
             GeneratedClassLoadingStrategy.getTCCLClassLoadingStrategy());
 
-        service = new SimpleBindingRuntimeContextService(context, moduleInfoBackedContext, moduleInfoBackedContext);
-
         final OsgiModuleInfoRegistry registry = new OsgiModuleInfoRegistry(moduleInfoBackedContext,
-                moduleInfoBackedContext, service);
+                moduleInfoBackedContext);
 
         LOG.debug("Starting Binding-DOM codec bundle tracker");
         bundleTracker = new ModuleInfoBundleTracker(context, registry);
         bundleTracker.open();
 
-        LOG.debug("Starting Binding-DOM runtime context service");
-        service.open();
-
         LOG.debug("Registering Binding-DOM codec services");
-        registrations.add(context.registerService(BindingRuntimeContextService.class, service, null));
         registrations.add(context.registerService(ClassLoadingStrategy.class, moduleInfoBackedContext, null));
 
         LOG.info("Binding-DOM codec started");
@@ -65,9 +57,6 @@ public final class Activator implements BundleActivator {
         LOG.debug("Stopping Binding-DOM codec bundle tracker");
         bundleTracker.close();
 
-        LOG.debug("Stoping Binding-DOM runtime context service");
-        service.close();
-
         LOG.info("Binding-DOM codec stopped");
     }
 }
index f8ff801e18165fdf7f6d359d693741aabd819180..b001583f70912389bf25702673bed5e4bac0fecd 100644 (file)
@@ -10,6 +10,7 @@ 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.binding.runtime.spi.ModuleInfoBackedContext;
 import org.opendaylight.binding.runtime.spi.ModuleInfoRegistry;
 import org.opendaylight.yangtools.concepts.ObjectRegistration;
 import org.opendaylight.yangtools.yang.binding.YangModuleInfo;
@@ -25,21 +26,19 @@ 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
@@ -57,13 +56,13 @@ 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
     }
 
     ObjectRegistration<YangModuleInfo> registerInfo(final YangModuleInfo yangModuleInfo) {
diff --git a/binding/mdsal-binding-dom-codec-osgi/src/main/java/org/opendaylight/mdsal/binding/dom/codec/osgi/impl/SimpleBindingRuntimeContextService.java b/binding/mdsal-binding-dom-codec-osgi/src/main/java/org/opendaylight/mdsal/binding/dom/codec/osgi/impl/SimpleBindingRuntimeContextService.java
deleted file mode 100644 (file)
index 98203f1..0000000
+++ /dev/null
@@ -1,86 +0,0 @@
-/*
- * Copyright (c) 2017 Pantheon Technologies, s.r.o. and others.  All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * 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.mdsal.binding.dom.codec.osgi.impl;
-
-import static com.google.common.base.Preconditions.checkState;
-import static java.util.Objects.requireNonNull;
-
-import com.google.common.util.concurrent.ListenableFuture;
-import org.checkerframework.checker.lock.qual.GuardedBy;
-import org.opendaylight.binding.runtime.api.BindingRuntimeContext;
-import org.opendaylight.binding.runtime.api.ClassLoadingStrategy;
-import org.opendaylight.binding.runtime.api.DefaultBindingRuntimeContext;
-import org.opendaylight.mdsal.binding.dom.codec.osgi.BindingRuntimeContextListener;
-import org.opendaylight.mdsal.binding.dom.codec.osgi.BindingRuntimeContextService;
-import org.opendaylight.mdsal.binding.generator.impl.DefaultBindingRuntimeGenerator;
-import org.opendaylight.yangtools.yang.model.api.SchemaContext;
-import org.opendaylight.yangtools.yang.model.repo.api.SourceIdentifier;
-import org.opendaylight.yangtools.yang.model.repo.api.YangTextSchemaSource;
-import org.opendaylight.yangtools.yang.model.repo.spi.SchemaSourceProvider;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.ServiceReference;
-import org.osgi.util.tracker.ServiceTracker;
-
-@Deprecated
-final class SimpleBindingRuntimeContextService extends
-        ServiceTracker<BindingRuntimeContextListener, BindingRuntimeContextListener>
-        implements BindingRuntimeContextService {
-    private final SchemaSourceProvider<YangTextSchemaSource> sourceProvider;
-    private final ClassLoadingStrategy strategy;
-    private final Object lock = new Object();
-
-    @GuardedBy("lock")
-    private BindingRuntimeContext current;
-
-    SimpleBindingRuntimeContextService(final BundleContext context, final ClassLoadingStrategy strategy,
-        final SchemaSourceProvider<YangTextSchemaSource> sourceProvider) {
-        super(context, BindingRuntimeContextListener.class, null);
-        this.sourceProvider = requireNonNull(sourceProvider);
-        this.strategy = requireNonNull(strategy);
-    }
-
-    @Override
-    public ListenableFuture<? extends YangTextSchemaSource> getSource(final SourceIdentifier sourceIdentifier) {
-        return sourceProvider.getSource(sourceIdentifier);
-    }
-
-    @Override
-    public BindingRuntimeContext getBindingRuntimeContext() {
-        synchronized (lock) {
-            checkState(current != null, "Runtime context is not initialized yet");
-            return current;
-        }
-    }
-
-    void updateBindingRuntimeContext(final SchemaContext schemaContext) {
-        final BindingRuntimeContext next = DefaultBindingRuntimeContext.create(
-            new DefaultBindingRuntimeGenerator().generateTypeMapping(schemaContext), strategy);
-
-        final BindingRuntimeContextListener[] listeners;
-        synchronized (lock) {
-            current = next;
-            listeners = this.getServices(new BindingRuntimeContextListener[0]);
-        }
-
-        for (BindingRuntimeContextListener l : listeners) {
-            l.onBindingRuntimeContextUpdated(next);
-        }
-    }
-
-    @Override
-    public BindingRuntimeContextListener addingService(
-            final ServiceReference<BindingRuntimeContextListener> reference) {
-        final BindingRuntimeContextListener listener = super.addingService(reference);
-
-        synchronized (lock) {
-            listener.onBindingRuntimeContextUpdated(current);
-        }
-
-        return listener;
-    }
-}