Introduce lifecycle to runtime beans registrator in config-manager
[controller.git] / opendaylight / config / config-manager / src / main / java / org / opendaylight / controller / config / manager / impl / ModuleInternalInfo.java
index fd6262cb8cf34f222b70c0e643bf9edc688d46b5..267e504f859fe3bd024bf5eb2d098fdb4904e935 100644 (file)
@@ -8,14 +8,15 @@
 package org.opendaylight.controller.config.manager.impl;
 
 import javax.annotation.Nullable;
-
 import org.opendaylight.controller.config.api.ModuleIdentifier;
 import org.opendaylight.controller.config.manager.impl.dependencyresolver.DestroyedModule;
 import org.opendaylight.controller.config.manager.impl.dynamicmbean.DynamicReadableWrapper;
 import org.opendaylight.controller.config.manager.impl.jmx.ModuleJMXRegistrator;
 import org.opendaylight.controller.config.manager.impl.jmx.RootRuntimeBeanRegistratorImpl;
 import org.opendaylight.controller.config.manager.impl.osgi.BeanToOsgiServiceManager.OsgiRegistration;
+import org.opendaylight.controller.config.spi.ModuleFactory;
 import org.opendaylight.yangtools.concepts.Identifiable;
+import org.osgi.framework.BundleContext;
 
 /**
  * Provides metadata about Module from controller to registry.
@@ -37,22 +38,20 @@ public class ModuleInternalInfo implements Comparable<ModuleInternalInfo>,
     private final ModuleJMXRegistrator moduleJMXRegistrator;
     private final int orderingIdx;
     private final boolean isDefaultBean;
+    private final ModuleFactory moduleFactory;
+    private final BundleContext bundleContext;
 
     public ModuleInternalInfo(ModuleIdentifier name,
             @Nullable DynamicReadableWrapper readableModule,
             OsgiRegistration osgiRegistration,
-            RootRuntimeBeanRegistratorImpl runtimeBeanRegistrator,
+            @Nullable RootRuntimeBeanRegistratorImpl runtimeBeanRegistrator,
             ModuleJMXRegistrator moduleJMXRegistrator, int orderingIdx,
-            boolean isDefaultBean) {
+            boolean isDefaultBean, ModuleFactory moduleFactory, BundleContext bundleContext) {
 
         if (osgiRegistration == null) {
             throw new IllegalArgumentException(
                     "Parameter 'osgiRegistration' is missing");
         }
-        if (runtimeBeanRegistrator == null) {
-            throw new IllegalArgumentException(
-                    "Parameter 'runtimeBeanRegistrator' is missing");
-        }
         this.readableModule = readableModule;
         this.osgiRegistration = osgiRegistration;
         this.runtimeBeanRegistrator = runtimeBeanRegistrator;
@@ -60,6 +59,8 @@ public class ModuleInternalInfo implements Comparable<ModuleInternalInfo>,
         this.moduleJMXRegistrator = moduleJMXRegistrator;
         this.orderingIdx = orderingIdx;
         this.isDefaultBean = isDefaultBean;
+        this.moduleFactory = moduleFactory;
+        this.bundleContext = bundleContext;
     }
 
     public DynamicReadableWrapper getReadableModule() {
@@ -109,7 +110,7 @@ public class ModuleInternalInfo implements Comparable<ModuleInternalInfo>,
     public DestroyedModule toDestroyedModule() {
         return new DestroyedModule(getIdentifier(),
                 getReadableModule().getInstance(), getModuleJMXRegistrator(),
-                getOsgiRegistration(), getOrderingIdx());
+                getOsgiRegistration(), getOrderingIdx(), runtimeBeanRegistrator);
     }
 
     @Override
@@ -120,4 +121,12 @@ public class ModuleInternalInfo implements Comparable<ModuleInternalInfo>,
     public boolean isDefaultBean() {
         return isDefaultBean;
     }
+
+    public ModuleFactory getModuleFactory() {
+        return moduleFactory;
+    }
+
+    public BundleContext getBundleContext() {
+        return bundleContext;
+    }
 }