X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=src%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fblueprint%2FBlueprintBundleTracker.java;h=5727c13ba1e888825d94b96bcc1c330bdf39fa1e;hb=251c682ff0ba6b3e1406903f5a6d0f9fab640f52;hp=98e31e826b464741f5f0fe36a7f6a2c423245af3;hpb=6873acef891d160e4196df92dd2f13b53f131e38;p=mdsal.git diff --git a/src/main/java/org/opendaylight/controller/blueprint/BlueprintBundleTracker.java b/src/main/java/org/opendaylight/controller/blueprint/BlueprintBundleTracker.java index 98e31e826b..5727c13ba1 100644 --- a/src/main/java/org/opendaylight/controller/blueprint/BlueprintBundleTracker.java +++ b/src/main/java/org/opendaylight/controller/blueprint/BlueprintBundleTracker.java @@ -12,7 +12,10 @@ import java.util.Dictionary; import java.util.Enumeration; import java.util.Hashtable; import java.util.List; +import org.apache.aries.blueprint.NamespaceHandler; import org.apache.aries.blueprint.services.BlueprintExtenderService; +import org.apache.aries.util.AriesFrameworkUtil; +import org.opendaylight.controller.blueprint.ext.OpendaylightNamespaceHandler; import org.osgi.framework.Bundle; import org.osgi.framework.BundleActivator; import org.osgi.framework.BundleContext; @@ -45,7 +48,9 @@ public class BlueprintBundleTracker implements BundleActivator, BundleTrackerCus private ServiceTracker serviceTracker; private BundleTracker bundleTracker; private volatile BlueprintExtenderService blueprintExtenderService; + private volatile ServiceRegistration blueprintContainerRestartReg; private ServiceRegistration eventHandlerReg; + private ServiceRegistration namespaceReg; /** * Implemented from BundleActivator. @@ -54,11 +59,9 @@ public class BlueprintBundleTracker implements BundleActivator, BundleTrackerCus public void start(BundleContext context) { LOG.info("Starting {}", getClass().getSimpleName()); - // Register EventHandler for blueprint events + registerBlueprintEventHandler(context); - Dictionary props = new Hashtable<>(); - props.put(org.osgi.service.event.EventConstants.EVENT_TOPIC, EventConstants.TOPIC_CREATED); - eventHandlerReg = context.registerService(EventHandler.class.getName(), this, props); + registerNamespaceHandler(context); bundleTracker = new BundleTracker<>(context, Bundle.ACTIVE, this); @@ -72,6 +75,10 @@ public class BlueprintBundleTracker implements BundleActivator, BundleTrackerCus LOG.debug("Got BlueprintExtenderService"); + blueprintContainerRestartReg = context.registerService( + BlueprintContainerRestartService.class.getName(), + new BlueprintContainerRestartServiceImpl(blueprintExtenderService), new Hashtable<>()); + return blueprintExtenderService; } @@ -88,6 +95,19 @@ public class BlueprintBundleTracker implements BundleActivator, BundleTrackerCus serviceTracker.open(); } + private void registerNamespaceHandler(BundleContext context) { + Dictionary props = new Hashtable<>(); + props.put("osgi.service.blueprint.namespace", OpendaylightNamespaceHandler.NAMESPACE_1_0_0); + namespaceReg = context.registerService(NamespaceHandler.class.getName(), + new OpendaylightNamespaceHandler(), props); + } + + private void registerBlueprintEventHandler(BundleContext context) { + Dictionary props = new Hashtable<>(); + props.put(org.osgi.service.event.EventConstants.EVENT_TOPIC, EventConstants.TOPIC_CREATED); + eventHandlerReg = context.registerService(EventHandler.class.getName(), this, props); + } + /** * Implemented from BundleActivator. */ @@ -95,7 +115,10 @@ public class BlueprintBundleTracker implements BundleActivator, BundleTrackerCus public void stop(BundleContext context) { bundleTracker.close(); serviceTracker.close(); - eventHandlerReg.unregister(); + + AriesFrameworkUtil.safeUnregisterService(eventHandlerReg); + AriesFrameworkUtil.safeUnregisterService(namespaceReg); + AriesFrameworkUtil.safeUnregisterService(blueprintContainerRestartReg); } /**