BundleScanner needs to be registered as a bundle listener to track bundles being...
[controller.git] / opendaylight / northbound / bundlescanner / implementation / src / main / java / org / opendaylight / controller / northbound / bundlescanner / internal / Activator.java
index 82de105709004b5ba5323de0f58f6c822431fa57..69c81242d99c1ace9cc2ebdbb8a9fd47d9ca07c8 100644 (file)
@@ -11,12 +11,26 @@ package org.opendaylight.controller.northbound.bundlescanner.internal;
 import org.apache.felix.dm.Component;
 import org.opendaylight.controller.northbound.bundlescanner.IBundleScanService;
 import org.opendaylight.controller.sal.core.ComponentActivatorAbstractBase;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.FrameworkUtil;
 
 /**
  * The activator registers the BundleScanner.
  */
 public class Activator extends ComponentActivatorAbstractBase {
 
+    @Override
+    protected void init() {
+        BundleContext context = FrameworkUtil.getBundle(BundleScanner.class).getBundleContext();
+        context.addBundleListener(BundleScanner.getInstance());
+    }
+
+    @Override
+    public void destroy() {
+        BundleContext context = FrameworkUtil.getBundle(BundleScanner.class).getBundleContext();
+        context.removeBundleListener(BundleScanner.getInstance());
+    }
+
     @Override
     protected Object[] getGlobalImplementations() {
         return new Object[] { BundleScanServiceImpl.class };