config-manager: final parameters
[controller.git] / opendaylight / config / config-manager / src / main / java / org / opendaylight / controller / config / manager / impl / dependencyresolver / ModuleInternalTransactionalInfo.java
index e9f573a05def40ec079dc3a45522698358ed8ee0..3a58b01b405387a6cba60467d170f76c8661d8c0 100644 (file)
@@ -7,6 +7,9 @@
  */
 package org.opendaylight.controller.config.manager.impl.dependencyresolver;
 
+import com.google.common.base.Preconditions;
+import javax.annotation.Nonnull;
+import javax.annotation.Nullable;
 import org.opendaylight.controller.config.api.ModuleIdentifier;
 import org.opendaylight.controller.config.manager.impl.ModuleInternalInfo;
 import org.opendaylight.controller.config.manager.impl.dynamicmbean.DynamicReadableWrapper;
@@ -14,23 +17,24 @@ import org.opendaylight.controller.config.manager.impl.jmx.TransactionModuleJMXR
 import org.opendaylight.controller.config.spi.Module;
 import org.opendaylight.controller.config.spi.ModuleFactory;
 import org.opendaylight.yangtools.concepts.Identifiable;
-
-import javax.annotation.Nullable;
+import org.osgi.framework.BundleContext;
 
 public class ModuleInternalTransactionalInfo implements Identifiable<ModuleIdentifier> {
     private final ModuleIdentifier name;
-    private final Module proxiedModule, realModule;
+    private final Module proxiedModule;
+    private final Module realModule;
     private final ModuleFactory moduleFactory;
-    @Nullable
-    private final ModuleInternalInfo maybeOldInternalInfo;
+
     private final TransactionModuleJMXRegistration transactionModuleJMXRegistration;
     private final boolean isDefaultBean;
+    private final BundleContext bundleContext;
+    @Nullable private ModuleInternalInfo maybeOldInternalInfo;
 
-    public ModuleInternalTransactionalInfo(ModuleIdentifier name, Module proxiedModule,
-                                           ModuleFactory moduleFactory,
-                                           ModuleInternalInfo maybeOldInternalInfo,
-                                           TransactionModuleJMXRegistration transactionModuleJMXRegistration,
-                                           boolean isDefaultBean, Module realModule) {
+    public ModuleInternalTransactionalInfo(final ModuleIdentifier name, final Module proxiedModule,
+                                           final ModuleFactory moduleFactory,
+                                           final ModuleInternalInfo maybeOldInternalInfo,
+                                           final TransactionModuleJMXRegistration transactionModuleJMXRegistration,
+                                           final boolean isDefaultBean, final Module realModule, final BundleContext bundleContext) {
         this.name = name;
         this.proxiedModule = proxiedModule;
         this.moduleFactory = moduleFactory;
@@ -38,6 +42,7 @@ public class ModuleInternalTransactionalInfo implements Identifiable<ModuleIdent
         this.transactionModuleJMXRegistration = transactionModuleJMXRegistration;
         this.isDefaultBean = isDefaultBean;
         this.realModule = realModule;
+        this.bundleContext = bundleContext;
     }
 
 
@@ -54,7 +59,7 @@ public class ModuleInternalTransactionalInfo implements Identifiable<ModuleIdent
         return new DestroyedModule(name, oldModule.getInstance(),
                 maybeOldInternalInfo.getModuleJMXRegistrator(),
                 maybeOldInternalInfo.getOsgiRegistration(),
-                maybeOldInternalInfo.getOrderingIdx());
+                maybeOldInternalInfo.getOrderingIdx(), maybeOldInternalInfo.getRuntimeBeanRegistrator());
     }
 
 
@@ -66,12 +71,13 @@ public class ModuleInternalTransactionalInfo implements Identifiable<ModuleIdent
         return moduleFactory;
     }
 
-    @Nullable
-    public ModuleInternalInfo getOldInternalInfo() {
-        if (maybeOldInternalInfo == null) {
-            throw new NullPointerException();
-        }
-        return maybeOldInternalInfo;
+    @Nonnull public ModuleInternalInfo getOldInternalInfo() {
+        return Preconditions.checkNotNull(maybeOldInternalInfo);
+    }
+
+    public void clearOldInternalInfo() {
+        Preconditions.checkState(maybeOldInternalInfo != null, "No old internal info present");
+        maybeOldInternalInfo = null;
     }
 
     public TransactionModuleJMXRegistration getTransactionModuleJMXRegistration() {
@@ -90,4 +96,8 @@ public class ModuleInternalTransactionalInfo implements Identifiable<ModuleIdent
     public Module getRealModule() {
         return realModule;
     }
+
+    public BundleContext getBundleContext() {
+        return bundleContext;
+    }
 }