Advertise ClassLoadingStrategy service 09/73009/2
authorTom Pantelis <tompantelis@gmail.com>
Thu, 14 Jun 2018 21:47:11 +0000 (17:47 -0400)
committerRobert Varga <robert.varga@pantheon.tech>
Mon, 18 Jun 2018 08:09:11 +0000 (10:09 +0200)
The ConfigManagerActivator advertises its ModuleInfoBackedContext
as the ClassLoadingStrategy service but the CSS features are being
removed. Therefore advertise mdsal's ModuleInfoBackedContext instance.

Change-Id: Ie03a25db940d3ae17ae5250cafe9fcc32a5baac7
Signed-off-by: Tom Pantelis <tompantelis@gmail.com>
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
binding/mdsal-binding-dom-codec-osgi/pom.xml
binding/mdsal-binding-dom-codec-osgi/src/main/java/org/opendaylight/mdsal/binding/dom/codec/osgi/impl/Activator.java

index 0645049cd0d6d8c38e235dd628f83f4dab2d2071..357a0b48f84f95149c80a56615e7d0827a208bcb 100644 (file)
@@ -75,7 +75,7 @@
                 <configuration>
                     <instructions>
                         <Bundle-Name>${project.groupId}.${project.artifactId}</Bundle-Name>
-                        <Activator>org.opendaylight.mdsal.binding.dom.codec.osgi.impl.Activator</Activator>
+                        <Bundle-Activator>org.opendaylight.mdsal.binding.dom.codec.osgi.impl.Activator</Bundle-Activator>
                     </instructions>
                 </configuration>
             </plugin>
index dd51b1591972d4ac59e450d4bd0181ba9bffd1fc..994a88d815bc13ec76342d00035241094a805588 100644 (file)
@@ -7,8 +7,11 @@
  */
 package org.opendaylight.mdsal.binding.dom.codec.osgi.impl;
 
+import java.util.ArrayList;
 import java.util.Collection;
+import java.util.List;
 import org.opendaylight.mdsal.binding.dom.codec.osgi.BindingRuntimeContextService;
+import org.opendaylight.mdsal.binding.generator.api.ClassLoadingStrategy;
 import org.opendaylight.mdsal.binding.generator.impl.ModuleInfoBackedContext;
 import org.opendaylight.yangtools.concepts.ObjectRegistration;
 import org.opendaylight.yangtools.yang.binding.YangModuleInfo;
@@ -19,9 +22,10 @@ import org.osgi.framework.ServiceRegistration;
 import org.osgi.util.tracker.BundleTracker;
 
 public final class Activator implements BundleActivator {
+    private final List<ServiceRegistration<?>> registrations = new ArrayList<>(2);
+
     private BundleTracker<Collection<ObjectRegistration<YangModuleInfo>>> moduleInfoResolvedBundleTracker;
     private SimpleBindingRuntimeContextService service;
-    private ServiceRegistration<?> registration;
 
     @Override
     public void start(final BundleContext context) {
@@ -31,7 +35,7 @@ public final class Activator implements BundleActivator {
         service = new SimpleBindingRuntimeContextService(context, moduleInfoBackedContext, moduleInfoBackedContext);
 
         final OsgiModuleInfoRegistry registry = new OsgiModuleInfoRegistry(moduleInfoBackedContext,
-            moduleInfoBackedContext, service);
+                moduleInfoBackedContext, service);
 
         final ModuleInfoBundleTracker moduleInfoTracker = new ModuleInfoBundleTracker(registry);
         moduleInfoResolvedBundleTracker = new BundleTracker<>(context, Bundle.RESOLVED | Bundle.STARTING
@@ -40,13 +44,15 @@ public final class Activator implements BundleActivator {
         moduleInfoTracker.finishStart();
 
         service.open();
-        registration = context.registerService(BindingRuntimeContextService.class, service, null);
+        registrations.add(context.registerService(BindingRuntimeContextService.class, service, null));
+        registrations.add(context.registerService(ClassLoadingStrategy.class, moduleInfoBackedContext, null));
     }
 
     @Override
     public void stop(final BundleContext context) {
         moduleInfoResolvedBundleTracker.close();
         service.close();
-        registration.unregister();
+        registrations.forEach(ServiceRegistration::unregister);
+        registrations.clear();
     }
 }